| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, Inc. |
| 3 * Copyright © 2011 Google, Inc. | 3 * Copyright © 2011 Google, Inc. |
| 4 * | 4 * |
| 5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
| 6 * | 6 * |
| 7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
| 8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
| 9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
| 10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "hb-face-private.hh" | 35 #include "hb-face-private.hh" |
| 36 #include "hb-shaper-private.hh" | 36 #include "hb-shaper-private.hh" |
| 37 | 37 |
| 38 | 38 |
| 39 | 39 |
| 40 /* | 40 /* |
| 41 * hb_font_funcs_t | 41 * hb_font_funcs_t |
| 42 */ | 42 */ |
| 43 | 43 |
| 44 #define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ | 44 #define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ |
| 45 HB_FONT_FUNC_IMPLEMENT (font_h_extents) \ |
| 46 HB_FONT_FUNC_IMPLEMENT (font_v_extents) \ |
| 45 HB_FONT_FUNC_IMPLEMENT (glyph) \ | 47 HB_FONT_FUNC_IMPLEMENT (glyph) \ |
| 46 HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ | 48 HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ |
| 47 HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ | 49 HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ |
| 48 HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ | 50 HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ |
| 49 HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ | 51 HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ |
| 50 HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ | 52 HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ |
| 51 HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \ | 53 HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \ |
| 52 HB_FONT_FUNC_IMPLEMENT (glyph_extents) \ | 54 HB_FONT_FUNC_IMPLEMENT (glyph_extents) \ |
| 53 HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ | 55 HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ |
| 54 HB_FONT_FUNC_IMPLEMENT (glyph_name) \ | 56 HB_FONT_FUNC_IMPLEMENT (glyph_name) \ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 73 #undef HB_FONT_FUNC_IMPLEMENT | 75 #undef HB_FONT_FUNC_IMPLEMENT |
| 74 } destroy; | 76 } destroy; |
| 75 | 77 |
| 76 /* Don't access these directly. Call font->get_*() instead. */ | 78 /* Don't access these directly. Call font->get_*() instead. */ |
| 77 union get_t { | 79 union get_t { |
| 78 struct get_funcs_t { | 80 struct get_funcs_t { |
| 79 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name; | 81 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name; |
| 80 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 82 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 81 #undef HB_FONT_FUNC_IMPLEMENT | 83 #undef HB_FONT_FUNC_IMPLEMENT |
| 82 } f; | 84 } f; |
| 83 void (*array[]) (void); | 85 void (*array[VAR]) (void); |
| 84 } get; | 86 } get; |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 | 89 |
| 88 | 90 |
| 89 /* | 91 /* |
| 90 * hb_font_t | 92 * hb_font_t |
| 91 */ | 93 */ |
| 92 | 94 |
| 93 struct hb_font_t { | 95 struct hb_font_t { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool \ | 155 bool \ |
| 154 has_##name##_func (void) \ | 156 has_##name##_func (void) \ |
| 155 { \ | 157 { \ |
| 156 hb_font_funcs_t *funcs = this->klass; \ | 158 hb_font_funcs_t *funcs = this->klass; \ |
| 157 unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / size
of (funcs->get.array[0]); \ | 159 unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / size
of (funcs->get.array[0]); \ |
| 158 return has_func (i); \ | 160 return has_func (i); \ |
| 159 } | 161 } |
| 160 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 162 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 161 #undef HB_FONT_FUNC_IMPLEMENT | 163 #undef HB_FONT_FUNC_IMPLEMENT |
| 162 | 164 |
| 163 inline hb_bool_t has_glyph (hb_codepoint_t unicode) | 165 inline hb_bool_t get_font_h_extents (hb_font_extents_t *extents) |
| 166 { |
| 167 memset (extents, 0, sizeof (*extents)); |
| 168 return klass->get.f.font_h_extents (this, user_data, |
| 169 » » » » » extents, |
| 170 » » » » » klass->user_data.font_h_extents); |
| 171 } |
| 172 inline hb_bool_t get_font_v_extents (hb_font_extents_t *extents) |
| 173 { |
| 174 memset (extents, 0, sizeof (*extents)); |
| 175 return klass->get.f.font_v_extents (this, user_data, |
| 176 » » » » » extents, |
| 177 » » » » » klass->user_data.font_v_extents); |
| 178 } |
| 179 |
| 180 inline bool has_glyph (hb_codepoint_t unicode) |
| 164 { | 181 { |
| 165 hb_codepoint_t glyph; | 182 hb_codepoint_t glyph; |
| 166 return get_glyph (unicode, 0, &glyph); | 183 return get_glyph (unicode, 0, &glyph); |
| 167 } | 184 } |
| 168 | 185 |
| 169 inline hb_bool_t get_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_s
elector, | 186 inline hb_bool_t get_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_s
elector, |
| 170 hb_codepoint_t *glyph) | 187 hb_codepoint_t *glyph) |
| 171 { | 188 { |
| 172 *glyph = 0; | 189 *glyph = 0; |
| 173 return klass->get.f.glyph (this, user_data, | 190 return klass->get.f.glyph (this, user_data, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 if (len == -1) len = strlen (name); | 275 if (len == -1) len = strlen (name); |
| 259 return klass->get.f.glyph_from_name (this, user_data, | 276 return klass->get.f.glyph_from_name (this, user_data, |
| 260 name, len, | 277 name, len, |
| 261 glyph, | 278 glyph, |
| 262 klass->user_data.glyph_from_name); | 279 klass->user_data.glyph_from_name); |
| 263 } | 280 } |
| 264 | 281 |
| 265 | 282 |
| 266 /* A bit higher-level, and with fallback */ | 283 /* A bit higher-level, and with fallback */ |
| 267 | 284 |
| 285 inline void get_extents_for_direction (hb_direction_t direction, |
| 286 hb_font_extents_t *extents) |
| 287 { |
| 288 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { |
| 289 if (!get_font_h_extents (extents)) |
| 290 { |
| 291 extents->ascender = y_scale * .8; |
| 292 extents->descender = y_scale - extents->ascender; |
| 293 extents->line_gap = 0; |
| 294 } |
| 295 } else { |
| 296 if (!get_font_v_extents (extents)) |
| 297 { |
| 298 extents->ascender = x_scale / 2; |
| 299 extents->descender = x_scale - extents->ascender; |
| 300 extents->line_gap = 0; |
| 301 } |
| 302 } |
| 303 } |
| 304 |
| 268 inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, | 305 inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, |
| 269 hb_direction_t direction, | 306 hb_direction_t direction, |
| 270 hb_position_t *x, hb_position_t *
y) | 307 hb_position_t *x, hb_position_t *
y) |
| 271 { | 308 { |
| 272 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { | 309 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { |
| 273 *x = get_glyph_h_advance (glyph); | 310 *x = get_glyph_h_advance (glyph); |
| 274 *y = 0; | 311 *y = 0; |
| 275 } else { | 312 } else { |
| 276 *x = 0; | 313 *x = 0; |
| 277 *y = get_glyph_v_advance (glyph); | 314 *y = get_glyph_v_advance (glyph); |
| 278 } | 315 } |
| 279 } | 316 } |
| 280 | 317 |
| 281 /* Internal only */ | 318 /* Internal only */ |
| 282 inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, | 319 inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, |
| 283 hb_position_t *x, hb_position_t *y) | 320 hb_position_t *x, hb_position_t *y) |
| 284 { | 321 { |
| 285 *x = get_glyph_h_advance (glyph) / 2; | 322 *x = get_glyph_h_advance (glyph) / 2; |
| 286 | 323 |
| 287 /* TODO use font_metrics.ascent */ | 324 /* TODO use font_extents.ascender */ |
| 288 *y = y_scale; | 325 *y = y_scale; |
| 289 } | 326 } |
| 290 | 327 |
| 291 inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, | 328 inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, |
| 292 hb_direction_t direction, | 329 hb_direction_t direction, |
| 293 hb_position_t *x, hb_position_t *y
) | 330 hb_position_t *x, hb_position_t *y
) |
| 294 { | 331 { |
| 295 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) | 332 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) |
| 296 { | 333 { |
| 297 if (!get_glyph_h_origin (glyph, x, y) && | 334 if (!get_glyph_h_origin (glyph, x, y) && |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 }; | 499 }; |
| 463 | 500 |
| 464 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS | 501 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS |
| 465 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); | 502 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); |
| 466 #include "hb-shaper-list.hh" | 503 #include "hb-shaper-list.hh" |
| 467 #undef HB_SHAPER_IMPLEMENT | 504 #undef HB_SHAPER_IMPLEMENT |
| 468 #undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS | 505 #undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS |
| 469 | 506 |
| 470 | 507 |
| 471 #endif /* HB_FONT_PRIVATE_HH */ | 508 #endif /* HB_FONT_PRIVATE_HH */ |
| OLD | NEW |