LEFT | RIGHT |
(no file at all) | |
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 |
11 LilyPond is distributed in the hope that it will be useful, | 11 LilyPond is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
20 #include "open-type-font.hh" | 20 #include "open-type-font.hh" |
21 | 21 |
22 #include <cstdio> | 22 #include <cstdio> |
23 | 23 |
24 using namespace std; | 24 using namespace std; |
25 | 25 |
26 #include <freetype/tttables.h> | 26 #include <freetype/tttables.h> |
27 | 27 |
28 #include "dimensions.hh" | 28 #include "dimensions.hh" |
| 29 #include "freetype.hh" |
29 #include "international.hh" | 30 #include "international.hh" |
30 #include "modified-font-metric.hh" | 31 #include "modified-font-metric.hh" |
31 #include "warn.hh" | 32 #include "warn.hh" |
32 | 33 |
33 FT_Byte * | 34 FT_Byte * |
34 load_table (char const *tag_str, FT_Face face, FT_ULong *length) | 35 load_table (char const *tag_str, FT_Face face, FT_ULong *length) |
35 { | 36 { |
36 *length = 0; | 37 *length = 0; |
37 FT_ULong tag = FT_MAKE_TAG (tag_str[0], tag_str[1], tag_str[2], tag_str[3]); | 38 FT_ULong tag = FT_MAKE_TAG (tag_str[0], tag_str[1], tag_str[2], tag_str[3]); |
38 | 39 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 207 |
207 b.scale (point_constant); | 208 b.scale (point_constant); |
208 | 209 |
209 scm_hashq_set_x (lily_index_to_bbox_table_, | 210 scm_hashq_set_x (lily_index_to_bbox_table_, |
210 scm_from_unsigned_integer (signed_idx), | 211 scm_from_unsigned_integer (signed_idx), |
211 b.smobbed_copy ()); | 212 b.smobbed_copy ()); |
212 return b; | 213 return b; |
213 } | 214 } |
214 } | 215 } |
215 | 216 |
216 FT_UInt idx = FT_UInt (signed_idx); | 217 Box b = get_unscaled_indexed_char_dimensions (signed_idx); |
217 FT_Load_Glyph (face_, idx, FT_LOAD_NO_SCALE); | |
218 | |
219 FT_Glyph_Metrics m = face_->glyph->metrics; | |
220 FT_Pos hb = m.horiBearingX; | |
221 FT_Pos vb = m.horiBearingY; | |
222 Box b (Interval (Real (-hb), Real (m.width - hb)), | |
223 Interval (Real (-vb), Real (m.height - vb))); | |
224 | 218 |
225 b.scale (design_size () / Real (face_->units_per_EM)); | 219 b.scale (design_size () / Real (face_->units_per_EM)); |
226 return b; | 220 return b; |
227 } | 221 } |
228 | 222 |
229 size_t | 223 size_t |
230 Open_type_font::name_to_index (string nm) const | 224 Open_type_font::name_to_index (string nm) const |
231 { | 225 { |
232 char *nm_str = (char *) nm.c_str (); | 226 char *nm_str = (char *) nm.c_str (); |
233 if (FT_UInt idx = FT_Get_Name_Index (face_, nm_str)) | 227 if (FT_UInt idx = FT_Get_Name_Index (face_, nm_str)) |
234 return (size_t) idx; | 228 return (size_t) idx; |
235 | 229 |
236 return (size_t) - 1; | 230 return (size_t) - 1; |
| 231 } |
| 232 |
| 233 Box |
| 234 Open_type_font::get_unscaled_indexed_char_dimensions (size_t signed_idx) const |
| 235 { |
| 236 return ly_FT_get_unscaled_indexed_char_dimensions (face_, signed_idx); |
| 237 } |
| 238 |
| 239 Box |
| 240 Open_type_font::get_glyph_outline_bbox (size_t signed_idx) const |
| 241 { |
| 242 return ly_FT_get_glyph_outline_bbox (face_, signed_idx); |
| 243 } |
| 244 |
| 245 SCM |
| 246 Open_type_font::get_glyph_outline (size_t signed_idx) const |
| 247 { |
| 248 return ly_FT_get_glyph_outline (face_, signed_idx); |
237 } | 249 } |
238 | 250 |
239 size_t | 251 size_t |
240 Open_type_font::index_to_charcode (size_t i) const | 252 Open_type_font::index_to_charcode (size_t i) const |
241 { | 253 { |
242 map<FT_UInt, FT_ULong>::const_iterator iter; | 254 map<FT_UInt, FT_ULong>::const_iterator iter; |
243 iter = index_to_charcode_map_.find (FT_UInt (i)); | 255 iter = index_to_charcode_map_.find (FT_UInt (i)); |
244 | 256 |
245 if (iter != index_to_charcode_map_.end ()) | 257 if (iter != index_to_charcode_map_.end ()) |
246 return (size_t) iter->second; | 258 return (size_t) iter->second; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if (code) | 329 if (code) |
318 warning (_f ("FT_Get_Glyph_Name () error: %s", | 330 warning (_f ("FT_Get_Glyph_Name () error: %s", |
319 freetype_error_string (code).c_str ())); | 331 freetype_error_string (code).c_str ())); |
320 | 332 |
321 *tail = scm_cons (scm_from_locale_string (name), SCM_EOL); | 333 *tail = scm_cons (scm_from_locale_string (name), SCM_EOL); |
322 tail = SCM_CDRLOC (*tail); | 334 tail = SCM_CDRLOC (*tail); |
323 } | 335 } |
324 | 336 |
325 return retval; | 337 return retval; |
326 } | 338 } |
LEFT | RIGHT |