| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2007,2008,2009 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009 Red Hat, Inc. |
| 3 * Copyright © 2010,2011,2012 Google, Inc. | 3 * Copyright © 2010,2011,2012 Google, Inc. |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 /* | 91 /* |
| 92 * Ligature Caret Table | 92 * Ligature Caret Table |
| 93 */ | 93 */ |
| 94 | 94 |
| 95 struct CaretValueFormat1 | 95 struct CaretValueFormat1 |
| 96 { | 96 { |
| 97 friend struct CaretValue; | 97 friend struct CaretValue; |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id HB_UNUSED) const | 100 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n) const |
| 101 { | 101 { |
| 102 return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate
) : font->em_scale_y (coordinate); | 102 return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate
) : font->em_scale_y (coordinate); |
| 103 } | 103 } |
| 104 | 104 |
| 105 inline bool sanitize (hb_sanitize_context_t *c) const | 105 inline bool sanitize (hb_sanitize_context_t *c) const |
| 106 { | 106 { |
| 107 TRACE_SANITIZE (this); | 107 TRACE_SANITIZE (this); |
| 108 return_trace (c->check_struct (this)); | 108 return_trace (c->check_struct (this)); |
| 109 } | 109 } |
| 110 | 110 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 139 USHORT caretValueFormat; /* Format identifier--format = 2 */ | 139 USHORT caretValueFormat; /* Format identifier--format = 2 */ |
| 140 USHORT caretValuePoint; /* Contour point index on glyph */ | 140 USHORT caretValuePoint; /* Contour point index on glyph */ |
| 141 public: | 141 public: |
| 142 DEFINE_SIZE_STATIC (4); | 142 DEFINE_SIZE_STATIC (4); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 struct CaretValueFormat3 | 145 struct CaretValueFormat3 |
| 146 { | 146 { |
| 147 friend struct CaretValue; | 147 friend struct CaretValue; |
| 148 | 148 |
| 149 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id HB_UNUSED) const | 149 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, const VariationStore &var_store) const |
| 150 { | 150 { |
| 151 return HB_DIRECTION_IS_HORIZONTAL (direction) ? | 151 return HB_DIRECTION_IS_HORIZONTAL (direction) ? |
| 152 font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font)
: | 152 font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font,
var_store) : |
| 153 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font)
; | 153 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font,
var_store); |
| 154 } | 154 } |
| 155 | 155 |
| 156 inline bool sanitize (hb_sanitize_context_t *c) const | 156 inline bool sanitize (hb_sanitize_context_t *c) const |
| 157 { | 157 { |
| 158 TRACE_SANITIZE (this); | 158 TRACE_SANITIZE (this); |
| 159 return_trace (c->check_struct (this) && deviceTable.sanitize (c, this)); | 159 return_trace (c->check_struct (this) && deviceTable.sanitize (c, this)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 protected: | 162 protected: |
| 163 USHORT caretValueFormat; /* Format identifier--format = 3 */ | 163 USHORT caretValueFormat; /* Format identifier--format = 3 */ |
| 164 SHORT coordinate; /* X or Y value, in design units */ | 164 SHORT coordinate; /* X or Y value, in design units */ |
| 165 OffsetTo<Device> | 165 OffsetTo<Device> |
| 166 deviceTable; /* Offset to Device table for X or Y | 166 deviceTable; /* Offset to Device table for X or Y |
| 167 * value--from beginning of CaretValue | 167 * value--from beginning of CaretValue |
| 168 * table */ | 168 * table */ |
| 169 public: | 169 public: |
| 170 DEFINE_SIZE_STATIC (6); | 170 DEFINE_SIZE_STATIC (6); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 struct CaretValue | 173 struct CaretValue |
| 174 { | 174 { |
| 175 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const | 175 inline hb_position_t get_caret_value (hb_font_t *font, |
| 176 » » » » » hb_direction_t direction, |
| 177 » » » » » hb_codepoint_t glyph_id, |
| 178 » » » » » const VariationStore &var_store) const |
| 176 { | 179 { |
| 177 switch (u.format) { | 180 switch (u.format) { |
| 178 case 1: return u.format1.get_caret_value (font, direction, glyph_id); | 181 case 1: return u.format1.get_caret_value (font, direction); |
| 179 case 2: return u.format2.get_caret_value (font, direction, glyph_id); | 182 case 2: return u.format2.get_caret_value (font, direction, glyph_id); |
| 180 case 3: return u.format3.get_caret_value (font, direction, glyph_id); | 183 case 3: return u.format3.get_caret_value (font, direction, var_store); |
| 181 default:return 0; | 184 default:return 0; |
| 182 } | 185 } |
| 183 } | 186 } |
| 184 | 187 |
| 185 inline bool sanitize (hb_sanitize_context_t *c) const | 188 inline bool sanitize (hb_sanitize_context_t *c) const |
| 186 { | 189 { |
| 187 TRACE_SANITIZE (this); | 190 TRACE_SANITIZE (this); |
| 188 if (!u.format.sanitize (c)) return_trace (false); | 191 if (!u.format.sanitize (c)) return_trace (false); |
| 189 switch (u.format) { | 192 switch (u.format) { |
| 190 case 1: return_trace (u.format1.sanitize (c)); | 193 case 1: return_trace (u.format1.sanitize (c)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 203 } u; | 206 } u; |
| 204 public: | 207 public: |
| 205 DEFINE_SIZE_UNION (2, format); | 208 DEFINE_SIZE_UNION (2, format); |
| 206 }; | 209 }; |
| 207 | 210 |
| 208 struct LigGlyph | 211 struct LigGlyph |
| 209 { | 212 { |
| 210 inline unsigned int get_lig_carets (hb_font_t *font, | 213 inline unsigned int get_lig_carets (hb_font_t *font, |
| 211 hb_direction_t direction, | 214 hb_direction_t direction, |
| 212 hb_codepoint_t glyph_id, | 215 hb_codepoint_t glyph_id, |
| 216 const VariationStore &var_store, |
| 213 unsigned int start_offset, | 217 unsigned int start_offset, |
| 214 unsigned int *caret_count /* IN/OUT */, | 218 unsigned int *caret_count /* IN/OUT */, |
| 215 hb_position_t *caret_array /* OUT */) cons
t | 219 hb_position_t *caret_array /* OUT */) cons
t |
| 216 { | 220 { |
| 217 if (caret_count) { | 221 if (caret_count) { |
| 218 const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_
count); | 222 const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_
count); |
| 219 unsigned int count = *caret_count; | 223 unsigned int count = *caret_count; |
| 220 for (unsigned int i = 0; i < count; i++) | 224 for (unsigned int i = 0; i < count; i++) |
| 221 » caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph
_id); | 225 » caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph
_id, var_store); |
| 222 } | 226 } |
| 223 | 227 |
| 224 return carets.len; | 228 return carets.len; |
| 225 } | 229 } |
| 226 | 230 |
| 227 inline bool sanitize (hb_sanitize_context_t *c) const | 231 inline bool sanitize (hb_sanitize_context_t *c) const |
| 228 { | 232 { |
| 229 TRACE_SANITIZE (this); | 233 TRACE_SANITIZE (this); |
| 230 return_trace (carets.sanitize (c, this)); | 234 return_trace (carets.sanitize (c, this)); |
| 231 } | 235 } |
| 232 | 236 |
| 233 protected: | 237 protected: |
| 234 OffsetArrayOf<CaretValue> | 238 OffsetArrayOf<CaretValue> |
| 235 carets; /* Offset array of CaretValue tables | 239 carets; /* Offset array of CaretValue tables |
| 236 * --from beginning of LigGlyph table | 240 * --from beginning of LigGlyph table |
| 237 * --in increasing coordinate order */ | 241 * --in increasing coordinate order */ |
| 238 public: | 242 public: |
| 239 DEFINE_SIZE_ARRAY (2, carets); | 243 DEFINE_SIZE_ARRAY (2, carets); |
| 240 }; | 244 }; |
| 241 | 245 |
| 242 struct LigCaretList | 246 struct LigCaretList |
| 243 { | 247 { |
| 244 inline unsigned int get_lig_carets (hb_font_t *font, | 248 inline unsigned int get_lig_carets (hb_font_t *font, |
| 245 hb_direction_t direction, | 249 hb_direction_t direction, |
| 246 hb_codepoint_t glyph_id, | 250 hb_codepoint_t glyph_id, |
| 251 const VariationStore &var_store, |
| 247 unsigned int start_offset, | 252 unsigned int start_offset, |
| 248 unsigned int *caret_count /* IN/OUT */, | 253 unsigned int *caret_count /* IN/OUT */, |
| 249 hb_position_t *caret_array /* OUT */) cons
t | 254 hb_position_t *caret_array /* OUT */) cons
t |
| 250 { | 255 { |
| 251 unsigned int index = (this+coverage).get_coverage (glyph_id); | 256 unsigned int index = (this+coverage).get_coverage (glyph_id); |
| 252 if (index == NOT_COVERED) | 257 if (index == NOT_COVERED) |
| 253 { | 258 { |
| 254 if (caret_count) | 259 if (caret_count) |
| 255 *caret_count = 0; | 260 *caret_count = 0; |
| 256 return 0; | 261 return 0; |
| 257 } | 262 } |
| 258 const LigGlyph &lig_glyph = this+ligGlyph[index]; | 263 const LigGlyph &lig_glyph = this+ligGlyph[index]; |
| 259 return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, ca
ret_count, caret_array); | 264 return lig_glyph.get_lig_carets (font, direction, glyph_id, var_store, start
_offset, caret_count, caret_array); |
| 260 } | 265 } |
| 261 | 266 |
| 262 inline bool sanitize (hb_sanitize_context_t *c) const | 267 inline bool sanitize (hb_sanitize_context_t *c) const |
| 263 { | 268 { |
| 264 TRACE_SANITIZE (this); | 269 TRACE_SANITIZE (this); |
| 265 return_trace (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this)); | 270 return_trace (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this)); |
| 266 } | 271 } |
| 267 | 272 |
| 268 protected: | 273 protected: |
| 269 OffsetTo<Coverage> | 274 OffsetTo<Coverage> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 unsigned int *point_array /* OUT */) co
nst | 365 unsigned int *point_array /* OUT */) co
nst |
| 361 { return (this+attachList).get_attach_points (glyph_id, start_offset, point_co
unt, point_array); } | 366 { return (this+attachList).get_attach_points (glyph_id, start_offset, point_co
unt, point_array); } |
| 362 | 367 |
| 363 inline bool has_lig_carets (void) const { return ligCaretList != 0; } | 368 inline bool has_lig_carets (void) const { return ligCaretList != 0; } |
| 364 inline unsigned int get_lig_carets (hb_font_t *font, | 369 inline unsigned int get_lig_carets (hb_font_t *font, |
| 365 hb_direction_t direction, | 370 hb_direction_t direction, |
| 366 hb_codepoint_t glyph_id, | 371 hb_codepoint_t glyph_id, |
| 367 unsigned int start_offset, | 372 unsigned int start_offset, |
| 368 unsigned int *caret_count /* IN/OUT */, | 373 unsigned int *caret_count /* IN/OUT */, |
| 369 hb_position_t *caret_array /* OUT */) cons
t | 374 hb_position_t *caret_array /* OUT */) cons
t |
| 370 { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_
offset, caret_count, caret_array); } | 375 { return (this+ligCaretList).get_lig_carets (font, |
| 376 » » » » » direction, glyph_id, get_var_stor
e(), |
| 377 » » » » » start_offset, caret_count, caret_
array); } |
| 371 | 378 |
| 372 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000
2u && markGlyphSetsDef[0] != 0; } | 379 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000
2u && markGlyphSetsDef != 0; } |
| 373 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id)
const | 380 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id)
const |
| 374 { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef[0]).covers
(set_index, glyph_id); } | 381 { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef).covers (s
et_index, glyph_id); } |
| 382 |
| 383 inline bool has_var_store (void) const { return version.to_int () >= 0x0001000
3u && varStore != 0; } |
| 384 inline const VariationStore &get_var_store (void) const |
| 385 { return version.to_int () >= 0x00010003u ? this+varStore : Null(VariationStor
e); } |
| 375 | 386 |
| 376 inline bool sanitize (hb_sanitize_context_t *c) const | 387 inline bool sanitize (hb_sanitize_context_t *c) const |
| 377 { | 388 { |
| 378 TRACE_SANITIZE (this); | 389 TRACE_SANITIZE (this); |
| 379 return_trace (version.sanitize (c) && | 390 return_trace (version.sanitize (c) && |
| 380 likely (version.major == 1) && | 391 likely (version.major == 1) && |
| 381 glyphClassDef.sanitize (c, this) && | 392 glyphClassDef.sanitize (c, this) && |
| 382 attachList.sanitize (c, this) && | 393 attachList.sanitize (c, this) && |
| 383 ligCaretList.sanitize (c, this) && | 394 ligCaretList.sanitize (c, this) && |
| 384 markAttachClassDef.sanitize (c, this) && | 395 markAttachClassDef.sanitize (c, this) && |
| 385 » » (version.to_int () < 0x00010002u || markGlyphSetsDef[0].saniti
ze (c, this))); | 396 » » (version.to_int () < 0x00010002u || markGlyphSetsDef.sanitize
(c, this)) && |
| 397 » » (version.to_int () < 0x00010003u || varStore.sanitize (c, this
))); |
| 386 } | 398 } |
| 387 | 399 |
| 388 | |
| 389 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin
g | 400 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin
g |
| 390 * glyph class and other bits, and high 8-bit gthe mark attachment type (if an
y). | 401 * glyph class and other bits, and high 8-bit gthe mark attachment type (if an
y). |
| 391 * Not to be confused with lookup_props which is very similar. */ | 402 * Not to be confused with lookup_props which is very similar. */ |
| 392 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const | 403 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const |
| 393 { | 404 { |
| 394 unsigned int klass = get_glyph_class (glyph); | 405 unsigned int klass = get_glyph_class (glyph); |
| 395 | 406 |
| 396 ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH == (unsign
ed int) LookupFlag::IgnoreBaseGlyphs); | 407 ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH == (unsign
ed int) LookupFlag::IgnoreBaseGlyphs); |
| 397 ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE == (unsigned
int) LookupFlag::IgnoreLigatures); | 408 ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE == (unsigned
int) LookupFlag::IgnoreLigatures); |
| 398 ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_MARK == (unsigned int
) LookupFlag::IgnoreMarks); | 409 ASSERT_STATIC ((unsigned int) HB_OT_LAYOUT_GLYPH_PROPS_MARK == (unsigned int
) LookupFlag::IgnoreMarks); |
| 399 | 410 |
| 400 switch (klass) { | 411 switch (klass) { |
| 401 default: return 0; | 412 default: return 0; |
| 402 case BaseGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH; | 413 case BaseGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH; |
| 403 case LigatureGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE; | 414 case LigatureGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE; |
| 404 case MarkGlyph: | 415 case MarkGlyph: |
| 405 klass = get_mark_attachment_type (glyph); | 416 klass = get_mark_attachment_type (glyph); |
| 406 return HB_OT_LAYOUT_GLYPH_PROPS_MARK | (klass << 8); | 417 return HB_OT_LAYOUT_GLYPH_PROPS_MARK | (klass << 8); |
| 407 } | 418 } |
| 408 } | 419 } |
| 409 | 420 |
| 410 | 421 |
| 411 protected: | 422 protected: |
| 412 FixedVersion<>version; /* Version of the GDEF table--currently | 423 FixedVersion<>version; /* Version of the GDEF table--currently |
| 413 » » » » » * 0x00010002u */ | 424 » » » » » * 0x00010003u */ |
| 414 OffsetTo<ClassDef> | 425 OffsetTo<ClassDef> |
| 415 glyphClassDef; /* Offset to class definition table | 426 glyphClassDef; /* Offset to class definition table |
| 416 * for glyph type--from beginning of | 427 * for glyph type--from beginning of |
| 417 * GDEF header (may be Null) */ | 428 * GDEF header (may be Null) */ |
| 418 OffsetTo<AttachList> | 429 OffsetTo<AttachList> |
| 419 attachList; /* Offset to list of glyphs with | 430 attachList; /* Offset to list of glyphs with |
| 420 * attachment points--from beginning | 431 * attachment points--from beginning |
| 421 * of GDEF header (may be Null) */ | 432 * of GDEF header (may be Null) */ |
| 422 OffsetTo<LigCaretList> | 433 OffsetTo<LigCaretList> |
| 423 ligCaretList; /* Offset to list of positioning points | 434 ligCaretList; /* Offset to list of positioning points |
| 424 * for ligature carets--from beginning | 435 * for ligature carets--from beginning |
| 425 * of GDEF header (may be Null) */ | 436 * of GDEF header (may be Null) */ |
| 426 OffsetTo<ClassDef> | 437 OffsetTo<ClassDef> |
| 427 markAttachClassDef; /* Offset to class definition table for | 438 markAttachClassDef; /* Offset to class definition table for |
| 428 * mark attachment type--from beginning | 439 * mark attachment type--from beginning |
| 429 * of GDEF header (may be Null) */ | 440 * of GDEF header (may be Null) */ |
| 430 OffsetTo<MarkGlyphSets> | 441 OffsetTo<MarkGlyphSets> |
| 431 » » markGlyphSetsDef[VAR];» /* Offset to the table of mark set | 442 » » markGlyphSetsDef;» /* Offset to the table of mark set |
| 432 * definitions--from beginning of GDEF | 443 * definitions--from beginning of GDEF |
| 433 * header (may be NULL). Introduced | 444 * header (may be NULL). Introduced |
| 434 » » » » » * in version 00010002. */ | 445 » » » » » * in version 0x00010002. */ |
| 446 OffsetTo<VariationStore, ULONG> |
| 447 » » varStore;» » /* Offset to the table of Item Variation |
| 448 » » » » » * Store--from beginning of GDEF |
| 449 » » » » » * header (may be NULL). Introduced |
| 450 » » » » » * in version 0x00010003. */ |
| 435 public: | 451 public: |
| 436 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); | 452 DEFINE_SIZE_MIN (12); |
| 437 }; | 453 }; |
| 438 | 454 |
| 439 | 455 |
| 440 } /* namespace OT */ | 456 } /* namespace OT */ |
| 441 | 457 |
| 442 | 458 |
| 443 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */ | 459 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */ |
| OLD | NEW |