OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2007,2008,2009 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009 Red Hat, Inc. |
3 * Copyright © 2010,2011 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 |
11 * all copies of this software. | 11 * all copies of this software. |
12 * | 12 * |
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 unsigned int count = *point_count; | 64 unsigned int count = *point_count; |
65 for (unsigned int i = 0; i < count; i++) | 65 for (unsigned int i = 0; i < count; i++) |
66 point_array[i] = array[i]; | 66 point_array[i] = array[i]; |
67 } | 67 } |
68 | 68 |
69 return points.len; | 69 return points.len; |
70 } | 70 } |
71 | 71 |
72 inline bool sanitize (hb_sanitize_context_t *c) { | 72 inline bool sanitize (hb_sanitize_context_t *c) { |
73 TRACE_SANITIZE (); | 73 TRACE_SANITIZE (); |
74 return coverage.sanitize (c, this) | 74 return TRACE_RETURN (coverage.sanitize (c, this) && attachPoint.sanitize (c,
this)); |
75 » && attachPoint.sanitize (c, this); | |
76 } | 75 } |
77 | 76 |
78 private: | 77 private: |
79 OffsetTo<Coverage> | 78 OffsetTo<Coverage> |
80 coverage; /* Offset to Coverage table -- from | 79 coverage; /* Offset to Coverage table -- from |
81 * beginning of AttachList table */ | 80 * beginning of AttachList table */ |
82 OffsetArrayOf<AttachPoint> | 81 OffsetArrayOf<AttachPoint> |
83 attachPoint; /* Array of AttachPoint tables | 82 attachPoint; /* Array of AttachPoint tables |
84 * in Coverage Index order */ | 83 * in Coverage Index order */ |
85 public: | 84 public: |
86 DEFINE_SIZE_ARRAY (4, attachPoint); | 85 DEFINE_SIZE_ARRAY (4, attachPoint); |
87 }; | 86 }; |
88 | 87 |
89 /* | 88 /* |
90 * Ligature Caret Table | 89 * Ligature Caret Table |
91 */ | 90 */ |
92 | 91 |
93 struct CaretValueFormat1 | 92 struct CaretValueFormat1 |
94 { | 93 { |
95 friend struct CaretValue; | 94 friend struct CaretValue; |
96 | 95 |
97 private: | 96 private: |
98 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id HB_UNUSED) const | 97 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id HB_UNUSED) const |
99 { | 98 { |
100 return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate
) : font->em_scale_y (coordinate); | 99 return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate
) : font->em_scale_y (coordinate); |
101 } | 100 } |
102 | 101 |
103 inline bool sanitize (hb_sanitize_context_t *c) { | 102 inline bool sanitize (hb_sanitize_context_t *c) { |
104 TRACE_SANITIZE (); | 103 TRACE_SANITIZE (); |
105 return c->check_struct (this); | 104 return TRACE_RETURN (c->check_struct (this)); |
106 } | 105 } |
107 | 106 |
108 private: | 107 private: |
109 USHORT caretValueFormat; /* Format identifier--format = 1 */ | 108 USHORT caretValueFormat; /* Format identifier--format = 1 */ |
110 SHORT coordinate; /* X or Y value, in design units */ | 109 SHORT coordinate; /* X or Y value, in design units */ |
111 public: | 110 public: |
112 DEFINE_SIZE_STATIC (4); | 111 DEFINE_SIZE_STATIC (4); |
113 }; | 112 }; |
114 | 113 |
115 struct CaretValueFormat2 | 114 struct CaretValueFormat2 |
116 { | 115 { |
117 friend struct CaretValue; | 116 friend struct CaretValue; |
118 | 117 |
119 private: | 118 private: |
120 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const | 119 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const |
121 { | 120 { |
122 hb_position_t x, y; | 121 hb_position_t x, y; |
123 if (hb_font_get_glyph_contour_point_for_origin (font, glyph_id, caretValuePo
int, direction, &x, &y)) | 122 if (hb_font_get_glyph_contour_point_for_origin (font, glyph_id, caretValuePo
int, direction, &x, &y)) |
124 return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; | 123 return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; |
125 else | 124 else |
126 return 0; | 125 return 0; |
127 } | 126 } |
128 | 127 |
129 inline bool sanitize (hb_sanitize_context_t *c) { | 128 inline bool sanitize (hb_sanitize_context_t *c) { |
130 TRACE_SANITIZE (); | 129 TRACE_SANITIZE (); |
131 return c->check_struct (this); | 130 return TRACE_RETURN (c->check_struct (this)); |
132 } | 131 } |
133 | 132 |
134 private: | 133 private: |
135 USHORT caretValueFormat; /* Format identifier--format = 2 */ | 134 USHORT caretValueFormat; /* Format identifier--format = 2 */ |
136 USHORT caretValuePoint; /* Contour point index on glyph */ | 135 USHORT caretValuePoint; /* Contour point index on glyph */ |
137 public: | 136 public: |
138 DEFINE_SIZE_STATIC (4); | 137 DEFINE_SIZE_STATIC (4); |
139 }; | 138 }; |
140 | 139 |
141 struct CaretValueFormat3 | 140 struct CaretValueFormat3 |
142 { | 141 { |
143 friend struct CaretValue; | 142 friend struct CaretValue; |
144 | 143 |
145 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id HB_UNUSED) const | 144 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id HB_UNUSED) const |
146 { | 145 { |
147 return HB_DIRECTION_IS_HORIZONTAL (direction) ? | 146 return HB_DIRECTION_IS_HORIZONTAL (direction) ? |
148 font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font)
: | 147 font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font)
: |
149 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font)
; | 148 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font)
; |
150 } | 149 } |
151 | 150 |
152 inline bool sanitize (hb_sanitize_context_t *c) { | 151 inline bool sanitize (hb_sanitize_context_t *c) { |
153 TRACE_SANITIZE (); | 152 TRACE_SANITIZE (); |
154 return c->check_struct (this) | 153 return TRACE_RETURN (c->check_struct (this) && deviceTable.sanitize (c, this
)); |
155 » && deviceTable.sanitize (c, this); | |
156 } | 154 } |
157 | 155 |
158 private: | 156 private: |
159 USHORT caretValueFormat; /* Format identifier--format = 3 */ | 157 USHORT caretValueFormat; /* Format identifier--format = 3 */ |
160 SHORT coordinate; /* X or Y value, in design units */ | 158 SHORT coordinate; /* X or Y value, in design units */ |
161 OffsetTo<Device> | 159 OffsetTo<Device> |
162 deviceTable; /* Offset to Device table for X or Y | 160 deviceTable; /* Offset to Device table for X or Y |
163 * value--from beginning of CaretValue | 161 * value--from beginning of CaretValue |
164 * table */ | 162 * table */ |
165 public: | 163 public: |
166 DEFINE_SIZE_STATIC (6); | 164 DEFINE_SIZE_STATIC (6); |
167 }; | 165 }; |
168 | 166 |
169 struct CaretValue | 167 struct CaretValue |
170 { | 168 { |
171 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const | 169 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const |
172 { | 170 { |
173 switch (u.format) { | 171 switch (u.format) { |
174 case 1: return u.format1.get_caret_value (font, direction, glyph_id); | 172 case 1: return u.format1.get_caret_value (font, direction, glyph_id); |
175 case 2: return u.format2.get_caret_value (font, direction, glyph_id); | 173 case 2: return u.format2.get_caret_value (font, direction, glyph_id); |
176 case 3: return u.format3.get_caret_value (font, direction, glyph_id); | 174 case 3: return u.format3.get_caret_value (font, direction, glyph_id); |
177 default:return 0; | 175 default:return 0; |
178 } | 176 } |
179 } | 177 } |
180 | 178 |
181 inline bool sanitize (hb_sanitize_context_t *c) { | 179 inline bool sanitize (hb_sanitize_context_t *c) { |
182 TRACE_SANITIZE (); | 180 TRACE_SANITIZE (); |
183 if (!u.format.sanitize (c)) return false; | 181 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
184 switch (u.format) { | 182 switch (u.format) { |
185 case 1: return u.format1.sanitize (c); | 183 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
186 case 2: return u.format2.sanitize (c); | 184 case 2: return TRACE_RETURN (u.format2.sanitize (c)); |
187 case 3: return u.format3.sanitize (c); | 185 case 3: return TRACE_RETURN (u.format3.sanitize (c)); |
188 default:return true; | 186 default:return TRACE_RETURN (true); |
189 } | 187 } |
190 } | 188 } |
191 | 189 |
192 private: | 190 private: |
193 union { | 191 union { |
194 USHORT format; /* Format identifier */ | 192 USHORT format; /* Format identifier */ |
195 CaretValueFormat1 format1; | 193 CaretValueFormat1 format1; |
196 CaretValueFormat2 format2; | 194 CaretValueFormat2 format2; |
197 CaretValueFormat3 format3; | 195 CaretValueFormat3 format3; |
198 } u; | 196 } u; |
(...skipping 15 matching lines...) Expand all Loading... |
214 unsigned int count = *caret_count; | 212 unsigned int count = *caret_count; |
215 for (unsigned int i = 0; i < count; i++) | 213 for (unsigned int i = 0; i < count; i++) |
216 caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph
_id); | 214 caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph
_id); |
217 } | 215 } |
218 | 216 |
219 return carets.len; | 217 return carets.len; |
220 } | 218 } |
221 | 219 |
222 inline bool sanitize (hb_sanitize_context_t *c) { | 220 inline bool sanitize (hb_sanitize_context_t *c) { |
223 TRACE_SANITIZE (); | 221 TRACE_SANITIZE (); |
224 return carets.sanitize (c, this); | 222 return TRACE_RETURN (carets.sanitize (c, this)); |
225 } | 223 } |
226 | 224 |
227 private: | 225 private: |
228 OffsetArrayOf<CaretValue> | 226 OffsetArrayOf<CaretValue> |
229 carets; /* Offset array of CaretValue tables | 227 carets; /* Offset array of CaretValue tables |
230 * --from beginning of LigGlyph table | 228 * --from beginning of LigGlyph table |
231 * --in increasing coordinate order */ | 229 * --in increasing coordinate order */ |
232 public: | 230 public: |
233 DEFINE_SIZE_ARRAY (2, carets); | 231 DEFINE_SIZE_ARRAY (2, carets); |
234 }; | 232 }; |
(...skipping 13 matching lines...) Expand all Loading... |
248 if (caret_count) | 246 if (caret_count) |
249 *caret_count = 0; | 247 *caret_count = 0; |
250 return 0; | 248 return 0; |
251 } | 249 } |
252 const LigGlyph &lig_glyph = this+ligGlyph[index]; | 250 const LigGlyph &lig_glyph = this+ligGlyph[index]; |
253 return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, ca
ret_count, caret_array); | 251 return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, ca
ret_count, caret_array); |
254 } | 252 } |
255 | 253 |
256 inline bool sanitize (hb_sanitize_context_t *c) { | 254 inline bool sanitize (hb_sanitize_context_t *c) { |
257 TRACE_SANITIZE (); | 255 TRACE_SANITIZE (); |
258 return coverage.sanitize (c, this) | 256 return TRACE_RETURN (coverage.sanitize (c, this) && ligGlyph.sanitize (c, th
is)); |
259 » && ligGlyph.sanitize (c, this); | |
260 } | 257 } |
261 | 258 |
262 private: | 259 private: |
263 OffsetTo<Coverage> | 260 OffsetTo<Coverage> |
264 coverage; /* Offset to Coverage table--from | 261 coverage; /* Offset to Coverage table--from |
265 * beginning of LigCaretList table */ | 262 * beginning of LigCaretList table */ |
266 OffsetArrayOf<LigGlyph> | 263 OffsetArrayOf<LigGlyph> |
267 ligGlyph; /* Array of LigGlyph tables | 264 ligGlyph; /* Array of LigGlyph tables |
268 * in Coverage Index order */ | 265 * in Coverage Index order */ |
269 public: | 266 public: |
270 DEFINE_SIZE_ARRAY (4, ligGlyph); | 267 DEFINE_SIZE_ARRAY (4, ligGlyph); |
271 }; | 268 }; |
272 | 269 |
273 | 270 |
274 struct MarkGlyphSetsFormat1 | 271 struct MarkGlyphSetsFormat1 |
275 { | 272 { |
276 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const | 273 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const |
277 { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } | 274 { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } |
278 | 275 |
279 inline bool sanitize (hb_sanitize_context_t *c) { | 276 inline bool sanitize (hb_sanitize_context_t *c) { |
280 TRACE_SANITIZE (); | 277 TRACE_SANITIZE (); |
281 return coverage.sanitize (c, this); | 278 return TRACE_RETURN (coverage.sanitize (c, this)); |
282 } | 279 } |
283 | 280 |
284 private: | 281 private: |
285 USHORT format; /* Format identifier--format = 1 */ | 282 USHORT format; /* Format identifier--format = 1 */ |
286 LongOffsetArrayOf<Coverage> | 283 LongOffsetArrayOf<Coverage> |
287 coverage; /* Array of long offsets to mark set | 284 coverage; /* Array of long offsets to mark set |
288 * coverage tables */ | 285 * coverage tables */ |
289 public: | 286 public: |
290 DEFINE_SIZE_ARRAY (4, coverage); | 287 DEFINE_SIZE_ARRAY (4, coverage); |
291 }; | 288 }; |
292 | 289 |
293 struct MarkGlyphSets | 290 struct MarkGlyphSets |
294 { | 291 { |
295 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const | 292 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const |
296 { | 293 { |
297 switch (u.format) { | 294 switch (u.format) { |
298 case 1: return u.format1.covers (set_index, glyph_id); | 295 case 1: return u.format1.covers (set_index, glyph_id); |
299 default:return false; | 296 default:return false; |
300 } | 297 } |
301 } | 298 } |
302 | 299 |
303 inline bool sanitize (hb_sanitize_context_t *c) { | 300 inline bool sanitize (hb_sanitize_context_t *c) { |
304 TRACE_SANITIZE (); | 301 TRACE_SANITIZE (); |
305 if (!u.format.sanitize (c)) return false; | 302 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
306 switch (u.format) { | 303 switch (u.format) { |
307 case 1: return u.format1.sanitize (c); | 304 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
308 default:return true; | 305 default:return TRACE_RETURN (true); |
309 } | 306 } |
310 } | 307 } |
311 | 308 |
312 private: | 309 private: |
313 union { | 310 union { |
314 USHORT format; /* Format identifier */ | 311 USHORT format; /* Format identifier */ |
315 MarkGlyphSetsFormat1 format1; | 312 MarkGlyphSetsFormat1 format1; |
316 } u; | 313 } u; |
317 public: | 314 public: |
318 DEFINE_SIZE_UNION (2, format); | 315 DEFINE_SIZE_UNION (2, format); |
319 }; | 316 }; |
320 | 317 |
321 | 318 |
322 /* | 319 /* |
323 * GDEF -- The Glyph Definition Table | 320 * GDEF -- The Glyph Definition Table |
324 */ | 321 */ |
325 | 322 |
326 struct GDEF | 323 struct GDEF |
327 { | 324 { |
328 static const hb_tag_t Tag = HB_OT_TAG_GDEF; | 325 static const hb_tag_t Tag = HB_OT_TAG_GDEF; |
329 | 326 |
330 enum { | 327 enum GlyphClasses { |
331 UnclassifiedGlyph = 0, | 328 UnclassifiedGlyph = 0, |
332 BaseGlyph = 1, | 329 BaseGlyph = 1, |
333 LigatureGlyph = 2, | 330 LigatureGlyph = 2, |
334 MarkGlyph = 3, | 331 MarkGlyph = 3, |
335 ComponentGlyph = 4 | 332 ComponentGlyph = 4 |
336 }; | 333 }; |
337 | 334 |
338 inline bool has_glyph_classes (void) const { return glyphClassDef != 0; } | 335 inline bool has_glyph_classes (void) const { return glyphClassDef != 0; } |
339 inline unsigned int get_glyph_class (hb_codepoint_t glyph) const | 336 inline unsigned int get_glyph_class (hb_codepoint_t glyph) const |
340 { return (this+glyphClassDef).get_class (glyph); } | 337 { return (this+glyphClassDef).get_class (glyph); } |
(...skipping 17 matching lines...) Expand all Loading... |
358 unsigned int *caret_count /* IN/OUT */, | 355 unsigned int *caret_count /* IN/OUT */, |
359 hb_position_t *caret_array /* OUT */) cons
t | 356 hb_position_t *caret_array /* OUT */) cons
t |
360 { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_
offset, caret_count, caret_array); } | 357 { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_
offset, caret_count, caret_array); } |
361 | 358 |
362 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000
2 && markGlyphSetsDef[0] != 0; } | 359 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000
2 && markGlyphSetsDef[0] != 0; } |
363 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id)
const | 360 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id)
const |
364 { return version.to_int () >= 0x00010002 && (this+markGlyphSetsDef[0]).covers
(set_index, glyph_id); } | 361 { return version.to_int () >= 0x00010002 && (this+markGlyphSetsDef[0]).covers
(set_index, glyph_id); } |
365 | 362 |
366 inline bool sanitize (hb_sanitize_context_t *c) { | 363 inline bool sanitize (hb_sanitize_context_t *c) { |
367 TRACE_SANITIZE (); | 364 TRACE_SANITIZE (); |
368 return version.sanitize (c) && likely (version.major == 1) | 365 return TRACE_RETURN (version.sanitize (c) && |
369 » && glyphClassDef.sanitize (c, this) | 366 » » » likely (version.major == 1) && |
370 » && attachList.sanitize (c, this) | 367 » » » glyphClassDef.sanitize (c, this) && |
371 » && ligCaretList.sanitize (c, this) | 368 » » » attachList.sanitize (c, this) && |
372 » && markAttachClassDef.sanitize (c, this) | 369 » » » ligCaretList.sanitize (c, this) && |
373 » && (version.to_int () < 0x00010002 || markGlyphSetsDef[0].sanitize (c, t
his)); | 370 » » » markAttachClassDef.sanitize (c, this) && |
| 371 » » » (version.to_int () < 0x00010002 || markGlyphSetsDef[0].
sanitize (c, this))); |
374 } | 372 } |
375 | 373 |
376 | 374 |
377 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin
g | 375 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin
g |
378 * glyph class and other bits, and high 8-bit gthe mark attachment type (if an
y). | 376 * glyph class and other bits, and high 8-bit gthe mark attachment type (if an
y). |
379 * Not to be confused with lookup_props which is very similar. */ | 377 * Not to be confused with lookup_props which is very similar. */ |
380 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const | 378 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const |
381 { | 379 { |
382 unsigned int klass = get_glyph_class (glyph); | 380 unsigned int klass = get_glyph_class (glyph); |
383 | 381 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 * definitions--from beginning of GDEF | 416 * definitions--from beginning of GDEF |
419 * header (may be NULL). Introduced | 417 * header (may be NULL). Introduced |
420 * in version 00010002. */ | 418 * in version 00010002. */ |
421 public: | 419 public: |
422 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); | 420 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); |
423 }; | 421 }; |
424 | 422 |
425 | 423 |
426 | 424 |
427 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */ | 425 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */ |
OLD | NEW |