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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ot-cmap-table.hh

Issue 1005693006: Roll harfbuzz-ng to 0.9.40 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 © 2014 Google, Inc. 2 * Copyright © 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 { 44 {
45 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const 45 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
46 { 46 {
47 hb_codepoint_t gid = codepoint < 256 ? glyphIdArray[codepoint] : 0; 47 hb_codepoint_t gid = codepoint < 256 ? glyphIdArray[codepoint] : 0;
48 if (!gid) 48 if (!gid)
49 return false; 49 return false;
50 *glyph = gid; 50 *glyph = gid;
51 return true; 51 return true;
52 } 52 }
53 53
54 inline bool sanitize (hb_sanitize_context_t *c) { 54 inline bool sanitize (hb_sanitize_context_t *c) const
55 {
55 TRACE_SANITIZE (this); 56 TRACE_SANITIZE (this);
56 return TRACE_RETURN (c->check_struct (this)); 57 return TRACE_RETURN (c->check_struct (this));
57 } 58 }
58 59
59 protected: 60 protected:
60 USHORT format; /* Format number is set to 0. */ 61 USHORT format; /* Format number is set to 0. */
61 USHORT lengthZ; /* Byte length of this subtable. */ 62 USHORT lengthZ; /* Byte length of this subtable. */
62 USHORT languageZ; /* Ignore. */ 63 USHORT languageZ; /* Ignore. */
63 BYTE glyphIdArray[256];/* An array that maps character 64 BYTE glyphIdArray[256];/* An array that maps character
64 * code to glyph index values. */ 65 * code to glyph index values. */
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 gid = glyphIdArray[index]; 119 gid = glyphIdArray[index];
119 if (unlikely (!gid)) 120 if (unlikely (!gid))
120 return false; 121 return false;
121 gid += idDelta[i]; 122 gid += idDelta[i];
122 } 123 }
123 124
124 *glyph = gid & 0xFFFFu; 125 *glyph = gid & 0xFFFFu;
125 return true; 126 return true;
126 } 127 }
127 128
128 inline bool sanitize (hb_sanitize_context_t *c) 129 inline bool sanitize (hb_sanitize_context_t *c) const
129 { 130 {
130 TRACE_SANITIZE (this); 131 TRACE_SANITIZE (this);
131 if (unlikely (!c->check_struct (this))) 132 if (unlikely (!c->check_struct (this)))
132 return TRACE_RETURN (false); 133 return TRACE_RETURN (false);
133 134
134 if (unlikely (!c->check_range (this, length))) 135 if (unlikely (!c->check_range (this, length)))
135 { 136 {
136 /* Some broken fonts have too long of a "length" value. 137 /* Some broken fonts have too long of a "length" value.
137 * If that is the case, just change the value to truncate 138 * If that is the case, just change the value to truncate
138 * the subtable at the end of the blob. */ 139 * the subtable at the end of the blob. */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 friend struct CmapSubtableFormat12; 177 friend struct CmapSubtableFormat12;
177 friend struct CmapSubtableFormat13; 178 friend struct CmapSubtableFormat13;
178 179
179 int cmp (hb_codepoint_t codepoint) const 180 int cmp (hb_codepoint_t codepoint) const
180 { 181 {
181 if (codepoint < startCharCode) return -1; 182 if (codepoint < startCharCode) return -1;
182 if (codepoint > endCharCode) return +1; 183 if (codepoint > endCharCode) return +1;
183 return 0; 184 return 0;
184 } 185 }
185 186
186 inline bool sanitize (hb_sanitize_context_t *c) { 187 inline bool sanitize (hb_sanitize_context_t *c) const
188 {
187 TRACE_SANITIZE (this); 189 TRACE_SANITIZE (this);
188 return TRACE_RETURN (c->check_struct (this)); 190 return TRACE_RETURN (c->check_struct (this));
189 } 191 }
190 192
191 private: 193 private:
192 ULONG startCharCode; /* First character code in this group. */ 194 ULONG startCharCode; /* First character code in this group. */
193 ULONG endCharCode; /* Last character code in this group. */ 195 ULONG endCharCode; /* Last character code in this group. */
194 ULONG glyphID; /* Glyph index; interpretation depends on 196 ULONG glyphID; /* Glyph index; interpretation depends on
195 * subtable format. */ 197 * subtable format. */
196 public: 198 public:
197 DEFINE_SIZE_STATIC (12); 199 DEFINE_SIZE_STATIC (12);
198 }; 200 };
199 201
200 template <typename UINT> 202 template <typename UINT>
201 struct CmapSubtableTrimmed 203 struct CmapSubtableTrimmed
202 { 204 {
203 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const 205 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
204 { 206 {
205 /* Rely on our implicit array bound-checking. */ 207 /* Rely on our implicit array bound-checking. */
206 hb_codepoint_t gid = glyphIdArray[codepoint - startCharCode]; 208 hb_codepoint_t gid = glyphIdArray[codepoint - startCharCode];
207 if (!gid) 209 if (!gid)
208 return false; 210 return false;
209 *glyph = gid; 211 *glyph = gid;
210 return true; 212 return true;
211 } 213 }
212 214
213 inline bool sanitize (hb_sanitize_context_t *c) { 215 inline bool sanitize (hb_sanitize_context_t *c) const
216 {
214 TRACE_SANITIZE (this); 217 TRACE_SANITIZE (this);
215 return TRACE_RETURN (c->check_struct (this) && glyphIdArray.sanitize (c)); 218 return TRACE_RETURN (c->check_struct (this) && glyphIdArray.sanitize (c));
216 } 219 }
217 220
218 protected: 221 protected:
219 UINT formatReserved; /* Subtable format and (maybe) padding. */ 222 UINT formatReserved; /* Subtable format and (maybe) padding. */
220 UINT lengthZ; /* Byte length of this subtable. */ 223 UINT lengthZ; /* Byte length of this subtable. */
221 UINT languageZ; /* Ignore. */ 224 UINT languageZ; /* Ignore. */
222 UINT startCharCode; /* First character code covered. */ 225 UINT startCharCode; /* First character code covered. */
223 ArrayOf<GlyphID, UINT> 226 ArrayOf<GlyphID, UINT>
(...skipping 11 matching lines...) Expand all
235 { 238 {
236 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const 239 inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
237 { 240 {
238 int i = groups.bsearch (codepoint); 241 int i = groups.bsearch (codepoint);
239 if (i == -1) 242 if (i == -1)
240 return false; 243 return false;
241 *glyph = T::group_get_glyph (groups[i], codepoint); 244 *glyph = T::group_get_glyph (groups[i], codepoint);
242 return true; 245 return true;
243 } 246 }
244 247
245 inline bool sanitize (hb_sanitize_context_t *c) { 248 inline bool sanitize (hb_sanitize_context_t *c) const
249 {
246 TRACE_SANITIZE (this); 250 TRACE_SANITIZE (this);
247 return TRACE_RETURN (c->check_struct (this) && groups.sanitize (c)); 251 return TRACE_RETURN (c->check_struct (this) && groups.sanitize (c));
248 } 252 }
249 253
250 protected: 254 protected:
251 USHORT format; /* Subtable format; set to 12. */ 255 USHORT format; /* Subtable format; set to 12. */
252 USHORT reservedZ; /* Reserved; set to 0. */ 256 USHORT reservedZ; /* Reserved; set to 0. */
253 ULONG lengthZ; /* Byte length of this subtable. */ 257 ULONG lengthZ; /* Byte length of this subtable. */
254 ULONG languageZ; /* Ignore. */ 258 ULONG languageZ; /* Ignore. */
255 SortedArrayOf<CmapSubtableLongGroup, ULONG> 259 SortedArrayOf<CmapSubtableLongGroup, ULONG>
(...skipping 25 matching lines...) Expand all
281 285
282 struct UnicodeValueRange 286 struct UnicodeValueRange
283 { 287 {
284 inline int cmp (const hb_codepoint_t &codepoint) const 288 inline int cmp (const hb_codepoint_t &codepoint) const
285 { 289 {
286 if (codepoint < startUnicodeValue) return -1; 290 if (codepoint < startUnicodeValue) return -1;
287 if (codepoint > startUnicodeValue + additionalCount) return +1; 291 if (codepoint > startUnicodeValue + additionalCount) return +1;
288 return 0; 292 return 0;
289 } 293 }
290 294
291 inline bool sanitize (hb_sanitize_context_t *c) { 295 inline bool sanitize (hb_sanitize_context_t *c) const
296 {
292 TRACE_SANITIZE (this); 297 TRACE_SANITIZE (this);
293 return TRACE_RETURN (c->check_struct (this)); 298 return TRACE_RETURN (c->check_struct (this));
294 } 299 }
295 300
296 UINT24 startUnicodeValue; /* First value in this range. */ 301 UINT24 startUnicodeValue; /* First value in this range. */
297 BYTE additionalCount; /* Number of additional values in this 302 BYTE additionalCount; /* Number of additional values in this
298 * range. */ 303 * range. */
299 public: 304 public:
300 DEFINE_SIZE_STATIC (4); 305 DEFINE_SIZE_STATIC (4);
301 }; 306 };
302 307
303 typedef SortedArrayOf<UnicodeValueRange, ULONG> DefaultUVS; 308 typedef SortedArrayOf<UnicodeValueRange, ULONG> DefaultUVS;
304 309
305 struct UVSMapping 310 struct UVSMapping
306 { 311 {
307 inline int cmp (const hb_codepoint_t &codepoint) const 312 inline int cmp (const hb_codepoint_t &codepoint) const
308 { 313 {
309 return unicodeValue.cmp (codepoint); 314 return unicodeValue.cmp (codepoint);
310 } 315 }
311 316
312 inline bool sanitize (hb_sanitize_context_t *c) { 317 inline bool sanitize (hb_sanitize_context_t *c) const
318 {
313 TRACE_SANITIZE (this); 319 TRACE_SANITIZE (this);
314 return TRACE_RETURN (c->check_struct (this)); 320 return TRACE_RETURN (c->check_struct (this));
315 } 321 }
316 322
317 UINT24 unicodeValue; /* Base Unicode value of the UVS */ 323 UINT24 unicodeValue; /* Base Unicode value of the UVS */
318 GlyphID glyphID; /* Glyph ID of the UVS */ 324 GlyphID glyphID; /* Glyph ID of the UVS */
319 public: 325 public:
320 DEFINE_SIZE_STATIC (5); 326 DEFINE_SIZE_STATIC (5);
321 }; 327 };
322 328
(...skipping 18 matching lines...) Expand all
341 return GLYPH_VARIANT_FOUND; 347 return GLYPH_VARIANT_FOUND;
342 } 348 }
343 return GLYPH_VARIANT_NOT_FOUND; 349 return GLYPH_VARIANT_NOT_FOUND;
344 } 350 }
345 351
346 inline int cmp (const hb_codepoint_t &variation_selector) const 352 inline int cmp (const hb_codepoint_t &variation_selector) const
347 { 353 {
348 return varSelector.cmp (variation_selector); 354 return varSelector.cmp (variation_selector);
349 } 355 }
350 356
351 inline bool sanitize (hb_sanitize_context_t *c, void *base) { 357 inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
358 {
352 TRACE_SANITIZE (this); 359 TRACE_SANITIZE (this);
353 return TRACE_RETURN (c->check_struct (this) && 360 return TRACE_RETURN (c->check_struct (this) &&
354 defaultUVS.sanitize (c, base) && 361 defaultUVS.sanitize (c, base) &&
355 nonDefaultUVS.sanitize (c, base)); 362 nonDefaultUVS.sanitize (c, base));
356 } 363 }
357 364
358 UINT24 varSelector; /* Variation selector. */ 365 UINT24 varSelector; /* Variation selector. */
359 OffsetTo<DefaultUVS, ULONG> 366 OffsetTo<DefaultUVS, ULONG>
360 defaultUVS; /* Offset to Default UVS Table. May be 0. */ 367 defaultUVS; /* Offset to Default UVS Table. May be 0. */
361 OffsetTo<NonDefaultUVS, ULONG> 368 OffsetTo<NonDefaultUVS, ULONG>
362 nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */ 369 nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */
363 public: 370 public:
364 DEFINE_SIZE_STATIC (11); 371 DEFINE_SIZE_STATIC (11);
365 }; 372 };
366 373
367 struct CmapSubtableFormat14 374 struct CmapSubtableFormat14
368 { 375 {
369 inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, 376 inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint,
370 hb_codepoint_t variation_selector, 377 hb_codepoint_t variation_selector,
371 hb_codepoint_t *glyph) const 378 hb_codepoint_t *glyph) const
372 { 379 {
373 return record[record.bsearch(variation_selector)].get_glyph (codepoint, glyp h, this); 380 return record[record.bsearch(variation_selector)].get_glyph (codepoint, glyp h, this);
374 } 381 }
375 382
376 inline bool sanitize (hb_sanitize_context_t *c) { 383 inline bool sanitize (hb_sanitize_context_t *c) const
384 {
377 TRACE_SANITIZE (this); 385 TRACE_SANITIZE (this);
378 return TRACE_RETURN (c->check_struct (this) && 386 return TRACE_RETURN (c->check_struct (this) &&
379 record.sanitize (c, this)); 387 record.sanitize (c, this));
380 } 388 }
381 389
382 protected: 390 protected:
383 USHORT format; /* Format number is set to 0. */ 391 USHORT format; /* Format number is set to 0. */
384 ULONG lengthZ; /* Byte length of this subtable. */ 392 ULONG lengthZ; /* Byte length of this subtable. */
385 SortedArrayOf<VariationSelectorRecord, ULONG> 393 SortedArrayOf<VariationSelectorRecord, ULONG>
386 record; /* Variation selector records; sorted 394 record; /* Variation selector records; sorted
(...skipping 24 matching lines...) Expand all
411 inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, 419 inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint,
412 hb_codepoint_t variation_selector, 420 hb_codepoint_t variation_selector,
413 hb_codepoint_t *glyph) const 421 hb_codepoint_t *glyph) const
414 { 422 {
415 switch (u.format) { 423 switch (u.format) {
416 case 14: return u.format14.get_glyph_variant(codepoint, variation_selector, glyph); 424 case 14: return u.format14.get_glyph_variant(codepoint, variation_selector, glyph);
417 default: return GLYPH_VARIANT_NOT_FOUND; 425 default: return GLYPH_VARIANT_NOT_FOUND;
418 } 426 }
419 } 427 }
420 428
421 inline bool sanitize (hb_sanitize_context_t *c) { 429 inline bool sanitize (hb_sanitize_context_t *c) const
430 {
422 TRACE_SANITIZE (this); 431 TRACE_SANITIZE (this);
423 if (!u.format.sanitize (c)) return TRACE_RETURN (false); 432 if (!u.format.sanitize (c)) return TRACE_RETURN (false);
424 switch (u.format) { 433 switch (u.format) {
425 case 0: return TRACE_RETURN (u.format0 .sanitize (c)); 434 case 0: return TRACE_RETURN (u.format0 .sanitize (c));
426 case 4: return TRACE_RETURN (u.format4 .sanitize (c)); 435 case 4: return TRACE_RETURN (u.format4 .sanitize (c));
427 case 6: return TRACE_RETURN (u.format6 .sanitize (c)); 436 case 6: return TRACE_RETURN (u.format6 .sanitize (c));
428 case 10: return TRACE_RETURN (u.format10.sanitize (c)); 437 case 10: return TRACE_RETURN (u.format10.sanitize (c));
429 case 12: return TRACE_RETURN (u.format12.sanitize (c)); 438 case 12: return TRACE_RETURN (u.format12.sanitize (c));
430 case 13: return TRACE_RETURN (u.format13.sanitize (c)); 439 case 13: return TRACE_RETURN (u.format13.sanitize (c));
431 case 14: return TRACE_RETURN (u.format14.sanitize (c)); 440 case 14: return TRACE_RETURN (u.format14.sanitize (c));
(...skipping 22 matching lines...) Expand all
454 inline int cmp (const EncodingRecord &other) const 463 inline int cmp (const EncodingRecord &other) const
455 { 464 {
456 int ret; 465 int ret;
457 ret = platformID.cmp (other.platformID); 466 ret = platformID.cmp (other.platformID);
458 if (ret) return ret; 467 if (ret) return ret;
459 ret = encodingID.cmp (other.encodingID); 468 ret = encodingID.cmp (other.encodingID);
460 if (ret) return ret; 469 if (ret) return ret;
461 return 0; 470 return 0;
462 } 471 }
463 472
464 inline bool sanitize (hb_sanitize_context_t *c, void *base) { 473 inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
474 {
465 TRACE_SANITIZE (this); 475 TRACE_SANITIZE (this);
466 return TRACE_RETURN (c->check_struct (this) && 476 return TRACE_RETURN (c->check_struct (this) &&
467 subtable.sanitize (c, base)); 477 subtable.sanitize (c, base));
468 } 478 }
469 479
470 USHORT platformID; /* Platform ID. */ 480 USHORT platformID; /* Platform ID. */
471 USHORT encodingID; /* Platform-specific encoding ID. */ 481 USHORT encodingID; /* Platform-specific encoding ID. */
472 OffsetTo<CmapSubtable, ULONG> 482 OffsetTo<CmapSubtable, ULONG>
473 subtable; /* Byte offset from beginning of table to the su btable for this encoding. */ 483 subtable; /* Byte offset from beginning of table to the su btable for this encoding. */
474 public: 484 public:
(...skipping 14 matching lines...) Expand all
489 /* Note: We can use bsearch, but since it has no performance 499 /* Note: We can use bsearch, but since it has no performance
490 * implications, we use lsearch and as such accept fonts with 500 * implications, we use lsearch and as such accept fonts with
491 * unsorted subtable list. */ 501 * unsorted subtable list. */
492 int result = encodingRecord./*bsearch*/lsearch (key); 502 int result = encodingRecord./*bsearch*/lsearch (key);
493 if (result == -1 || !encodingRecord[result].subtable) 503 if (result == -1 || !encodingRecord[result].subtable)
494 return NULL; 504 return NULL;
495 505
496 return &(this+encodingRecord[result].subtable); 506 return &(this+encodingRecord[result].subtable);
497 } 507 }
498 508
499 inline bool sanitize (hb_sanitize_context_t *c) { 509 inline bool sanitize (hb_sanitize_context_t *c) const
510 {
500 TRACE_SANITIZE (this); 511 TRACE_SANITIZE (this);
501 return TRACE_RETURN (c->check_struct (this) && 512 return TRACE_RETURN (c->check_struct (this) &&
502 likely (version == 0) && 513 likely (version == 0) &&
503 encodingRecord.sanitize (c, this)); 514 encodingRecord.sanitize (c, this));
504 } 515 }
505 516
506 USHORT version; /* Table version number (0). */ 517 USHORT version; /* Table version number (0). */
507 SortedArrayOf<EncodingRecord> 518 SortedArrayOf<EncodingRecord>
508 encodingRecord; /* Encoding tables. */ 519 encodingRecord; /* Encoding tables. */
509 public: 520 public:
510 DEFINE_SIZE_ARRAY (4, encodingRecord); 521 DEFINE_SIZE_ARRAY (4, encodingRecord);
511 }; 522 };
512 523
513 524
514 } /* namespace OT */ 525 } /* namespace OT */
515 526
516 527
517 #endif /* HB_OT_CMAP_TABLE_HH */ 528 #endif /* HB_OT_CMAP_TABLE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-open-type-private.hh ('k') | third_party/harfbuzz-ng/src/hb-ot-head-table.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698