Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ft.cc

Issue 10510004: Roll harfbuzz-ng 3b8fd9c48f4bde368bf2d465c148b9743a9216ee (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ft.h ('k') | third_party/harfbuzz-ng/src/hb-glib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * - We don't handle / allow for emboldening / obliqueing. 54 * - We don't handle / allow for emboldening / obliqueing.
55 * 55 *
56 * - Rounding, etc? 56 * - Rounding, etc?
57 * 57 *
58 * - In the future, we should add constructors to create fonts in font space. 58 * - In the future, we should add constructors to create fonts in font space.
59 * 59 *
60 * - I believe transforms are not correctly implemented. FreeType does not 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. :( 61 * provide any API to get to the transform/delta set on the face. :(
62 * 62 *
63 * - Always use FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH? 63 * - Always use FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH?
64 *
65 * - FT_Load_Glyph() is exteremely costly. Do something about it?
64 */ 66 */
65 67
66 68
67 static hb_bool_t 69 static hb_bool_t
68 hb_ft_get_glyph (hb_font_t *font HB_UNUSED, 70 hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
69 void *font_data, 71 void *font_data,
70 hb_codepoint_t unicode, 72 hb_codepoint_t unicode,
71 hb_codepoint_t variation_selector, 73 hb_codepoint_t variation_selector,
72 hb_codepoint_t *glyph, 74 hb_codepoint_t *glyph,
73 void *user_data HB_UNUSED) 75 void *user_data HB_UNUSED)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 224
223 if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) 225 if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points))
224 return FALSE; 226 return FALSE;
225 227
226 *x = ft_face->glyph->outline.points[point_index].x; 228 *x = ft_face->glyph->outline.points[point_index].x;
227 *y = ft_face->glyph->outline.points[point_index].y; 229 *y = ft_face->glyph->outline.points[point_index].y;
228 230
229 return TRUE; 231 return TRUE;
230 } 232 }
231 233
234 static hb_bool_t
235 hb_ft_get_glyph_name (hb_font_t *font,
236 void *font_data,
237 hb_codepoint_t glyph,
238 char *name, unsigned int size,
239 void *user_data HB_UNUSED)
240 {
241 FT_Face ft_face = (FT_Face) font_data;
242
243 hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size);
244 if (!ret)
245 snprintf (name, size, "gid%u", glyph);
246
247 return ret;
248 }
249
250 static hb_bool_t
251 hb_ft_get_glyph_from_name (hb_font_t *font,
252 void *font_data,
253 const char *name, int len, /* -1 means nul-terminated */
254 hb_codepoint_t *glyph,
255 void *user_data HB_UNUSED)
256 {
257 FT_Face ft_face = (FT_Face) font_data;
258
259 if (len < 0)
260 *glyph = FT_Get_Name_Index (ft_face, (FT_String *) name);
261 else {
262 /* Make a nul-terminated version. */
263 char buf[128];
264 len = MIN (len, (int) sizeof (buf) - 1);
265 strncpy (buf, name, len);
266 buf[len] = '\0';
267 *glyph = FT_Get_Name_Index (ft_face, buf);
268 }
269
270 return *glyph != 0;
271 }
272
273
232 static hb_font_funcs_t ft_ffuncs = { 274 static hb_font_funcs_t ft_ffuncs = {
233 HB_OBJECT_HEADER_STATIC, 275 HB_OBJECT_HEADER_STATIC,
234 276
235 TRUE, /* immutable */ 277 TRUE, /* immutable */
236 278
237 { 279 {
238 hb_ft_get_glyph, 280 #define HB_FONT_FUNC_IMPLEMENT(name) hb_ft_get_##name,
239 hb_ft_get_glyph_h_advance, 281 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
240 hb_ft_get_glyph_v_advance, 282 #undef HB_FONT_FUNC_IMPLEMENT
241 hb_ft_get_glyph_h_origin,
242 hb_ft_get_glyph_v_origin,
243 hb_ft_get_glyph_h_kerning,
244 hb_ft_get_glyph_v_kerning,
245 hb_ft_get_glyph_extents,
246 hb_ft_get_glyph_contour_point,
247 } 283 }
248 }; 284 };
249 285
250 static hb_font_funcs_t * 286 static hb_font_funcs_t *
251 _hb_ft_get_font_funcs (void) 287 _hb_ft_get_font_funcs (void)
252 { 288 {
253 return &ft_ffuncs; 289 return &ft_ffuncs;
254 } 290 }
255 291
256 292
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 466
431 FT_Face 467 FT_Face
432 hb_ft_font_get_face (hb_font_t *font) 468 hb_ft_font_get_face (hb_font_t *font)
433 { 469 {
434 if (font->destroy == (hb_destroy_func_t) FT_Done_Face || 470 if (font->destroy == (hb_destroy_func_t) FT_Done_Face ||
435 font->destroy == (hb_destroy_func_t) _do_nothing) 471 font->destroy == (hb_destroy_func_t) _do_nothing)
436 return (FT_Face) font->user_data; 472 return (FT_Face) font->user_data;
437 473
438 return NULL; 474 return NULL;
439 } 475 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ft.h ('k') | third_party/harfbuzz-ng/src/hb-glib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698