| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, Inc. |
| 3 * Copyright © 2009 Keith Stribley | 3 * Copyright © 2009 Keith Stribley |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 * In general, this file does a fine job of what it's supposed to do. | 46 * In general, this file does a fine job of what it's supposed to do. |
| 47 * There are, however, things that need more work: | 47 * There are, however, things that need more work: |
| 48 * | 48 * |
| 49 * - We don't handle any load_flags. That definitely has API implications. :( | 49 * - We don't handle any load_flags. That definitely has API implications. :( |
| 50 * I believe hb_ft_font_create() should take load_flags input. | 50 * I believe hb_ft_font_create() should take load_flags input. |
| 51 * In particular, FT_Get_Advance() without the NO_HINTING flag seems to be | 51 * In particular, FT_Get_Advance() without the NO_HINTING flag seems to be |
| 52 * buggy. | 52 * buggy. |
| 53 * | 53 * |
| 54 * - We don't handle / allow for emboldening / obliqueing. | 54 * - We don't handle / allow for emboldening / obliqueing. |
| 55 * | 55 * |
| 56 * - Rounding, etc? | 56 * - In the future, we should add constructors to create fonts in font space? |
| 57 * | |
| 58 * - In the future, we should add constructors to create fonts in font space. | |
| 59 * | |
| 60 * - I believe transforms are not correctly implemented. FreeType does not | |
| 61 * provide any API to get to the transform/delta set on the face. :( | |
| 62 * | |
| 63 * - Always use FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH? | |
| 64 * | 57 * |
| 65 * - FT_Load_Glyph() is exteremely costly. Do something about it? | 58 * - FT_Load_Glyph() is exteremely costly. Do something about it? |
| 66 */ | 59 */ |
| 67 | 60 |
| 68 | 61 |
| 69 static hb_bool_t | 62 static hb_bool_t |
| 70 hb_ft_get_glyph (hb_font_t *font HB_UNUSED, | 63 hb_ft_get_glyph (hb_font_t *font HB_UNUSED, |
| 71 void *font_data, | 64 void *font_data, |
| 72 hb_codepoint_t unicode, | 65 hb_codepoint_t unicode, |
| 73 hb_codepoint_t variation_selector, | 66 hb_codepoint_t variation_selector, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 static hb_bool_t | 228 static hb_bool_t |
| 236 hb_ft_get_glyph_name (hb_font_t *font HB_UNUSED, | 229 hb_ft_get_glyph_name (hb_font_t *font HB_UNUSED, |
| 237 void *font_data, | 230 void *font_data, |
| 238 hb_codepoint_t glyph, | 231 hb_codepoint_t glyph, |
| 239 char *name, unsigned int size, | 232 char *name, unsigned int size, |
| 240 void *user_data HB_UNUSED) | 233 void *user_data HB_UNUSED) |
| 241 { | 234 { |
| 242 FT_Face ft_face = (FT_Face) font_data; | 235 FT_Face ft_face = (FT_Face) font_data; |
| 243 | 236 |
| 244 hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size); | 237 hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size); |
| 245 if (!ret || (size && !*name)) | 238 if (ret && (size && !*name)) |
| 246 snprintf (name, size, "gid%u", glyph); | 239 ret = false; |
| 247 | 240 |
| 248 return ret; | 241 return ret; |
| 249 } | 242 } |
| 250 | 243 |
| 251 static hb_bool_t | 244 static hb_bool_t |
| 252 hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED, | 245 hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED, |
| 253 void *font_data, | 246 void *font_data, |
| 254 const char *name, int len, /* -1 means nul-terminated
*/ | 247 const char *name, int len, /* -1 means nul-terminated
*/ |
| 255 hb_codepoint_t *glyph, | 248 hb_codepoint_t *glyph, |
| 256 void *user_data HB_UNUSED) | 249 void *user_data HB_UNUSED) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 ft_face->size->metrics.y_ppem); | 389 ft_face->size->metrics.y_ppem); |
| 397 | 390 |
| 398 return font; | 391 return font; |
| 399 } | 392 } |
| 400 | 393 |
| 401 | 394 |
| 402 /* Thread-safe, lock-free, FT_Library */ | 395 /* Thread-safe, lock-free, FT_Library */ |
| 403 | 396 |
| 404 static FT_Library ft_library; | 397 static FT_Library ft_library; |
| 405 | 398 |
| 406 static | 399 static inline |
| 407 void free_ft_library (void) | 400 void free_ft_library (void) |
| 408 { | 401 { |
| 409 FT_Done_FreeType (ft_library); | 402 FT_Done_FreeType (ft_library); |
| 410 } | 403 } |
| 411 | 404 |
| 412 static FT_Library | 405 static FT_Library |
| 413 get_ft_library (void) | 406 get_ft_library (void) |
| 414 { | 407 { |
| 415 retry: | 408 retry: |
| 416 FT_Library library = (FT_Library) hb_atomic_ptr_get (&ft_library); | 409 FT_Library library = (FT_Library) hb_atomic_ptr_get (&ft_library); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 477 |
| 485 FT_Face | 478 FT_Face |
| 486 hb_ft_font_get_face (hb_font_t *font) | 479 hb_ft_font_get_face (hb_font_t *font) |
| 487 { | 480 { |
| 488 if (font->destroy == (hb_destroy_func_t) FT_Done_Face || | 481 if (font->destroy == (hb_destroy_func_t) FT_Done_Face || |
| 489 font->destroy == (hb_destroy_func_t) _do_nothing) | 482 font->destroy == (hb_destroy_func_t) _do_nothing) |
| 490 return (FT_Face) font->user_data; | 483 return (FT_Face) font->user_data; |
| 491 | 484 |
| 492 return NULL; | 485 return NULL; |
| 493 } | 486 } |
| OLD | NEW |