Mercurial > octave
annotate libinterp/corefcn/text-renderer.cc @ 29470:2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
* NEWS: Announce basic support for "latex" interpreter.
* plot.txi: Restructure the "Use of the interpreter Property" section to include
3 subsections, one for each interpreter type. In "Printing and Saving Plots"
describe the new behavior.
* print.m: Document new behavior.
* contributors.in: Add Andrej Lojdl, a former GSoC student that worked on this
subject. Even though there is not much left of his original work, it served
as a very useful starting point.
* base-text-renderer.h, base-text-renderer.cc: New enum to store symbolic
constants for rotation angles.
(base_text_renderer::rotate_pixels): New utility method. Code extracted
from ft_text_renderer::render.
(base_text_renderer::rotation_to_mode): Moved from ft_text_renderer class.
(base_text_renderer::fix_bbox_anchor): New utility method. Code extracted
from ft_text_renderer::text_to_pixels.
* ft_text_renderer.cc (ft_text_renderer::render,
ft_text_renderer::text_to_pixels): Make use of base class utility functions.
* gl2ps-print.cc: New counter variable m_svg_def_index for safe inclusion of
defs coming from dvisvgm.
(gl2ps_renderer::format_svg_element): New function to manipulate svg elements
obtained from dvisvgm so as to position them properly on the figure and
change their color.
(gl2ps_renderer::strlist_to_svg): If the str_list object returned from
text_to_strlist contains an svg element, use format_svg_element to handle
position and color and then return it. Otherwise, use <g> and <text> elements
rather than <text> and <tspan> elements which are not supported by Qt's svg
renderer (svg-tiny implementation).
(gl2ps_renderer::strlist_to_ps): If the str_list object returned from
text_to_strlist contains an svg element, raise a warning about the
necessity of using -svgconvert.
* latex-text-renderer.h, latex-text-renderer.cc: New files to hold the
latex_interpreter class.
* libinterp/corefcn/module.mk: Add new files to the build system.
* text-renderer.h, text-renderer.cc (text_renderer): New data member latex_rep
to hold a pointer to an instance of a latex_renderer.
(text_renderer::~text_renderer, get_extent, set_anti_aliasing, set_font,
set_color, text_to_pixels, text_to_strlist): Duplicate action of the
latex_rep.
(text_renderer::latex_ok): New method to test the usability of the
latex_renderer.
(text_renderer::string::svg_element, text_renderer::string::set_svg_element,
text_renderer::string::get_svg_element): New string data member to hold
preformated svg element. Provide accessor methods.
* acinclude.m4: Add QtSvg to the list of imported QT_MODULES.
* octave-svgconvert.cc: Overhaul program to make use of Qt's QSvgRenderer
when rendering to PDF.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Mon, 22 Mar 2021 21:32:54 +0100 |
parents | 0a5b15007766 |
children | af41ebf3d1b3 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 2009-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
21209 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
22003
2d3972b802ff
use consistent style for including config.h in source files
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
27 # include "config.h" |
21209 | 28 #endif |
29 | |
30 #include "base-text-renderer.h" | |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
31 #include "error.h" |
21209 | 32 #include "errwarn.h" |
33 #include "ft-text-renderer.h" | |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
34 #include "latex-text-renderer.h" |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
35 #include "oct-env.h" |
21209 | 36 #include "text-renderer.h" |
37 | |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
38 namespace octave |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
39 { |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
40 text_renderer::text_renderer (void) |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
41 : rep (make_ft_text_renderer ()), latex_rep (make_latex_text_renderer ()) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
42 { } |
21209 | 43 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
44 text_renderer::~text_renderer (void) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
45 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
46 delete rep; |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
47 delete latex_rep; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
48 } |
21209 | 49 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
50 bool |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
51 text_renderer::ok (void) const |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
52 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
53 static bool warned = false; |
21209 | 54 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
55 if (! rep) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
56 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
57 if (! warned) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
58 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
59 warn_disabled_feature ("opengl_renderer::render_text", |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
60 "rendering text (FreeType)"); |
21209 | 61 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
62 warned = true; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
63 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
64 } |
21209 | 65 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
66 return rep != nullptr; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
67 } |
21209 | 68 |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
69 bool |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
70 text_renderer::latex_ok (void) const |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
71 { |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
72 static bool warned = false; |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
73 |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
74 if (! sys::env::getenv ("OCTAVE_LATEX_DEBUG_FLAG").empty () |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
75 && ! latex_rep && ! warned) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
76 { |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
77 warning_with_id ("Octave:LaTeX:internal-error", |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
78 "latex_renderer: unusable latex tool-chain"); |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
79 warned = true; |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
80 } |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
81 |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
82 return latex_rep != nullptr; |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
83 } |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
84 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
85 Matrix |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
86 text_renderer::get_extent (text_element *elt, double rotation) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
87 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
88 static Matrix empty_extent (1, 4, 0.0); |
21209 | 89 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
90 return ok () ? rep->get_extent (elt, rotation) : empty_extent; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
91 } |
21209 | 92 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
93 Matrix |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
94 text_renderer::get_extent (const std::string& txt, double rotation, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
95 const caseless_str& interpreter) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
96 { |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
97 static Matrix retval (1, 4, 0.0); |
21209 | 98 |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
99 if (interpreter == "latex" && latex_ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
100 retval = latex_rep->get_extent (txt, rotation, interpreter); |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
101 else if (ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
102 retval = rep->get_extent (txt, rotation, interpreter); |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
103 |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
104 return retval; |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
105 } |
21209 | 106 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
107 void |
26858
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
108 text_renderer::set_anti_aliasing (bool val) |
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
109 { |
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
110 if (ok ()) |
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
111 rep->set_anti_aliasing (val); |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
112 |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
113 if (latex_ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
114 latex_rep->set_anti_aliasing (val); |
26858
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
115 } |
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
116 |
27623
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
117 octave_map |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
118 text_renderer::get_system_fonts (void) |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
119 { |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
120 octave_map retval; |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
121 |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
122 if (ok ()) |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
123 retval = rep->get_system_fonts (); |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
124 |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
125 return retval; |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
126 } |
698c8b08fe8c
New function uisetfont (bug #57130).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
27102
diff
changeset
|
127 |
26858
0adb232f93b9
Implement axes and text "fontsmoothing" property (bug #55833).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
128 void |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
129 text_renderer::set_font (const std::string& name, const std::string& weight, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
130 const std::string& angle, double size) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
131 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
132 if (ok ()) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
133 rep->set_font (name, weight, angle, size); |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
134 |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
135 if (latex_ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
136 latex_rep->set_font (name, weight, angle, size); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
137 } |
21209 | 138 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
139 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
140 text_renderer::set_color (const Matrix& c) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
141 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
142 if (ok ()) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
143 rep->set_color (c); |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
144 |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
145 if (latex_ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
146 latex_rep->set_color (c); |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
147 } |
21209 | 148 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
149 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
150 text_renderer::text_to_pixels (const std::string& txt, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
151 uint8NDArray& pxls, Matrix& bbox, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
152 int halign, int valign, double rotation, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
153 const caseless_str& interpreter, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
154 bool handle_rotation) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
155 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
156 static Matrix empty_bbox (1, 4, 0.0); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
157 static uint8NDArray empty_pxls; |
21209 | 158 |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
159 if (interpreter == "latex" && latex_ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
160 latex_rep->text_to_pixels (txt, pxls, bbox, halign, valign, rotation, |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
161 interpreter, handle_rotation); |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
162 else if (ok ()) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
163 rep->text_to_pixels (txt, pxls, bbox, halign, valign, rotation, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
164 interpreter, handle_rotation); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
165 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
166 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
167 bbox = empty_bbox; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
168 pxls = empty_pxls; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
169 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
170 } |
21209 | 171 |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
172 void |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
173 text_renderer::text_to_strlist (const std::string& txt, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
174 std::list<text_renderer::string>& lst, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
175 Matrix& bbox, int halign, int valign, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
176 double rotation, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
177 const caseless_str& interpreter) |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
178 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
179 static Matrix empty_bbox (1, 4, 0.0); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
180 static std::list<text_renderer::string> empty_lst; |
21209 | 181 |
29470
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
182 if (interpreter == "latex" && latex_ok ()) |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
183 latex_rep->text_to_strlist (txt, lst, bbox, halign, valign, rotation, |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
184 interpreter); |
2ae4764180c6
Initial implementation of a LaTeX interpreter (bug #59546).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
29358
diff
changeset
|
185 else if (ok ()) |
22331
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
186 rep->text_to_strlist (txt, lst, bbox, halign, valign, rotation, |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
187 interpreter); |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
188 else |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
189 { |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
190 bbox = empty_bbox; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
191 lst = empty_lst; |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
192 } |
b81b08cc4c83
maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents:
22326
diff
changeset
|
193 } |
21209 | 194 } |