| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, Inc. |
| 3 * Copyright © 2012 Google, Inc. | 3 * Copyright © 2012 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 27 matching lines...) Expand all Loading... |
| 38 #include "hb-cache-private.hh" | 38 #include "hb-cache-private.hh" |
| 39 | 39 |
| 40 #include <string.h> | 40 #include <string.h> |
| 41 | 41 |
| 42 | 42 |
| 43 /* | 43 /* |
| 44 * hb_font_funcs_t | 44 * hb_font_funcs_t |
| 45 */ | 45 */ |
| 46 | 46 |
| 47 static hb_bool_t | 47 static hb_bool_t |
| 48 hb_font_get_glyph_nil (hb_font_t *font, | 48 hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED, |
| 49 void *font_data HB_UNUSED, | 49 void *font_data HB_UNUSED, |
| 50 hb_codepoint_t unicode, | 50 hb_codepoint_t unicode, |
| 51 hb_codepoint_t variation_selector, | 51 hb_codepoint_t variation_selector, |
| 52 hb_codepoint_t *glyph, | 52 hb_codepoint_t *glyph, |
| 53 void *user_data HB_UNUSED) | 53 void *user_data HB_UNUSED) |
| 54 { | 54 { |
| 55 if (font->parent) | |
| 56 return font->parent->get_glyph (unicode, variation_selector, glyph); | |
| 57 | |
| 58 *glyph = 0; | 55 *glyph = 0; |
| 59 return false; | 56 return false; |
| 60 } | 57 } |
| 58 static hb_bool_t |
| 59 hb_font_get_glyph_parent (hb_font_t *font, |
| 60 void *font_data HB_UNUSED, |
| 61 hb_codepoint_t unicode, |
| 62 hb_codepoint_t variation_selector, |
| 63 hb_codepoint_t *glyph, |
| 64 void *user_data HB_UNUSED) |
| 65 { |
| 66 return font->parent->get_glyph (unicode, variation_selector, glyph); |
| 67 } |
| 61 | 68 |
| 62 static hb_position_t | 69 static hb_position_t |
| 63 hb_font_get_glyph_h_advance_nil (hb_font_t *font, | 70 hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, |
| 64 void *font_data HB_UNUSED, | 71 void *font_data HB_UNUSED, |
| 65 hb_codepoint_t glyph, | 72 hb_codepoint_t glyph, |
| 66 void *user_data HB_UNUSED) | 73 void *user_data HB_UNUSED) |
| 67 { | 74 { |
| 68 if (font->parent) | |
| 69 return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (gly
ph)); | |
| 70 | |
| 71 return font->x_scale; | 75 return font->x_scale; |
| 72 } | 76 } |
| 77 static hb_position_t |
| 78 hb_font_get_glyph_h_advance_parent (hb_font_t *font, |
| 79 void *font_data HB_UNUSED, |
| 80 hb_codepoint_t glyph, |
| 81 void *user_data HB_UNUSED) |
| 82 { |
| 83 return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph
)); |
| 84 } |
| 73 | 85 |
| 74 static hb_position_t | 86 static hb_position_t |
| 75 hb_font_get_glyph_v_advance_nil (hb_font_t *font, | 87 hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED, |
| 76 void *font_data HB_UNUSED, | 88 void *font_data HB_UNUSED, |
| 77 hb_codepoint_t glyph, | 89 hb_codepoint_t glyph, |
| 78 void *user_data HB_UNUSED) | 90 void *user_data HB_UNUSED) |
| 79 { | 91 { |
| 80 if (font->parent) | |
| 81 return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (gly
ph)); | |
| 82 | |
| 83 return font->y_scale; | 92 return font->y_scale; |
| 84 } | 93 } |
| 94 static hb_position_t |
| 95 hb_font_get_glyph_v_advance_parent (hb_font_t *font, |
| 96 void *font_data HB_UNUSED, |
| 97 hb_codepoint_t glyph, |
| 98 void *user_data HB_UNUSED) |
| 99 { |
| 100 return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph
)); |
| 101 } |
| 85 | 102 |
| 86 static hb_bool_t | 103 static hb_bool_t |
| 87 hb_font_get_glyph_h_origin_nil (hb_font_t *font, | 104 hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, |
| 88 void *font_data HB_UNUSED, | 105 void *font_data HB_UNUSED, |
| 89 hb_codepoint_t glyph, | 106 hb_codepoint_t glyph, |
| 90 hb_position_t *x, | 107 hb_position_t *x, |
| 91 hb_position_t *y, | 108 hb_position_t *y, |
| 92 void *user_data HB_UNUSED) | 109 void *user_data HB_UNUSED) |
| 93 { | 110 { |
| 94 if (font->parent) { | |
| 95 hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); | |
| 96 if (ret) | |
| 97 font->parent_scale_position (x, y); | |
| 98 return ret; | |
| 99 } | |
| 100 | |
| 101 *x = *y = 0; | 111 *x = *y = 0; |
| 102 return false; | 112 return false; |
| 103 } | 113 } |
| 114 static hb_bool_t |
| 115 hb_font_get_glyph_h_origin_parent (hb_font_t *font, |
| 116 void *font_data HB_UNUSED, |
| 117 hb_codepoint_t glyph, |
| 118 hb_position_t *x, |
| 119 hb_position_t *y, |
| 120 void *user_data HB_UNUSED) |
| 121 { |
| 122 hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); |
| 123 if (ret) |
| 124 font->parent_scale_position (x, y); |
| 125 return ret; |
| 126 } |
| 104 | 127 |
| 105 static hb_bool_t | 128 static hb_bool_t |
| 106 hb_font_get_glyph_v_origin_nil (hb_font_t *font, | 129 hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED, |
| 107 void *font_data HB_UNUSED, | 130 void *font_data HB_UNUSED, |
| 108 hb_codepoint_t glyph, | 131 hb_codepoint_t glyph, |
| 109 hb_position_t *x, | 132 hb_position_t *x, |
| 110 hb_position_t *y, | 133 hb_position_t *y, |
| 111 void *user_data HB_UNUSED) | 134 void *user_data HB_UNUSED) |
| 112 { | 135 { |
| 113 if (font->parent) { | |
| 114 hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); | |
| 115 if (ret) | |
| 116 font->parent_scale_position (x, y); | |
| 117 return ret; | |
| 118 } | |
| 119 | |
| 120 *x = *y = 0; | 136 *x = *y = 0; |
| 121 return false; | 137 return false; |
| 122 } | 138 } |
| 139 static hb_bool_t |
| 140 hb_font_get_glyph_v_origin_parent (hb_font_t *font, |
| 141 void *font_data HB_UNUSED, |
| 142 hb_codepoint_t glyph, |
| 143 hb_position_t *x, |
| 144 hb_position_t *y, |
| 145 void *user_data HB_UNUSED) |
| 146 { |
| 147 hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); |
| 148 if (ret) |
| 149 font->parent_scale_position (x, y); |
| 150 return ret; |
| 151 } |
| 123 | 152 |
| 124 static hb_position_t | 153 static hb_position_t |
| 125 hb_font_get_glyph_h_kerning_nil (hb_font_t *font, | 154 hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED, |
| 126 void *font_data HB_UNUSED, | 155 void *font_data HB_UNUSED, |
| 127 hb_codepoint_t left_glyph, | 156 hb_codepoint_t left_glyph, |
| 128 hb_codepoint_t right_glyph, | 157 hb_codepoint_t right_glyph, |
| 129 void *user_data HB_UNUSED) | 158 void *user_data HB_UNUSED) |
| 130 { | 159 { |
| 131 if (font->parent) | |
| 132 return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (lef
t_glyph, right_glyph)); | |
| 133 | |
| 134 return 0; | 160 return 0; |
| 135 } | 161 } |
| 162 static hb_position_t |
| 163 hb_font_get_glyph_h_kerning_parent (hb_font_t *font, |
| 164 void *font_data HB_UNUSED, |
| 165 hb_codepoint_t left_glyph, |
| 166 hb_codepoint_t right_glyph, |
| 167 void *user_data HB_UNUSED) |
| 168 { |
| 169 return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_
glyph, right_glyph)); |
| 170 } |
| 136 | 171 |
| 137 static hb_position_t | 172 static hb_position_t |
| 138 hb_font_get_glyph_v_kerning_nil (hb_font_t *font, | 173 hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED, |
| 139 void *font_data HB_UNUSED, | 174 void *font_data HB_UNUSED, |
| 140 hb_codepoint_t top_glyph, | 175 hb_codepoint_t top_glyph, |
| 141 hb_codepoint_t bottom_glyph, | 176 hb_codepoint_t bottom_glyph, |
| 142 void *user_data HB_UNUSED) | 177 void *user_data HB_UNUSED) |
| 143 { | 178 { |
| 144 if (font->parent) | |
| 145 return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top
_glyph, bottom_glyph)); | |
| 146 | |
| 147 return 0; | 179 return 0; |
| 148 } | 180 } |
| 181 static hb_position_t |
| 182 hb_font_get_glyph_v_kerning_parent (hb_font_t *font, |
| 183 void *font_data HB_UNUSED, |
| 184 hb_codepoint_t top_glyph, |
| 185 hb_codepoint_t bottom_glyph, |
| 186 void *user_data HB_UNUSED) |
| 187 { |
| 188 return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_g
lyph, bottom_glyph)); |
| 189 } |
| 149 | 190 |
| 150 static hb_bool_t | 191 static hb_bool_t |
| 151 hb_font_get_glyph_extents_nil (hb_font_t *font, | 192 hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED, |
| 152 void *font_data HB_UNUSED, | 193 void *font_data HB_UNUSED, |
| 153 hb_codepoint_t glyph, | 194 hb_codepoint_t glyph, |
| 154 hb_glyph_extents_t *extents, | 195 hb_glyph_extents_t *extents, |
| 155 void *user_data HB_UNUSED) | 196 void *user_data HB_UNUSED) |
| 156 { | 197 { |
| 157 if (font->parent) { | |
| 158 hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); | |
| 159 if (ret) { | |
| 160 font->parent_scale_position (&extents->x_bearing, &extents->y_bearing); | |
| 161 font->parent_scale_distance (&extents->width, &extents->height); | |
| 162 } | |
| 163 return ret; | |
| 164 } | |
| 165 | |
| 166 memset (extents, 0, sizeof (*extents)); | 198 memset (extents, 0, sizeof (*extents)); |
| 167 return false; | 199 return false; |
| 168 } | 200 } |
| 201 static hb_bool_t |
| 202 hb_font_get_glyph_extents_parent (hb_font_t *font, |
| 203 void *font_data HB_UNUSED, |
| 204 hb_codepoint_t glyph, |
| 205 hb_glyph_extents_t *extents, |
| 206 void *user_data HB_UNUSED) |
| 207 { |
| 208 hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); |
| 209 if (ret) { |
| 210 font->parent_scale_position (&extents->x_bearing, &extents->y_bearing); |
| 211 font->parent_scale_distance (&extents->width, &extents->height); |
| 212 } |
| 213 return ret; |
| 214 } |
| 169 | 215 |
| 170 static hb_bool_t | 216 static hb_bool_t |
| 171 hb_font_get_glyph_contour_point_nil (hb_font_t *font, | 217 hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED, |
| 172 void *font_data HB_UNUSED, | 218 void *font_data HB_UNUSED, |
| 173 hb_codepoint_t glyph, | 219 hb_codepoint_t glyph, |
| 174 unsigned int point_index, | 220 unsigned int point_index, |
| 175 hb_position_t *x, | 221 hb_position_t *x, |
| 176 hb_position_t *y, | 222 hb_position_t *y, |
| 177 void *user_data HB_UNUSED) | 223 void *user_data HB_UNUSED) |
| 178 { | 224 { |
| 179 if (font->parent) { | |
| 180 hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x
, y); | |
| 181 if (ret) | |
| 182 font->parent_scale_position (x, y); | |
| 183 return ret; | |
| 184 } | |
| 185 | |
| 186 *x = *y = 0; | 225 *x = *y = 0; |
| 187 return false; | 226 return false; |
| 188 } | 227 } |
| 228 static hb_bool_t |
| 229 hb_font_get_glyph_contour_point_parent (hb_font_t *font, |
| 230 void *font_data HB_UNUSED, |
| 231 hb_codepoint_t glyph, |
| 232 unsigned int point_index, |
| 233 hb_position_t *x, |
| 234 hb_position_t *y, |
| 235 void *user_data HB_UNUSED) |
| 236 { |
| 237 hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x,
y); |
| 238 if (ret) |
| 239 font->parent_scale_position (x, y); |
| 240 return ret; |
| 241 } |
| 189 | 242 |
| 190 static hb_bool_t | 243 static hb_bool_t |
| 191 hb_font_get_glyph_name_nil (hb_font_t *font, | 244 hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED, |
| 192 void *font_data HB_UNUSED, | 245 void *font_data HB_UNUSED, |
| 193 hb_codepoint_t glyph, | 246 hb_codepoint_t glyph, |
| 194 char *name, unsigned int size, | 247 char *name, unsigned int size, |
| 195 void *user_data HB_UNUSED) | 248 void *user_data HB_UNUSED) |
| 196 { | 249 { |
| 197 if (font->parent) | |
| 198 return font->parent->get_glyph_name (glyph, name, size); | |
| 199 | |
| 200 if (size) *name = '\0'; | 250 if (size) *name = '\0'; |
| 201 return false; | 251 return false; |
| 202 } | 252 } |
| 253 static hb_bool_t |
| 254 hb_font_get_glyph_name_parent (hb_font_t *font, |
| 255 void *font_data HB_UNUSED, |
| 256 hb_codepoint_t glyph, |
| 257 char *name, unsigned int size, |
| 258 void *user_data HB_UNUSED) |
| 259 { |
| 260 return font->parent->get_glyph_name (glyph, name, size); |
| 261 } |
| 203 | 262 |
| 204 static hb_bool_t | 263 static hb_bool_t |
| 205 hb_font_get_glyph_from_name_nil (hb_font_t *font, | 264 hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED, |
| 206 void *font_data HB_UNUSED, | 265 void *font_data HB_UNUSED, |
| 207 const char *name, int len, /* -1 means nul-term
inated */ | 266 const char *name, int len, /* -1 means nul-term
inated */ |
| 208 hb_codepoint_t *glyph, | 267 hb_codepoint_t *glyph, |
| 209 void *user_data HB_UNUSED) | 268 void *user_data HB_UNUSED) |
| 210 { | 269 { |
| 211 if (font->parent) | |
| 212 return font->parent->get_glyph_from_name (name, len, glyph); | |
| 213 | |
| 214 *glyph = 0; | 270 *glyph = 0; |
| 215 return false; | 271 return false; |
| 216 } | 272 } |
| 273 static hb_bool_t |
| 274 hb_font_get_glyph_from_name_parent (hb_font_t *font, |
| 275 void *font_data HB_UNUSED, |
| 276 const char *name, int len, /* -1 means nul-t
erminated */ |
| 277 hb_codepoint_t *glyph, |
| 278 void *user_data HB_UNUSED) |
| 279 { |
| 280 return font->parent->get_glyph_from_name (name, len, glyph); |
| 281 } |
| 217 | 282 |
| 218 | 283 |
| 219 static const hb_font_funcs_t _hb_font_funcs_nil = { | 284 static const hb_font_funcs_t _hb_font_funcs_nil = { |
| 220 HB_OBJECT_HEADER_STATIC, | 285 HB_OBJECT_HEADER_STATIC, |
| 221 | 286 |
| 222 true, /* immutable */ | 287 true, /* immutable */ |
| 223 | 288 |
| 224 { | 289 { |
| 225 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, | 290 #define HB_FONT_FUNC_IMPLEMENT(name) NULL, |
| 226 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 291 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 227 #undef HB_FONT_FUNC_IMPLEMENT | 292 #undef HB_FONT_FUNC_IMPLEMENT |
| 293 }, |
| 294 { |
| 295 #define HB_FONT_FUNC_IMPLEMENT(name) NULL, |
| 296 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 297 #undef HB_FONT_FUNC_IMPLEMENT |
| 298 }, |
| 299 { |
| 300 { |
| 301 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, |
| 302 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 303 #undef HB_FONT_FUNC_IMPLEMENT |
| 304 } |
| 305 } |
| 306 }; |
| 307 static const hb_font_funcs_t _hb_font_funcs_parent = { |
| 308 HB_OBJECT_HEADER_STATIC, |
| 309 |
| 310 true, /* immutable */ |
| 311 |
| 312 { |
| 313 #define HB_FONT_FUNC_IMPLEMENT(name) NULL, |
| 314 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 315 #undef HB_FONT_FUNC_IMPLEMENT |
| 316 }, |
| 317 { |
| 318 #define HB_FONT_FUNC_IMPLEMENT(name) NULL, |
| 319 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 320 #undef HB_FONT_FUNC_IMPLEMENT |
| 321 }, |
| 322 { |
| 323 { |
| 324 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent, |
| 325 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 326 #undef HB_FONT_FUNC_IMPLEMENT |
| 327 } |
| 228 } | 328 } |
| 229 }; | 329 }; |
| 230 | 330 |
| 231 | 331 |
| 232 /** | 332 /** |
| 233 * hb_font_funcs_create: (Xconstructor) | 333 * hb_font_funcs_create: (Xconstructor) |
| 234 * | 334 * |
| 235 * | 335 * |
| 236 * | 336 * |
| 237 * Return value: (transfer full): | 337 * Return value: (transfer full): |
| 238 * | 338 * |
| 239 * Since: 0.9.2 | 339 * Since: 0.9.2 |
| 240 **/ | 340 **/ |
| 241 hb_font_funcs_t * | 341 hb_font_funcs_t * |
| 242 hb_font_funcs_create (void) | 342 hb_font_funcs_create (void) |
| 243 { | 343 { |
| 244 hb_font_funcs_t *ffuncs; | 344 hb_font_funcs_t *ffuncs; |
| 245 | 345 |
| 246 if (!(ffuncs = hb_object_create<hb_font_funcs_t> ())) | 346 if (!(ffuncs = hb_object_create<hb_font_funcs_t> ())) |
| 247 return hb_font_funcs_get_empty (); | 347 return hb_font_funcs_get_empty (); |
| 248 | 348 |
| 249 ffuncs->get = _hb_font_funcs_nil.get; | 349 ffuncs->get = _hb_font_funcs_parent.get; |
| 250 | 350 |
| 251 return ffuncs; | 351 return ffuncs; |
| 252 } | 352 } |
| 253 | 353 |
| 254 /** | 354 /** |
| 255 * hb_font_funcs_get_empty: | 355 * hb_font_funcs_get_empty: |
| 256 * | 356 * |
| 257 * | 357 * |
| 258 * | 358 * |
| 259 * Return value: (transfer full): | 359 * Return value: (transfer full): |
| 260 * | 360 * |
| 261 * Since: 0.9.2 | 361 * Since: 0.9.2 |
| 262 **/ | 362 **/ |
| 263 hb_font_funcs_t * | 363 hb_font_funcs_t * |
| 264 hb_font_funcs_get_empty (void) | 364 hb_font_funcs_get_empty (void) |
| 265 { | 365 { |
| 266 return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil); | 366 return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_parent); |
| 267 } | 367 } |
| 268 | 368 |
| 269 /** | 369 /** |
| 270 * hb_font_funcs_reference: (skip) | 370 * hb_font_funcs_reference: (skip) |
| 271 * @ffuncs: font functions. | 371 * @ffuncs: font functions. |
| 272 * | 372 * |
| 273 * | 373 * |
| 274 * | 374 * |
| 275 * Return value: | 375 * Return value: |
| 276 * | 376 * |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (ffuncs->immutable) { \ | 491 if (ffuncs->immutable) { \ |
| 392 if (destroy) \ | 492 if (destroy) \ |
| 393 destroy (user_data); \ | 493 destroy (user_data); \ |
| 394 return; \ | 494 return; \ |
| 395 } \ | 495 } \ |
| 396 \ | 496 \ |
| 397 if (ffuncs->destroy.name) \ | 497 if (ffuncs->destroy.name) \ |
| 398 ffuncs->destroy.name (ffuncs->user_data.name); \ | 498 ffuncs->destroy.name (ffuncs->user_data.name); \ |
| 399 \ | 499 \ |
| 400 if (func) { \ | 500 if (func) { \ |
| 401 ffuncs->get.name = func; \ | 501 ffuncs->get.f.name = func; \ |
| 402 ffuncs->user_data.name = user_data; \ | 502 ffuncs->user_data.name = user_data; \ |
| 403 ffuncs->destroy.name = destroy; \ | 503 ffuncs->destroy.name = destroy; \ |
| 404 } else { \ | 504 } else { \ |
| 405 ffuncs->get.name = hb_font_get_##name##_nil; \ | 505 ffuncs->get.f.name = hb_font_get_##name##_parent; \ |
| 406 ffuncs->user_data.name = NULL; \ | 506 ffuncs->user_data.name = NULL; \ |
| 407 ffuncs->destroy.name = NULL; \ | 507 ffuncs->destroy.name = NULL; \ |
| 408 } \ | 508 } \ |
| 409 } | 509 } |
| 410 | 510 |
| 411 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 511 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 412 #undef HB_FONT_FUNC_IMPLEMENT | 512 #undef HB_FONT_FUNC_IMPLEMENT |
| 413 | 513 |
| 514 bool |
| 515 hb_font_t::has_func (unsigned int i) |
| 516 { |
| 517 if (parent && parent != hb_font_get_empty () && parent->has_func (i)) |
| 518 return true; |
| 519 return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i]; |
| 520 } |
| 414 | 521 |
| 415 /* Public getters */ | 522 /* Public getters */ |
| 416 | 523 |
| 417 /** | 524 /** |
| 418 * hb_font_get_glyph: | 525 * hb_font_get_glyph: |
| 419 * @font: a font. | 526 * @font: a font. |
| 420 * @unicode: | 527 * @unicode: |
| 421 * @variation_selector: | 528 * @variation_selector: |
| 422 * @glyph: (out): | 529 * @glyph: (out): |
| 423 * | 530 * |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 hb_font_create (hb_face_t *face) | 958 hb_font_create (hb_face_t *face) |
| 852 { | 959 { |
| 853 hb_font_t *font; | 960 hb_font_t *font; |
| 854 | 961 |
| 855 if (unlikely (!face)) | 962 if (unlikely (!face)) |
| 856 face = hb_face_get_empty (); | 963 face = hb_face_get_empty (); |
| 857 if (!(font = hb_object_create<hb_font_t> ())) | 964 if (!(font = hb_object_create<hb_font_t> ())) |
| 858 return hb_font_get_empty (); | 965 return hb_font_get_empty (); |
| 859 | 966 |
| 860 hb_face_make_immutable (face); | 967 hb_face_make_immutable (face); |
| 968 font->parent = hb_font_get_empty (); |
| 861 font->face = hb_face_reference (face); | 969 font->face = hb_face_reference (face); |
| 862 font->klass = hb_font_funcs_get_empty (); | 970 font->klass = hb_font_funcs_get_empty (); |
| 863 | 971 |
| 864 font->x_scale = font->y_scale = hb_face_get_upem (face); | 972 font->x_scale = font->y_scale = hb_face_get_upem (face); |
| 865 | 973 |
| 866 return font; | 974 return font; |
| 867 } | 975 } |
| 868 | 976 |
| 869 /** | 977 /** |
| 870 * hb_font_create_sub_font: | 978 * hb_font_create_sub_font: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 hb_font_get_empty (void) | 1018 hb_font_get_empty (void) |
| 911 { | 1019 { |
| 912 static const hb_font_t _hb_font_nil = { | 1020 static const hb_font_t _hb_font_nil = { |
| 913 HB_OBJECT_HEADER_STATIC, | 1021 HB_OBJECT_HEADER_STATIC, |
| 914 | 1022 |
| 915 true, /* immutable */ | 1023 true, /* immutable */ |
| 916 | 1024 |
| 917 NULL, /* parent */ | 1025 NULL, /* parent */ |
| 918 const_cast<hb_face_t *> (&_hb_face_nil), | 1026 const_cast<hb_face_t *> (&_hb_face_nil), |
| 919 | 1027 |
| 920 0, /* x_scale */ | 1028 1000, /* x_scale */ |
| 921 0, /* y_scale */ | 1029 1000, /* y_scale */ |
| 922 | 1030 |
| 923 0, /* x_ppem */ | 1031 0, /* x_ppem */ |
| 924 0, /* y_ppem */ | 1032 0, /* y_ppem */ |
| 925 | 1033 |
| 926 const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */ | 1034 const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */ |
| 927 NULL, /* user_data */ | 1035 NULL, /* user_data */ |
| 928 NULL, /* destroy */ | 1036 NULL, /* destroy */ |
| 929 | 1037 |
| 930 { | 1038 { |
| 931 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, | 1039 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 * Since: 0.9.2 | 1365 * Since: 0.9.2 |
| 1258 **/ | 1366 **/ |
| 1259 void | 1367 void |
| 1260 hb_font_get_ppem (hb_font_t *font, | 1368 hb_font_get_ppem (hb_font_t *font, |
| 1261 unsigned int *x_ppem, | 1369 unsigned int *x_ppem, |
| 1262 unsigned int *y_ppem) | 1370 unsigned int *y_ppem) |
| 1263 { | 1371 { |
| 1264 if (x_ppem) *x_ppem = font->x_ppem; | 1372 if (x_ppem) *x_ppem = font->x_ppem; |
| 1265 if (y_ppem) *y_ppem = font->y_ppem; | 1373 if (y_ppem) *y_ppem = font->y_ppem; |
| 1266 } | 1374 } |
| OLD | NEW |