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

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

Issue 10915172: harfbuzz-ng roll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font-private.hh ('k') | third_party/harfbuzz-ng/src/hb-glib.cc » ('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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 /* Note: FreeType's vertical metrics grows downward while other FreeType coord inates 152 /* Note: FreeType's vertical metrics grows downward while other FreeType coord inates
153 * have a Y growing upward. Hence the extra negation. */ 153 * have a Y growing upward. Hence the extra negation. */
154 *x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBear ingX; 154 *x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBear ingX;
155 *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBear ingY); 155 *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBear ingY);
156 156
157 return true; 157 return true;
158 } 158 }
159 159
160 static hb_position_t 160 static hb_position_t
161 hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED, 161 hb_ft_get_glyph_h_kerning (hb_font_t *font,
162 void *font_data, 162 void *font_data,
163 hb_codepoint_t left_glyph, 163 hb_codepoint_t left_glyph,
164 hb_codepoint_t right_glyph, 164 hb_codepoint_t right_glyph,
165 void *user_data HB_UNUSED) 165 void *user_data HB_UNUSED)
166 { 166 {
167 FT_Face ft_face = (FT_Face) font_data; 167 FT_Face ft_face = (FT_Face) font_data;
168 FT_Vector kerningv; 168 FT_Vector kerningv;
169 169
170 if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &ker ningv)) 170 FT_Kerning_Mode mode = font->x_ppem ? FT_KERNING_DEFAULT : FT_KERNING_UNFITTED ;
171 if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, mode, &kerningv))
171 return 0; 172 return 0;
172 173
173 return kerningv.x; 174 return kerningv.x;
174 } 175 }
175 176
176 static hb_position_t 177 static hb_position_t
177 hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED, 178 hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED,
178 void *font_data HB_UNUSED, 179 void *font_data HB_UNUSED,
179 hb_codepoint_t top_glyph HB_UNUSED, 180 hb_codepoint_t top_glyph HB_UNUSED,
180 hb_codepoint_t bottom_glyph HB_UNUSED, 181 hb_codepoint_t bottom_glyph HB_UNUSED,
(...skipping 12 matching lines...) Expand all
193 { 194 {
194 FT_Face ft_face = (FT_Face) font_data; 195 FT_Face ft_face = (FT_Face) font_data;
195 int load_flags = FT_LOAD_DEFAULT; 196 int load_flags = FT_LOAD_DEFAULT;
196 197
197 if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) 198 if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
198 return false; 199 return false;
199 200
200 extents->x_bearing = ft_face->glyph->metrics.horiBearingX; 201 extents->x_bearing = ft_face->glyph->metrics.horiBearingX;
201 extents->y_bearing = ft_face->glyph->metrics.horiBearingY; 202 extents->y_bearing = ft_face->glyph->metrics.horiBearingY;
202 extents->width = ft_face->glyph->metrics.width; 203 extents->width = ft_face->glyph->metrics.width;
203 extents->height = ft_face->glyph->metrics.height; 204 extents->height = -ft_face->glyph->metrics.height;
204 return true; 205 return true;
205 } 206 }
206 207
207 static hb_bool_t 208 static hb_bool_t
208 hb_ft_get_glyph_contour_point (hb_font_t *font HB_UNUSED, 209 hb_ft_get_glyph_contour_point (hb_font_t *font HB_UNUSED,
209 void *font_data, 210 void *font_data,
210 hb_codepoint_t glyph, 211 hb_codepoint_t glyph,
211 unsigned int point_index, 212 unsigned int point_index,
212 hb_position_t *x, 213 hb_position_t *x,
213 hb_position_t *y, 214 hb_position_t *y,
(...skipping 11 matching lines...) Expand all
225 if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) 226 if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points))
226 return false; 227 return false;
227 228
228 *x = ft_face->glyph->outline.points[point_index].x; 229 *x = ft_face->glyph->outline.points[point_index].x;
229 *y = ft_face->glyph->outline.points[point_index].y; 230 *y = ft_face->glyph->outline.points[point_index].y;
230 231
231 return true; 232 return true;
232 } 233 }
233 234
234 static hb_bool_t 235 static hb_bool_t
235 hb_ft_get_glyph_name (hb_font_t *font, 236 hb_ft_get_glyph_name (hb_font_t *font HB_UNUSED,
236 void *font_data, 237 void *font_data,
237 hb_codepoint_t glyph, 238 hb_codepoint_t glyph,
238 char *name, unsigned int size, 239 char *name, unsigned int size,
239 void *user_data HB_UNUSED) 240 void *user_data HB_UNUSED)
240 { 241 {
241 FT_Face ft_face = (FT_Face) font_data; 242 FT_Face ft_face = (FT_Face) font_data;
242 243
243 hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size); 244 hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size);
244 if (!ret) 245 if (!ret)
245 snprintf (name, size, "gid%u", glyph); 246 snprintf (name, size, "gid%u", glyph);
246 247
247 return ret; 248 return ret;
248 } 249 }
249 250
250 static hb_bool_t 251 static hb_bool_t
251 hb_ft_get_glyph_from_name (hb_font_t *font, 252 hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED,
252 void *font_data, 253 void *font_data,
253 const char *name, int len, /* -1 means nul-terminated */ 254 const char *name, int len, /* -1 means nul-terminated */
254 hb_codepoint_t *glyph, 255 hb_codepoint_t *glyph,
255 void *user_data HB_UNUSED) 256 void *user_data HB_UNUSED)
256 { 257 {
257 FT_Face ft_face = (FT_Face) font_data; 258 FT_Face ft_face = (FT_Face) font_data;
258 259
259 if (len < 0) 260 if (len < 0)
260 *glyph = FT_Get_Name_Index (ft_face, (FT_String *) name); 261 *glyph = FT_Get_Name_Index (ft_face, (FT_String *) name);
261 else { 262 else {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 &ft_face); 457 &ft_face);
457 458
458 if (unlikely (err)) { 459 if (unlikely (err)) {
459 hb_blob_destroy (blob); 460 hb_blob_destroy (blob);
460 DEBUG_MSG (FT, font, "Font face FT_New_Memory_Face() failed"); 461 DEBUG_MSG (FT, font, "Font face FT_New_Memory_Face() failed");
461 return; 462 return;
462 } 463 }
463 464
464 FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE); 465 FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE);
465 466
467 assert (font->y_scale >= 0);
466 FT_Set_Char_Size (ft_face, 468 FT_Set_Char_Size (ft_face,
467 font->x_scale, font->y_scale, 469 font->x_scale, font->y_scale,
470 0, 0);
471 #if 0
468 font->x_ppem * 72 * 64 / font->x_scale, 472 font->x_ppem * 72 * 64 / font->x_scale,
469 font->y_ppem * 72 * 64 / font->y_scale); 473 font->y_ppem * 72 * 64 / font->y_scale);
474 #endif
470 475
471 ft_face->generic.data = blob; 476 ft_face->generic.data = blob;
472 ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob; 477 ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob;
473 478
474 hb_font_set_funcs (font, 479 hb_font_set_funcs (font,
475 _hb_ft_get_font_funcs (), 480 _hb_ft_get_font_funcs (),
476 ft_face, 481 ft_face,
477 (hb_destroy_func_t) FT_Done_Face); 482 (hb_destroy_func_t) FT_Done_Face);
478 } 483 }
479 484
480 FT_Face 485 FT_Face
481 hb_ft_font_get_face (hb_font_t *font) 486 hb_ft_font_get_face (hb_font_t *font)
482 { 487 {
483 if (font->destroy == (hb_destroy_func_t) FT_Done_Face || 488 if (font->destroy == (hb_destroy_func_t) FT_Done_Face ||
484 font->destroy == (hb_destroy_func_t) _do_nothing) 489 font->destroy == (hb_destroy_func_t) _do_nothing)
485 return (FT_Face) font->user_data; 490 return (FT_Face) font->user_data;
486 491
487 return NULL; 492 return NULL;
488 } 493 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font-private.hh ('k') | third_party/harfbuzz-ng/src/hb-glib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698