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

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

Issue 2163983005: Roll HarfBuzz to 1.3.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright © 2011,2014 Google, Inc. 2 * Copyright © 2011,2014 Google, Inc.
3 * 3 *
4 * This is part of HarfBuzz, a text shaping library. 4 * This is part of HarfBuzz, a text shaping library.
5 * 5 *
6 * Permission is hereby granted, without written agreement and without 6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this 7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the 8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in 9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software. 10 * all copies of this software.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 template <typename Type> 209 template <typename Type>
210 static inline bool get_glyph_from (const void *obj, 210 static inline bool get_glyph_from (const void *obj,
211 hb_codepoint_t codepoint, 211 hb_codepoint_t codepoint,
212 hb_codepoint_t *glyph) 212 hb_codepoint_t *glyph)
213 { 213 {
214 const Type *typed_obj = (const Type *) obj; 214 const Type *typed_obj = (const Type *) obj;
215 return typed_obj->get_glyph (codepoint, glyph); 215 return typed_obj->get_glyph (codepoint, glyph);
216 } 216 }
217 217
218 template <typename Type>
219 static inline bool get_glyph_from_symbol (const void *obj,
220 hb_codepoint_t codepoint,
221 hb_codepoint_t *glyph)
222 {
223 const Type *typed_obj = (const Type *) obj;
224 if (likely (typed_obj->get_glyph (codepoint, glyph)))
225 return true;
226
227 if (codepoint <= 0x00FFu)
228 {
229 /* For symbol-encoded OpenType fonts, we duplicate the
230 * U+F000..F0FF range at U+0000..U+00FF. That's what
231 * Windows seems to do, and that's hinted about at:
232 * http://www.microsoft.com/typography/otspec/recom.htm
233 * under "Non-Standard (Symbol) Fonts". */
234 return typed_obj->get_glyph (0xF000u + codepoint, glyph);
235 }
236
237 return false;
238 }
239
218 struct hb_ot_face_cmap_accelerator_t 240 struct hb_ot_face_cmap_accelerator_t
219 { 241 {
220 hb_cmap_get_glyph_func_t get_glyph_func; 242 hb_cmap_get_glyph_func_t get_glyph_func;
221 const void *get_glyph_data; 243 const void *get_glyph_data;
222 OT::CmapSubtableFormat4::accelerator_t format4_accel; 244 OT::CmapSubtableFormat4::accelerator_t format4_accel;
223 245
224 const OT::CmapSubtableFormat14 *uvs_table; 246 const OT::CmapSubtableFormat14 *uvs_table;
225 hb_blob_t *blob; 247 hb_blob_t *blob;
226 248
227 inline void init (hb_face_t *face) 249 inline void init (hb_face_t *face)
228 { 250 {
229 this->blob = OT::Sanitizer<OT::cmap>::sanitize (face->reference_table (HB_OT _TAG_cmap)); 251 this->blob = OT::Sanitizer<OT::cmap>::sanitize (face->reference_table (HB_OT _TAG_cmap));
230 const OT::cmap *cmap = OT::Sanitizer<OT::cmap>::lock_instance (this->blob); 252 const OT::cmap *cmap = OT::Sanitizer<OT::cmap>::lock_instance (this->blob);
231 const OT::CmapSubtable *subtable = NULL; 253 const OT::CmapSubtable *subtable = NULL;
232 const OT::CmapSubtableFormat14 *subtable_uvs = NULL; 254 const OT::CmapSubtableFormat14 *subtable_uvs = NULL;
233 255
256 bool symbol = false;
234 /* 32-bit subtables. */ 257 /* 32-bit subtables. */
235 if (!subtable) subtable = cmap->find_subtable (3, 10); 258 if (!subtable) subtable = cmap->find_subtable (3, 10);
236 if (!subtable) subtable = cmap->find_subtable (0, 6); 259 if (!subtable) subtable = cmap->find_subtable (0, 6);
237 if (!subtable) subtable = cmap->find_subtable (0, 4); 260 if (!subtable) subtable = cmap->find_subtable (0, 4);
238 /* 16-bit subtables. */ 261 /* 16-bit subtables. */
239 if (!subtable) subtable = cmap->find_subtable (3, 1); 262 if (!subtable) subtable = cmap->find_subtable (3, 1);
240 if (!subtable) subtable = cmap->find_subtable (0, 3); 263 if (!subtable) subtable = cmap->find_subtable (0, 3);
241 if (!subtable) subtable = cmap->find_subtable (0, 2); 264 if (!subtable) subtable = cmap->find_subtable (0, 2);
242 if (!subtable) subtable = cmap->find_subtable (0, 1); 265 if (!subtable) subtable = cmap->find_subtable (0, 1);
243 if (!subtable) subtable = cmap->find_subtable (0, 0); 266 if (!subtable) subtable = cmap->find_subtable (0, 0);
244 if (!subtable) subtable = cmap->find_subtable (3, 0); 267 if (!subtable)(subtable = cmap->find_subtable (3, 0)) && (symbol = true);
245 /* Meh. */ 268 /* Meh. */
246 if (!subtable) subtable = &OT::Null(OT::CmapSubtable); 269 if (!subtable) subtable = &OT::Null(OT::CmapSubtable);
247 270
248 /* UVS subtable. */ 271 /* UVS subtable. */
249 if (!subtable_uvs) 272 if (!subtable_uvs)
250 { 273 {
251 const OT::CmapSubtable *st = cmap->find_subtable (0, 5); 274 const OT::CmapSubtable *st = cmap->find_subtable (0, 5);
252 if (st && st->u.format == 14) 275 if (st && st->u.format == 14)
253 subtable_uvs = &st->u.format14; 276 subtable_uvs = &st->u.format14;
254 } 277 }
255 /* Meh. */ 278 /* Meh. */
256 if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtableFormat14); 279 if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtableFormat14);
257 280
258 this->uvs_table = subtable_uvs; 281 this->uvs_table = subtable_uvs;
259 282
260 this->get_glyph_data = subtable; 283 this->get_glyph_data = subtable;
261 switch (subtable->u.format) { 284 if (unlikely (symbol))
262 /* Accelerate format 4 and format 12. */ 285 this->get_glyph_func = get_glyph_from_symbol<OT::CmapSubtable>;
263 default: this->get_glyph_func = get_glyph_from<OT::CmapSubtable>;» » break; 286 else
264 case 12: this->get_glyph_func = get_glyph_from<OT::CmapSubtableFormat12>;» break; 287 switch (subtable->u.format) {
265 case 4: 288 /* Accelerate format 4 and format 12. */
266 { 289 default: this->get_glyph_func = get_glyph_from<OT::CmapSubtable>;»» break;
267 this->format4_accel.init (&subtable->u.format4); 290 case 12: this->get_glyph_func = get_glyph_from<OT::CmapSubtableFormat12>;» break;
268 » this->get_glyph_data = &this->format4_accel; 291 case 4:
269 this->get_glyph_func = this->format4_accel.get_glyph_func; 292 » {
293 » this->format4_accel.init (&subtable->u.format4);
294 » this->get_glyph_data = &this->format4_accel;
295 » this->get_glyph_func = this->format4_accel.get_glyph_func;
296 » }
297 » break;
270 } 298 }
271 break;
272 }
273 } 299 }
274 300
275 inline void fini (void) 301 inline void fini (void)
276 { 302 {
277 hb_blob_destroy (this->blob); 303 hb_blob_destroy (this->blob);
278 } 304 }
279 305
280 inline bool get_nominal_glyph (hb_codepoint_t unicode, 306 inline bool get_nominal_glyph (hb_codepoint_t unicode,
281 hb_codepoint_t *glyph) const 307 hb_codepoint_t *glyph) const
282 { 308 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 { 552 {
527 hb_ot_font_t *ot_font = _hb_ot_font_create (font->face); 553 hb_ot_font_t *ot_font = _hb_ot_font_create (font->face);
528 if (unlikely (!ot_font)) 554 if (unlikely (!ot_font))
529 return; 555 return;
530 556
531 hb_font_set_funcs (font, 557 hb_font_set_funcs (font,
532 _hb_ot_get_font_funcs (), 558 _hb_ot_get_font_funcs (),
533 ot_font, 559 ot_font,
534 (hb_destroy_func_t) _hb_ot_font_destroy); 560 (hb_destroy_func_t) _hb_ot_font_destroy);
535 } 561 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-gobject-structs.h ('k') | third_party/harfbuzz-ng/src/hb-ot-layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698