Mercurial > octave-nkf
annotate libinterp/corefcn/txt-eng-ft.h @ 20654:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1 /* |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2 |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18770
diff
changeset
|
3 Copyright (C) 2009-2015 Michael Goffioul |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
4 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
6 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
10 option) any later version. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
11 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
15 for more details. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
16 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
20 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
21 */ |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
22 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
23 #if ! defined (txt_eng_ft_h) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
24 #define txt_eng_ft_h 1 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
25 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
26 #if HAVE_FREETYPE |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
27 |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
28 #include <list> |
12969
6fc2c61660f2
Native multi-line text alignment.
Vanya Sergeev <vsergeev@gmail.com>
parents:
12334
diff
changeset
|
29 #include <vector> |
6fc2c61660f2
Native multi-line text alignment.
Vanya Sergeev <vsergeev@gmail.com>
parents:
12334
diff
changeset
|
30 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
31 #include <ft2build.h> |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
32 #include FT_FREETYPE_H |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
33 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
34 #include <dMatrix.h> |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
35 #include <uint8NDArray.h> |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
36 #include "txt-eng.h" |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
37 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
38 class |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
39 OCTINTERP_API |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
40 ft_render : public text_processor |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
41 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
42 public: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 enum |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
45 MODE_BBOX = 0, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
46 MODE_RENDER = 1 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
47 }; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
48 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
49 enum |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
51 ROTATION_0 = 0, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
52 ROTATION_90 = 1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
53 ROTATION_180 = 2, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
54 ROTATION_270 = 3 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
55 }; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
56 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
57 public: |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
58 ft_render (void); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
59 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
60 ~ft_render (void); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
61 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
62 void visit (text_element_string& e); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
63 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
64 void visit (text_element_list& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
65 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
66 void visit (text_element_subscript& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
67 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
68 void visit (text_element_superscript& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
69 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
70 void visit (text_element_color& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
71 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
72 void visit (text_element_fontsize& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
73 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
74 void visit (text_element_fontname& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
75 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
76 void visit (text_element_fontstyle& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
77 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
78 void visit (text_element_symbol& e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
79 |
17274
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
80 void visit (text_element_combined& e); |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
81 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
82 void reset (void); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
83 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
84 uint8NDArray get_pixels (void) const { return pixels; } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
85 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
86 Matrix get_boundingbox (void) const { return bbox; } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
87 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
88 uint8NDArray render (text_element* elt, Matrix& box, |
10313 | 89 int rotation = ROTATION_0); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
90 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10313
diff
changeset
|
91 Matrix get_extent (text_element *elt, double rotation = 0.0); |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
92 Matrix get_extent (const std::string& txt, double rotation = 0.0, |
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
93 const caseless_str& interpreter = "tex"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10313
diff
changeset
|
94 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10402
diff
changeset
|
95 void set_font (const std::string& name, const std::string& weight, |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10402
diff
changeset
|
96 const std::string& angle, double size); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
97 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
98 void set_color (Matrix c); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
99 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
100 void set_mode (int m); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
101 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10402
diff
changeset
|
102 void text_to_pixels (const std::string& txt, |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10402
diff
changeset
|
103 uint8NDArray& pixels_, Matrix& bbox, |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
104 int halign, int valign, double rotation, |
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
105 const caseless_str& interpreter = "tex"); |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10402
diff
changeset
|
106 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
107 private: |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10313
diff
changeset
|
108 int rotation_to_mode (double rotation) const; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10313
diff
changeset
|
109 |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
110 // No copying! |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
111 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
112 ft_render (const ft_render&); |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
113 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
114 ft_render& operator = (const ft_render&); |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
115 |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
116 // Class to hold information about fonts and a strong |
18770
333901476119
maint: Use "FreeType" rather than "freetype" in messages and comments.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
117 // reference to the font objects loaded by FreeType. |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
118 class ft_font |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 public: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 ft_font (void) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
122 : name (), weight (), angle (), size (0), face (0) { } |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
123 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 ft_font (const std::string& nm, const std::string& wt, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 const std::string& ang, double sz, FT_Face f = 0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 : name (nm), weight (wt), angle (ang), size (sz), face (f) { } |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
127 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
128 ft_font (const ft_font& ft); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
129 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
130 ~ft_font (void) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 if (face) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 FT_Done_Face (face); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 } |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
135 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 ft_font& operator = (const ft_font& ft); |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17274
diff
changeset
|
137 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 bool is_valid (void) const { return get_face (); } |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17274
diff
changeset
|
139 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 std::string get_name (void) const { return name; } |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17274
diff
changeset
|
141 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
142 std::string get_weight (void) const { return weight; } |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17274
diff
changeset
|
143 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 std::string get_angle (void) const { return angle; } |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
145 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
146 double get_size (void) const { return size; } |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17274
diff
changeset
|
147 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 FT_Face get_face (void) const; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
149 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
150 private: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 std::string name; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
152 std::string weight; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
153 std::string angle; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 double size; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
155 mutable FT_Face face; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 }; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
157 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
158 void push_new_line (void); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
159 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
160 void update_line_bbox (void); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
161 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
162 void compute_bbox (void); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
163 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
164 int compute_line_xoffset (const Matrix& lb) const; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
165 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
166 FT_UInt process_character (FT_ULong code, FT_UInt previous = 0); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
167 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10313
diff
changeset
|
168 private: |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
169 // The current font used by the renderer. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
170 ft_font font; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
171 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
172 // Used to stored the bounding box corresponding to the rendered text. |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
173 // The bounding box has the form [x, y, w, h] where x and y represent the |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
174 // coordinates of the bottom left corner relative to the anchor point of |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
175 // the text (== start of text on the baseline). Due to font descent or |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
176 // multiple lines, the value y is usually negative. |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
177 Matrix bbox; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
178 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
179 // Used to stored the rendered text. It's a 3D matrix with size MxNx4 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
180 // where M and N are the width and height of the bounding box. |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
181 uint8NDArray pixels; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
182 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
183 // Used to store the bounding box of each line. This is used to layout |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
184 // multiline text properly. |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
185 std::list<Matrix> line_bbox; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
186 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
187 // The current horizontal alignment. This is used to align multi-line text. |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
188 int halign; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
189 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
190 // The X offset for the next glyph. |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
191 int xoffset; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
192 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
193 // The Y offset of the baseline for the current line. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
194 int line_yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
195 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
196 // The Y offset of the baseline for the next glyph. The offset is relative |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
197 // to line_yoffset. The total Y offset is computed with: |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
198 // line_yoffset + yoffset. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
199 int yoffset; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
200 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
201 // The current mode of the rendering process (box computing or rendering). |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
202 int mode; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
203 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
204 // The base color of the rendered text. |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
205 uint8NDArray color; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
206 }; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
207 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
208 #endif // HAVE_FREETYPE |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
209 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
210 #endif |