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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 for (unsigned int i = 0; i < count; i++) | 67 for (unsigned int i = 0; i < count; i++) |
68 point_array[i] = array[i]; | 68 point_array[i] = array[i]; |
69 } | 69 } |
70 | 70 |
71 return points.len; | 71 return points.len; |
72 } | 72 } |
73 | 73 |
74 inline bool sanitize (hb_sanitize_context_t *c) const | 74 inline bool sanitize (hb_sanitize_context_t *c) const |
75 { | 75 { |
76 TRACE_SANITIZE (this); | 76 TRACE_SANITIZE (this); |
77 return TRACE_RETURN (coverage.sanitize (c, this) && attachPoint.sanitize (c,
this)); | 77 return_trace (coverage.sanitize (c, this) && attachPoint.sanitize (c, this))
; |
78 } | 78 } |
79 | 79 |
80 protected: | 80 protected: |
81 OffsetTo<Coverage> | 81 OffsetTo<Coverage> |
82 coverage; /* Offset to Coverage table -- from | 82 coverage; /* Offset to Coverage table -- from |
83 * beginning of AttachList table */ | 83 * beginning of AttachList table */ |
84 OffsetArrayOf<AttachPoint> | 84 OffsetArrayOf<AttachPoint> |
85 attachPoint; /* Array of AttachPoint tables | 85 attachPoint; /* Array of AttachPoint tables |
86 * in Coverage Index order */ | 86 * in Coverage Index order */ |
87 public: | 87 public: |
(...skipping 10 matching lines...) Expand all Loading... |
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, hb_codepoint_t glyph_id HB_UNUSED) 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_RETURN (c->check_struct (this)); | 108 return_trace (c->check_struct (this)); |
109 } | 109 } |
110 | 110 |
111 protected: | 111 protected: |
112 USHORT caretValueFormat; /* Format identifier--format = 1 */ | 112 USHORT caretValueFormat; /* Format identifier--format = 1 */ |
113 SHORT coordinate; /* X or Y value, in design units */ | 113 SHORT coordinate; /* X or Y value, in design units */ |
114 public: | 114 public: |
115 DEFINE_SIZE_STATIC (4); | 115 DEFINE_SIZE_STATIC (4); |
116 }; | 116 }; |
117 | 117 |
118 struct CaretValueFormat2 | 118 struct CaretValueFormat2 |
119 { | 119 { |
120 friend struct CaretValue; | 120 friend struct CaretValue; |
121 | 121 |
122 private: | 122 private: |
123 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const | 123 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio
n, hb_codepoint_t glyph_id) const |
124 { | 124 { |
125 hb_position_t x, y; | 125 hb_position_t x, y; |
126 if (font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, dir
ection, &x, &y)) | 126 if (font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, dir
ection, &x, &y)) |
127 return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; | 127 return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; |
128 else | 128 else |
129 return 0; | 129 return 0; |
130 } | 130 } |
131 | 131 |
132 inline bool sanitize (hb_sanitize_context_t *c) const | 132 inline bool sanitize (hb_sanitize_context_t *c) const |
133 { | 133 { |
134 TRACE_SANITIZE (this); | 134 TRACE_SANITIZE (this); |
135 return TRACE_RETURN (c->check_struct (this)); | 135 return_trace (c->check_struct (this)); |
136 } | 136 } |
137 | 137 |
138 protected: | 138 protected: |
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, hb_codepoint_t glyph_id HB_UNUSED) 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)
: |
153 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font)
; | 153 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font)
; |
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_RETURN (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, hb_direction_t directio
n, hb_codepoint_t glyph_id) const |
176 { | 176 { |
177 switch (u.format) { | 177 switch (u.format) { |
178 case 1: return u.format1.get_caret_value (font, direction, glyph_id); | 178 case 1: return u.format1.get_caret_value (font, direction, glyph_id); |
179 case 2: return u.format2.get_caret_value (font, direction, glyph_id); | 179 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); | 180 case 3: return u.format3.get_caret_value (font, direction, glyph_id); |
181 default:return 0; | 181 default:return 0; |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 inline bool sanitize (hb_sanitize_context_t *c) const | 185 inline bool sanitize (hb_sanitize_context_t *c) const |
186 { | 186 { |
187 TRACE_SANITIZE (this); | 187 TRACE_SANITIZE (this); |
188 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 188 if (!u.format.sanitize (c)) return_trace (false); |
189 switch (u.format) { | 189 switch (u.format) { |
190 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 190 case 1: return_trace (u.format1.sanitize (c)); |
191 case 2: return TRACE_RETURN (u.format2.sanitize (c)); | 191 case 2: return_trace (u.format2.sanitize (c)); |
192 case 3: return TRACE_RETURN (u.format3.sanitize (c)); | 192 case 3: return_trace (u.format3.sanitize (c)); |
193 default:return TRACE_RETURN (true); | 193 default:return_trace (true); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 protected: | 197 protected: |
198 union { | 198 union { |
199 USHORT format; /* Format identifier */ | 199 USHORT format; /* Format identifier */ |
200 CaretValueFormat1 format1; | 200 CaretValueFormat1 format1; |
201 CaretValueFormat2 format2; | 201 CaretValueFormat2 format2; |
202 CaretValueFormat3 format3; | 202 CaretValueFormat3 format3; |
203 } u; | 203 } u; |
(...skipping 16 matching lines...) Expand all Loading... |
220 for (unsigned int i = 0; i < count; i++) | 220 for (unsigned int i = 0; i < count; i++) |
221 caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph
_id); | 221 caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph
_id); |
222 } | 222 } |
223 | 223 |
224 return carets.len; | 224 return carets.len; |
225 } | 225 } |
226 | 226 |
227 inline bool sanitize (hb_sanitize_context_t *c) const | 227 inline bool sanitize (hb_sanitize_context_t *c) const |
228 { | 228 { |
229 TRACE_SANITIZE (this); | 229 TRACE_SANITIZE (this); |
230 return TRACE_RETURN (carets.sanitize (c, this)); | 230 return_trace (carets.sanitize (c, this)); |
231 } | 231 } |
232 | 232 |
233 protected: | 233 protected: |
234 OffsetArrayOf<CaretValue> | 234 OffsetArrayOf<CaretValue> |
235 carets; /* Offset array of CaretValue tables | 235 carets; /* Offset array of CaretValue tables |
236 * --from beginning of LigGlyph table | 236 * --from beginning of LigGlyph table |
237 * --in increasing coordinate order */ | 237 * --in increasing coordinate order */ |
238 public: | 238 public: |
239 DEFINE_SIZE_ARRAY (2, carets); | 239 DEFINE_SIZE_ARRAY (2, carets); |
240 }; | 240 }; |
(...skipping 14 matching lines...) Expand all Loading... |
255 *caret_count = 0; | 255 *caret_count = 0; |
256 return 0; | 256 return 0; |
257 } | 257 } |
258 const LigGlyph &lig_glyph = this+ligGlyph[index]; | 258 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); | 259 return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, ca
ret_count, caret_array); |
260 } | 260 } |
261 | 261 |
262 inline bool sanitize (hb_sanitize_context_t *c) const | 262 inline bool sanitize (hb_sanitize_context_t *c) const |
263 { | 263 { |
264 TRACE_SANITIZE (this); | 264 TRACE_SANITIZE (this); |
265 return TRACE_RETURN (coverage.sanitize (c, this) && ligGlyph.sanitize (c, th
is)); | 265 return_trace (coverage.sanitize (c, this) && ligGlyph.sanitize (c, this)); |
266 } | 266 } |
267 | 267 |
268 protected: | 268 protected: |
269 OffsetTo<Coverage> | 269 OffsetTo<Coverage> |
270 coverage; /* Offset to Coverage table--from | 270 coverage; /* Offset to Coverage table--from |
271 * beginning of LigCaretList table */ | 271 * beginning of LigCaretList table */ |
272 OffsetArrayOf<LigGlyph> | 272 OffsetArrayOf<LigGlyph> |
273 ligGlyph; /* Array of LigGlyph tables | 273 ligGlyph; /* Array of LigGlyph tables |
274 * in Coverage Index order */ | 274 * in Coverage Index order */ |
275 public: | 275 public: |
276 DEFINE_SIZE_ARRAY (4, ligGlyph); | 276 DEFINE_SIZE_ARRAY (4, ligGlyph); |
277 }; | 277 }; |
278 | 278 |
279 | 279 |
280 struct MarkGlyphSetsFormat1 | 280 struct MarkGlyphSetsFormat1 |
281 { | 281 { |
282 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const | 282 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const |
283 { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } | 283 { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } |
284 | 284 |
285 inline bool sanitize (hb_sanitize_context_t *c) const | 285 inline bool sanitize (hb_sanitize_context_t *c) const |
286 { | 286 { |
287 TRACE_SANITIZE (this); | 287 TRACE_SANITIZE (this); |
288 return TRACE_RETURN (coverage.sanitize (c, this)); | 288 return_trace (coverage.sanitize (c, this)); |
289 } | 289 } |
290 | 290 |
291 protected: | 291 protected: |
292 USHORT format; /* Format identifier--format = 1 */ | 292 USHORT format; /* Format identifier--format = 1 */ |
293 ArrayOf<OffsetTo<Coverage, ULONG> > | 293 ArrayOf<OffsetTo<Coverage, ULONG> > |
294 coverage; /* Array of long offsets to mark set | 294 coverage; /* Array of long offsets to mark set |
295 * coverage tables */ | 295 * coverage tables */ |
296 public: | 296 public: |
297 DEFINE_SIZE_ARRAY (4, coverage); | 297 DEFINE_SIZE_ARRAY (4, coverage); |
298 }; | 298 }; |
299 | 299 |
300 struct MarkGlyphSets | 300 struct MarkGlyphSets |
301 { | 301 { |
302 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const | 302 inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const |
303 { | 303 { |
304 switch (u.format) { | 304 switch (u.format) { |
305 case 1: return u.format1.covers (set_index, glyph_id); | 305 case 1: return u.format1.covers (set_index, glyph_id); |
306 default:return false; | 306 default:return false; |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 inline bool sanitize (hb_sanitize_context_t *c) const | 310 inline bool sanitize (hb_sanitize_context_t *c) const |
311 { | 311 { |
312 TRACE_SANITIZE (this); | 312 TRACE_SANITIZE (this); |
313 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 313 if (!u.format.sanitize (c)) return_trace (false); |
314 switch (u.format) { | 314 switch (u.format) { |
315 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 315 case 1: return_trace (u.format1.sanitize (c)); |
316 default:return TRACE_RETURN (true); | 316 default:return_trace (true); |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 protected: | 320 protected: |
321 union { | 321 union { |
322 USHORT format; /* Format identifier */ | 322 USHORT format; /* Format identifier */ |
323 MarkGlyphSetsFormat1 format1; | 323 MarkGlyphSetsFormat1 format1; |
324 } u; | 324 } u; |
325 public: | 325 public: |
326 DEFINE_SIZE_UNION (2, format); | 326 DEFINE_SIZE_UNION (2, format); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 hb_position_t *caret_array /* OUT */) cons
t | 369 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); } | 370 { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_
offset, caret_count, caret_array); } |
371 | 371 |
372 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000
2u && markGlyphSetsDef[0] != 0; } | 372 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000
2u && markGlyphSetsDef[0] != 0; } |
373 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id)
const | 373 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); } | 374 { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef[0]).covers
(set_index, glyph_id); } |
375 | 375 |
376 inline bool sanitize (hb_sanitize_context_t *c) const | 376 inline bool sanitize (hb_sanitize_context_t *c) const |
377 { | 377 { |
378 TRACE_SANITIZE (this); | 378 TRACE_SANITIZE (this); |
379 return TRACE_RETURN (version.sanitize (c) && | 379 return_trace (version.sanitize (c) && |
380 » » » likely (version.major == 1) && | 380 » » likely (version.major == 1) && |
381 » » » glyphClassDef.sanitize (c, this) && | 381 » » glyphClassDef.sanitize (c, this) && |
382 » » » attachList.sanitize (c, this) && | 382 » » attachList.sanitize (c, this) && |
383 » » » ligCaretList.sanitize (c, this) && | 383 » » ligCaretList.sanitize (c, this) && |
384 » » » markAttachClassDef.sanitize (c, this) && | 384 » » markAttachClassDef.sanitize (c, this) && |
385 » » » (version.to_int () < 0x00010002u || markGlyphSetsDef[0]
.sanitize (c, this))); | 385 » » (version.to_int () < 0x00010002u || markGlyphSetsDef[0].saniti
ze (c, this))); |
386 } | 386 } |
387 | 387 |
388 | 388 |
389 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin
g | 389 /* 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). | 390 * 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. */ | 391 * Not to be confused with lookup_props which is very similar. */ |
392 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const | 392 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const |
393 { | 393 { |
394 unsigned int klass = get_glyph_class (glyph); | 394 unsigned int klass = get_glyph_class (glyph); |
395 | 395 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 * in version 00010002. */ | 434 * in version 00010002. */ |
435 public: | 435 public: |
436 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); | 436 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); |
437 }; | 437 }; |
438 | 438 |
439 | 439 |
440 } /* namespace OT */ | 440 } /* namespace OT */ |
441 | 441 |
442 | 442 |
443 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */ | 443 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */ |
OLD | NEW |