annotate libinterp/corefcn/text-renderer.h @ 26443:6dfb842362dd stable

text-renderer.h: Fix static analyzer detected issues (bug #55347). * text-renderer.h (string (const string& s)): Initialize z data member from s. * text-renderer.h (string operator =): Initialize z data member.
author Rik <rik@octave.org>
date Fri, 04 Jan 2019 21:55:07 -0800
parents 00f796120a6d
children 0adb232f93b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25643
diff changeset
3 Copyright (C) 2016-2019 John W. Eaton
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25643
diff changeset
4 Copyright (C) 2009-2019 Michael Goffioul
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 This file is part of Octave.
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24076
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24076
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
11 (at your option) any later version.
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
16 GNU General Public License for more details.
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24076
diff changeset
20 <https://www.gnu.org/licenses/>.
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 */
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #if ! defined (octave_text_renderer_h)
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #define octave_text_renderer_h 1
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21209
diff changeset
27 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21209
diff changeset
28
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <list>
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <string>
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
31 #include <vector>
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "caseless-str.h"
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include "dMatrix.h"
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "uint8NDArray.h"
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
22326
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
37 namespace octave
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
38 {
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
39 class base_text_renderer;
25643
afb5288a25ad move text engine classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
40 class text_element;
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
42 class
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
43 OCTINTERP_API
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
44 text_renderer
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 {
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 public:
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
48 text_renderer (void);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
49
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
50 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
51
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
52 text_renderer (const text_renderer&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
53
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
54 text_renderer& operator = (const text_renderer&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
55
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
56 ~text_renderer (void);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
57
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
58 bool ok (void) const;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
59
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
60 Matrix get_extent (text_element *elt, double rotation = 0.0);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
61
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
62 Matrix get_extent (const std::string& txt, double rotation = 0.0,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
63 const caseless_str& interpreter = "tex");
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
65 void 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
66 const std::string& angle, double size);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
67
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
68 void set_color (const Matrix& c);
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
70 void text_to_pixels (const std::string& txt,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
71 uint8NDArray& pxls, Matrix& bbox,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
72 int halign, int valign, double rotation = 0.0,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
73 const caseless_str& interpreter = "tex",
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
74 bool handle_rotation = true);
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
76 class font
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 {
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
78 public:
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
79
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
80 font (void)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
81 : name (), weight (), angle (), size (0)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
82 { }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
83
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
84 font (const std::string& nm, const std::string& wt,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
85 const std::string& ang, double sz)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
86 : name (nm), weight (wt), angle (ang), size (sz)
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
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
89 font (const font& ft)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
90 : name (ft.name), weight (ft.weight), angle (ft.angle),
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
91 size (ft.size)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
92 { }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
93
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
94 ~font (void) = default;
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
96 font& operator = (const font& ft)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
97 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
98 if (&ft != this)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
99 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
100 name = ft.name;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
101 weight = ft.weight;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
102 angle = ft.angle;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
103 size = ft.size;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
104 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
105
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
106 return *this;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
107 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
108
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
109 std::string get_name (void) const { return name; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
110
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
111 std::string get_weight (void) const { return weight; }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
113 std::string get_angle (void) const { return angle; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
114
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
115 double get_size (void) const { return size; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
116
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
117 protected:
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
119 std::string name;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
120 std::string weight;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
121 std::string angle;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
122 double size;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
123 };
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
124
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
125 // Container for substrings after parsing.
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
126
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
127 class string
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
128 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
129 public:
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
131 string (const std::string& s, font& f, const double x0, const double y0)
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
132 : str (s), family (f.get_name ()), fnt (f), x (x0), y (y0), z (0.0),
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
133 xdata (), code (0), color (Matrix (1,3,0.0))
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
134 { }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
136 string (const string& s)
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
137 : str (s.str), family (s.family), fnt (s.fnt), x (s.x), y (s.y),
26443
6dfb842362dd text-renderer.h: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
138 z (s.z), xdata (s.xdata), code (s.code), color (s.color)
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
139 { }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
141 ~string (void) = default;
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
143 string& operator = (const string& s)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
144 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
145 if (&s != this)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
146 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
147 str = s.str;
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
148 family = s.family;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
149 fnt = s.fnt;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
150 x = s.x;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
151 y = s.y;
26443
6dfb842362dd text-renderer.h: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
152 z = s.z;
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
153 xdata = s.xdata;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
154 code = s.code;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
155 color = s.color;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
156 }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
158 return *this;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
159 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
160
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
161 void set_string (const std::string& s) { str = s; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
162
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
163 std::string get_string (void) const { return str; }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
165 std::string get_name (void) const { return fnt.get_name (); }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
166
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
167 std::string get_family (void) const { return family; }
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
168
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
169 void set_family (const std::string& nm) { family = nm; }
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
170
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
171 std::string get_weight (void) const { return fnt.get_weight (); }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
172
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
173 std::string get_angle (void) const { return fnt.get_angle (); }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
174
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
175 double get_size (void) const { return fnt.get_size (); }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
177 void set_x (const double x0) { x = x0; }
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 double get_x (void) const { return x; }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
181 void set_xdata (const std::vector<double>& x0) { xdata = x0; }
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
182
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
183 std::vector<double> get_xdata (void) const { return xdata; }
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
184
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
185 void set_y (const double y0) { y = y0; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
186
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
187 double get_y (void) const { return y; }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
189 void set_z (const double z0) { z = z0; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
190
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
191 double get_z (void) const { return z; }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
193 void set_code (const uint32_t c) { code = c; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
194
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
195 uint32_t get_code (void) const { return code; }
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
197 void set_color (const uint8NDArray& c)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
198 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
199 color(0) = static_cast<double> (c(0)) / 255;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
200 color(1) = static_cast<double> (c(1)) / 255;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
201 color(2) = static_cast<double> (c(2)) / 255;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
202 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
203
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
204 Matrix get_color (void) const { return color; }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
205
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
206 private:
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
208 std::string str;
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
209 std::string family;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
210 font fnt;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
211 double x, y, z;
24076
1b7e49a72c62 improve text rendering in svg printout (bug #48567)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23220
diff changeset
212 std::vector<double> xdata;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
213 uint32_t code;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
214 Matrix color;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
215 };
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
216
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
217 void text_to_strlist (const std::string& txt,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
218 std::list<string>& lst, Matrix& box,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
219 int halign, int valign, double rotation = 0.0,
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
220 const caseless_str& interpreter = "tex");
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
221
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222 private:
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
223
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
224 base_text_renderer *rep;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
225 };
22326
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
226 }
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
227
21209
67d2965af0b5 revamp text rendering classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 #endif