Mercurial > octave-nkf
comparison libinterp/corefcn/oct-tex-parser.yy @ 17272:8ce6cdd272eb
Support TeX elements in FreeType renderer.
* libinterp/corefcn/txt-eng.cc: New file. Contains mapping from symbol
name to character code, in Unicode and MS symbol.
* libinterp/corefcn/modules.mk (COREFCN_SRC): Add txt-eng.cc.
* libinterp/corefcn/oct-tex-lexer.ll: Add "\n" to rules applicable to
".", as
the latter does not include new line characters.
* libinterp/corefcn/oct-tex-parser.yy: Remove debug statements.
* libinterp/corefcn/txt-eng.ft.cc (gripe_missing_glyph,
gripe_glyph_render): Change signature from char to FT_ULong.
(ft_render::ft_render): Adapt to new/removed members.
(ft_render::~ft_render): Remove use of fonts member.
(ft_render::set_font): Likewise. Use font instead.
(ft_render::push_new_line): Likewise. Change meaning of yoffset and
initialize line_yoffset.
(ft_render::update_line_bbox): New method.
(ft_render::set_mode): Change meaning of yoffset and initialize
line_yoffset.
(ft_render::process_character): New method.
(ft_render::visit(text_element_string)): Use it.
(ft_render::visit(text_element_list),
ft_render::visit(text_element_subscript),
ft_render::visit(text_element_superscript),
ft_render::visit(text_element_color),
ft_render::visit(text_element_fontsize),
ft_render::visit(text_element_fontname),
ft_render::visit(text_element_fontstyle),
ft_render::visit(text_element_symbol)): New methods.
(ft_render::set_color): Use color member instead of red/green/blue.
* libinterp/corefcn/txt-eng-ft.h (ft_render::visit(text_element_list),
ft_render::visit(text_element_subscript),
ft_render::visit(text_element_superscript),
ft_render::visit(text_element_color),
ft_render::visit(text_element_fontsize),
ft_render::visit(text_element_fontname),
ft_render::visit(text_element_fontstyle),
ft_render::visit(text_element_symbol)): New methods.
(ft_render::update_line_bbox, ft_render::process_character): New
methods.
(ft_render::current_face): Removed method.i
(ft_render::font): New member, replaces obsolete ft_render::fonts.
(ft_render::line_yoffset): New member.
(ft_render::color): New member, replaces obsolete red, green and blue.
(ft_render::ft_font::ft_font()): Implement default constructor.
(ft_render::ft_font::operator=): Fix incorrect use of FT_Reference_Face
return value.
(ft_render::ft_font::is_valid): New method.
* libinterp/corefcn/txt-eng.h (class text_element_symbol, class
text_element_fontname, class text_element_fontsize, class
text_element_fontname, class text_element_fontstyle, class
text_element_color): Add forward definition.
(text_element_symbol::invalid_code): New enum.
(text_element_symbol::code): New member.
(text_element_symbol::text_element_symbol): Initialize it.
(text_element_symbol::get_symbol_code): New method.
(text_element_fontstyle::get_fontstyle): New method.
(text_element_fontname::get_fontname): Renamed from fontname.
(text_element_fontsize::get_fontsize): Renamed from fontsize.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 18 Aug 2013 16:36:46 -0400 |
parents | 5b088598df1d |
children | 0a09d4b40767 |
comparison
equal
deleted
inserted
replaced
17271:cb7233cfbf43 | 17272:8ce6cdd272eb |
---|---|
92 { $1->append (1, $2); $$ = $1; } | 92 { $1->append (1, $2); $$ = $1; } |
93 ; | 93 ; |
94 | 94 |
95 symbol_element : CMD identifier | 95 symbol_element : CMD identifier |
96 { | 96 { |
97 printf ("symbol: %s\n", $2->c_str ()); | |
98 $$ = new text_element_symbol (*$2); | 97 $$ = new text_element_symbol (*$2); |
99 delete $2; | 98 delete $2; |
100 } | 99 } |
101 ; | 100 ; |
102 | 101 |
114 { $$ = new text_element_fontsize ($3); } | 113 { $$ = new text_element_fontsize ($3); } |
115 ; | 114 ; |
116 | 115 |
117 fontname_element : FONTNAME START simple_string END | 116 fontname_element : FONTNAME START simple_string END |
118 { | 117 { |
119 printf ("fontname: %s\n", $3->c_str ()); | |
120 $$ = new text_element_fontname (*$3); | 118 $$ = new text_element_fontname (*$3); |
121 delete $3; | 119 delete $3; |
122 } | 120 } |
123 ; | 121 ; |
124 | 122 |
125 color_element : COLOR START simple_string END | 123 color_element : COLOR START simple_string END |
126 { | 124 { |
127 printf ("color: %s\n", $3->c_str ()); | |
128 $$ = new text_element_color (*$3); | 125 $$ = new text_element_color (*$3); |
129 delete $3; | 126 delete $3; |
130 } | 127 } |
131 | COLOR_RGB START NUM NUM NUM END | 128 | COLOR_RGB START NUM NUM NUM END |
132 { | 129 { |
133 printf ("color: %g %g %g\n", $3, $4, $5); | |
134 $$ = new text_element_color ($3, $4, $5); | 130 $$ = new text_element_color ($3, $4, $5); |
135 } | 131 } |
136 ; | 132 ; |
137 | 133 |
138 string_element : simple_string %prec STR | 134 string_element : simple_string %prec STR |
139 { | 135 { |
140 printf ("string: \"%s\"\n", $1->c_str ()); | |
141 $$ = new text_element_string (*$1); | 136 $$ = new text_element_string (*$1); |
142 delete $1; | 137 delete $1; |
143 } | 138 } |
144 | scoped_string_element_list | 139 | scoped_string_element_list |
145 /* This is just to avoid a warning in bison. */ | 140 /* This is just to avoid a warning in bison. */ |
200 } | 195 } |
201 | 196 |
202 static void | 197 static void |
203 yyerror (text_parser_tex&, const char *s) | 198 yyerror (text_parser_tex&, const char *s) |
204 { | 199 { |
205 fprintf (stderr, "parse error: %s\n", s); | 200 fprintf (stderr, "TeX parse error: %s\n", s); |
206 } | 201 } |