LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 Pango_font::register_font_file (string filename, | 84 Pango_font::register_font_file (string filename, |
85 string ps_name, | 85 string ps_name, |
86 int face_index) | 86 int face_index) |
87 { | 87 { |
88 scm_hash_set_x (physical_font_tab_, | 88 scm_hash_set_x (physical_font_tab_, |
89 ly_string2scm (ps_name), | 89 ly_string2scm (ps_name), |
90 scm_list_2 (ly_string2scm (filename), | 90 scm_list_2 (ly_string2scm (filename), |
91 scm_from_int (face_index))); | 91 scm_from_int (face_index))); |
92 } | 92 } |
93 | 93 |
| 94 size_t |
| 95 Pango_font::name_to_index (string nm) const |
| 96 { |
| 97 PangoFcFont *fcfont = PANGO_FC_FONT (pango_context_load_font (context_, pango_
description_)); |
| 98 FT_Face face = pango_fc_font_lock_face (fcfont); |
| 99 char *nm_str = (char *) nm.c_str (); |
| 100 if (FT_UInt idx = FT_Get_Name_Index (face, nm_str)) |
| 101 { |
| 102 pango_fc_font_unlock_face (fcfont); |
| 103 return (size_t) idx; |
| 104 } |
| 105 |
| 106 pango_fc_font_unlock_face (fcfont); |
| 107 return (size_t) - 1; |
| 108 } |
| 109 |
94 void | 110 void |
95 Pango_font::derived_mark () const | 111 Pango_font::derived_mark () const |
96 { | 112 { |
97 scm_gc_mark (physical_font_tab_); | 113 scm_gc_mark (physical_font_tab_); |
98 } | 114 } |
99 | 115 |
100 void | 116 void |
101 get_glyph_index_name (char *s, | 117 get_glyph_index_name (char *s, |
102 FT_ULong code) | 118 FT_ULong code) |
103 { | 119 { |
104 sprintf (s, "glyphIndex%lX", code); | 120 sprintf (s, "glyphIndex%lX", code); |
105 } | 121 } |
106 | 122 |
107 void | 123 void |
108 get_unicode_name (char *s, | 124 get_unicode_name (char *s, |
109 FT_ULong code) | 125 FT_ULong code) |
110 { | 126 { |
111 if (code > 0xFFFF) | 127 if (code > 0xFFFF) |
112 sprintf (s, "u%lX", code); | 128 sprintf (s, "u%lX", code); |
113 else | 129 else |
114 sprintf (s, "uni%04lX", code); | 130 sprintf (s, "uni%04lX", code); |
115 } | 131 } |
116 | 132 |
| 133 Box |
| 134 Pango_font::get_unscaled_indexed_char_dimensions (size_t signed_idx) const |
| 135 { |
| 136 PangoFcFont *fcfont = PANGO_FC_FONT (pango_context_load_font (context_, pango_
description_)); |
| 137 FT_Face face = pango_fc_font_lock_face (fcfont); |
| 138 Box b = ly_FT_get_unscaled_indexed_char_dimensions (face, signed_idx); |
| 139 pango_fc_font_unlock_face (fcfont); |
| 140 return b; |
| 141 } |
| 142 |
| 143 Box |
| 144 Pango_font::get_scaled_indexed_char_dimensions (size_t signed_idx) const |
| 145 { |
| 146 PangoFont *font = pango_context_load_font (context_, pango_description_); |
| 147 PangoRectangle logical_rect; |
| 148 PangoRectangle ink_rect; |
| 149 pango_font_get_glyph_extents (font, signed_idx, &ink_rect, &logical_rect); |
| 150 Box out (Interval (PANGO_LBEARING (ink_rect), |
| 151 PANGO_RBEARING (ink_rect)), |
| 152 Interval (-PANGO_DESCENT (ink_rect), |
| 153 PANGO_ASCENT (ink_rect))); |
| 154 out.scale (scale_); |
| 155 return out; |
| 156 } |
| 157 |
| 158 Box |
| 159 Pango_font::get_glyph_outline_bbox (size_t signed_idx) const |
| 160 { |
| 161 PangoFcFont *fcfont = PANGO_FC_FONT (pango_context_load_font (context_, pango_
description_)); |
| 162 FT_Face face = pango_fc_font_lock_face (fcfont); |
| 163 Box b = ly_FT_get_glyph_outline_bbox (face, signed_idx); |
| 164 pango_fc_font_unlock_face (fcfont); |
| 165 return b; |
| 166 } |
| 167 |
| 168 SCM |
| 169 Pango_font::get_glyph_outline (size_t signed_idx) const |
| 170 { |
| 171 PangoFcFont *fcfont = PANGO_FC_FONT (pango_context_load_font (context_, pango_
description_)); |
| 172 FT_Face face = pango_fc_font_lock_face (fcfont); |
| 173 SCM s = ly_FT_get_glyph_outline (face, signed_idx); |
| 174 pango_fc_font_unlock_face (fcfont); |
| 175 return s; |
| 176 } |
| 177 |
117 Stencil | 178 Stencil |
118 Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const | 179 Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const |
119 { | 180 { |
120 const int GLYPH_NAME_LEN = 256; | 181 const int GLYPH_NAME_LEN = 256; |
121 char glyph_name[GLYPH_NAME_LEN]; | 182 char glyph_name[GLYPH_NAME_LEN]; |
122 | 183 |
123 PangoAnalysis const *pa = &(glyph_item->item->analysis); | 184 PangoAnalysis const *pa = &(glyph_item->item->analysis); |
124 PangoGlyphString *pgs = glyph_item->glyphs; | 185 PangoGlyphString *pgs = glyph_item->glyphs; |
125 | 186 |
126 PangoRectangle logical_rect; | 187 PangoRectangle logical_rect; |
127 PangoRectangle ink_rect; | 188 PangoRectangle ink_rect; |
128 pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect); | 189 pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect); |
129 | 190 |
130 PangoFcFont *fcfont = PANGO_FC_FONT (pa->font); | 191 PangoFcFont *fcfont = PANGO_FC_FONT (pa->font); |
131 | |
132 FT_Face ftface = pango_fc_font_lock_face (fcfont); | 192 FT_Face ftface = pango_fc_font_lock_face (fcfont); |
133 | 193 |
134 Box b (Interval (PANGO_LBEARING (logical_rect), | 194 Box b (Interval (PANGO_LBEARING (logical_rect), |
135 PANGO_RBEARING (logical_rect)), | 195 PANGO_RBEARING (logical_rect)), |
136 Interval (-PANGO_DESCENT (ink_rect), | 196 Interval (-PANGO_DESCENT (ink_rect), |
137 PANGO_ASCENT (ink_rect))); | 197 PANGO_ASCENT (ink_rect))); |
138 | 198 |
139 b.scale (scale_); | 199 b.scale (scale_); |
140 | 200 |
141 char const *ps_name_str0 = FT_Get_Postscript_Name (ftface); | 201 char const *ps_name_str0 = FT_Get_Postscript_Name (ftface); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 ps_name = initial + name; | 343 ps_name = initial + name; |
284 } | 344 } |
285 else if (ps_name_str0) | 345 else if (ps_name_str0) |
286 ps_name = ps_name_str0; | 346 ps_name = ps_name_str0; |
287 | 347 |
288 if (ps_name.length ()) | 348 if (ps_name.length ()) |
289 { | 349 { |
290 ((Pango_font *) this)->register_font_file (file_name, | 350 ((Pango_font *) this)->register_font_file (file_name, |
291 ps_name, | 351 ps_name, |
292 face_index); | 352 face_index); |
293 pango_fc_font_unlock_face (fcfont); | 353 |
294 | 354 SCM expr = scm_list_n (ly_symbol2scm ("glyph-string"), |
295 SCM expr = scm_list_5 (ly_symbol2scm ("glyph-string"), | 355 self_scm (), |
296 ly_string2scm (ps_name), | 356 ly_string2scm (ps_name), |
297 scm_from_double (size), | 357 scm_from_double (size), |
298 scm_from_bool (cid_keyed), | 358 scm_from_bool (cid_keyed), |
299 ly_quote_scm (glyph_exprs)); | 359 ly_quote_scm (glyph_exprs), |
| 360 SCM_UNDEFINED); |
300 | 361 |
301 return Stencil (b, expr); | 362 return Stencil (b, expr); |
302 } | 363 } |
303 | 364 |
304 warning (_ ("FreeType face has no PostScript font name")); | 365 warning (_ ("FreeType face has no PostScript font name")); |
305 return Stencil (); | 366 return Stencil (); |
306 } | 367 } |
307 | 368 |
308 SCM | 369 SCM |
309 Pango_font::physical_font_tab () const | 370 Pango_font::physical_font_tab () const |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 return s; | 469 return s; |
409 } | 470 } |
410 | 471 |
411 SCM | 472 SCM |
412 Pango_font::font_file_name () const | 473 Pango_font::font_file_name () const |
413 { | 474 { |
414 return SCM_BOOL_F; | 475 return SCM_BOOL_F; |
415 } | 476 } |
416 | 477 |
417 #endif // HAVE_PANGO_FT2 | 478 #endif // HAVE_PANGO_FT2 |
LEFT | RIGHT |