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

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

Issue 9223010: Update harfbuzz-ng to 1a5a91dc0d8bf4b72a2f22dc6300b06ad7000b79. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't use -M option for 'git diff' to patch correctly Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007,2008,2009 Red Hat, Inc. 2 * Copyright © 2007,2008,2009 Red Hat, Inc.
3 * Copyright (C) 2010 Google, Inc. 3 * Copyright © 2010,2011 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
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE. 17 * DAMAGE.
18 * 18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * 24 *
25 * Red Hat Author(s): Behdad Esfahbod 25 * Red Hat Author(s): Behdad Esfahbod
26 * Google Author(s): Behdad Esfahbod 26 * Google Author(s): Behdad Esfahbod
27 */ 27 */
28 28
29 #ifndef HB_OT_LAYOUT_GDEF_PRIVATE_HH 29 #ifndef HB_OT_LAYOUT_GDEF_TABLE_HH
30 #define HB_OT_LAYOUT_GDEF_PRIVATE_HH 30 #define HB_OT_LAYOUT_GDEF_TABLE_HH
31 31
32 #include "hb-ot-layout-common-private.hh" 32 #include "hb-ot-layout-common-private.hh"
33 33
34 #include "hb-font-private.h" 34 #include "hb-font-private.hh"
35 35
36 HB_BEGIN_DECLS
37 36
38 37
39 /* 38 /*
40 * Attachment List Table 39 * Attachment List Table
41 */ 40 */
42 41
43 typedef ArrayOf<USHORT> AttachPoint; /* Array of contour point indices--in 42 typedef ArrayOf<USHORT> AttachPoint; /* Array of contour point indices--in
44 * increasing numerical order */ 43 * increasing numerical order */
45 44
46 struct AttachList 45 struct AttachList
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 88
90 /* 89 /*
91 * Ligature Caret Table 90 * Ligature Caret Table
92 */ 91 */
93 92
94 struct CaretValueFormat1 93 struct CaretValueFormat1
95 { 94 {
96 friend struct CaretValue; 95 friend struct CaretValue;
97 96
98 private: 97 private:
99 inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t directio n, hb_codepoint_t glyph_id HB_UNUSED) const 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
100 { 99 {
101 return HB_DIRECTION_IS_HORIZONTAL (direction) ? c->scale_x (coordinate) : c- >scale_y (coordinate); 100 return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate ) : font->em_scale_y (coordinate);
102 } 101 }
103 102
104 inline bool sanitize (hb_sanitize_context_t *c) { 103 inline bool sanitize (hb_sanitize_context_t *c) {
105 TRACE_SANITIZE (); 104 TRACE_SANITIZE ();
106 return c->check_struct (this); 105 return c->check_struct (this);
107 } 106 }
108 107
109 private: 108 private:
110 USHORT caretValueFormat; /* Format identifier--format = 1 */ 109 USHORT caretValueFormat; /* Format identifier--format = 1 */
111 SHORT coordinate; /* X or Y value, in design units */ 110 SHORT coordinate; /* X or Y value, in design units */
112 public: 111 public:
113 DEFINE_SIZE_STATIC (4); 112 DEFINE_SIZE_STATIC (4);
114 }; 113 };
115 114
116 struct CaretValueFormat2 115 struct CaretValueFormat2
117 { 116 {
118 friend struct CaretValue; 117 friend struct CaretValue;
119 118
120 private: 119 private:
121 inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t directio n, hb_codepoint_t glyph_id) const 120 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio n, hb_codepoint_t glyph_id) const
122 { 121 {
123 hb_position_t x, y; 122 hb_position_t x, y;
124 if (hb_font_get_contour_point (c->font, c->face, caretValuePoint, glyph_id, &x, &y)) 123 if (hb_font_get_glyph_contour_point_for_origin (font, glyph_id, caretValuePo int, direction, &x, &y))
125 return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; 124 return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
126 else 125 else
127 return 0; 126 return 0;
128 } 127 }
129 128
130 inline bool sanitize (hb_sanitize_context_t *c) { 129 inline bool sanitize (hb_sanitize_context_t *c) {
131 TRACE_SANITIZE (); 130 TRACE_SANITIZE ();
132 return c->check_struct (this); 131 return c->check_struct (this);
133 } 132 }
134 133
135 private: 134 private:
136 USHORT caretValueFormat; /* Format identifier--format = 2 */ 135 USHORT caretValueFormat; /* Format identifier--format = 2 */
137 USHORT caretValuePoint; /* Contour point index on glyph */ 136 USHORT caretValuePoint; /* Contour point index on glyph */
138 public: 137 public:
139 DEFINE_SIZE_STATIC (4); 138 DEFINE_SIZE_STATIC (4);
140 }; 139 };
141 140
142 struct CaretValueFormat3 141 struct CaretValueFormat3
143 { 142 {
144 friend struct CaretValue; 143 friend struct CaretValue;
145 144
146 inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t directio n, hb_codepoint_t glyph_id) const 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
147 { 146 {
148 return HB_DIRECTION_IS_HORIZONTAL (direction) ? 147 return HB_DIRECTION_IS_HORIZONTAL (direction) ?
149 c->scale_x (coordinate) + (this+deviceTable).get_x_delta (c) : 148 font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font) :
150 c->scale_y (coordinate) + (this+deviceTable).get_y_delta (c); 149 font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font) ;
151 } 150 }
152 151
153 inline bool sanitize (hb_sanitize_context_t *c) { 152 inline bool sanitize (hb_sanitize_context_t *c) {
154 TRACE_SANITIZE (); 153 TRACE_SANITIZE ();
155 return c->check_struct (this) 154 return c->check_struct (this)
156 && deviceTable.sanitize (c, this); 155 && deviceTable.sanitize (c, this);
157 } 156 }
158 157
159 private: 158 private:
160 USHORT caretValueFormat; /* Format identifier--format = 3 */ 159 USHORT caretValueFormat; /* Format identifier--format = 3 */
161 SHORT coordinate; /* X or Y value, in design units */ 160 SHORT coordinate; /* X or Y value, in design units */
162 OffsetTo<Device> 161 OffsetTo<Device>
163 deviceTable; /* Offset to Device table for X or Y 162 deviceTable; /* Offset to Device table for X or Y
164 * value--from beginning of CaretValue 163 * value--from beginning of CaretValue
165 * table */ 164 * table */
166 public: 165 public:
167 DEFINE_SIZE_STATIC (6); 166 DEFINE_SIZE_STATIC (6);
168 }; 167 };
169 168
170 struct CaretValue 169 struct CaretValue
171 { 170 {
172 inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t directio n, hb_codepoint_t glyph_id) const 171 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t directio n, hb_codepoint_t glyph_id) const
173 { 172 {
174 switch (u.format) { 173 switch (u.format) {
175 case 1: return u.format1.get_caret_value (c, direction, glyph_id); 174 case 1: return u.format1.get_caret_value (font, direction, glyph_id);
176 case 2: return u.format2.get_caret_value (c, direction, glyph_id); 175 case 2: return u.format2.get_caret_value (font, direction, glyph_id);
177 case 3: return u.format3.get_caret_value (c, direction, glyph_id); 176 case 3: return u.format3.get_caret_value (font, direction, glyph_id);
178 default:return 0; 177 default:return 0;
179 } 178 }
180 } 179 }
181 180
182 inline bool sanitize (hb_sanitize_context_t *c) { 181 inline bool sanitize (hb_sanitize_context_t *c) {
183 TRACE_SANITIZE (); 182 TRACE_SANITIZE ();
184 if (!u.format.sanitize (c)) return false; 183 if (!u.format.sanitize (c)) return false;
185 switch (u.format) { 184 switch (u.format) {
186 case 1: return u.format1.sanitize (c); 185 case 1: return u.format1.sanitize (c);
187 case 2: return u.format2.sanitize (c); 186 case 2: return u.format2.sanitize (c);
188 case 3: return u.format3.sanitize (c); 187 case 3: return u.format3.sanitize (c);
189 default:return true; 188 default:return true;
190 } 189 }
191 } 190 }
192 191
193 private: 192 private:
194 union { 193 union {
195 USHORT format; /* Format identifier */ 194 USHORT format; /* Format identifier */
196 CaretValueFormat1 format1; 195 CaretValueFormat1 format1;
197 CaretValueFormat2 format2; 196 CaretValueFormat2 format2;
198 CaretValueFormat3 format3; 197 CaretValueFormat3 format3;
199 } u; 198 } u;
200 public: 199 public:
201 DEFINE_SIZE_UNION (2, format); 200 DEFINE_SIZE_UNION (2, format);
202 }; 201 };
203 202
204 struct LigGlyph 203 struct LigGlyph
205 { 204 {
206 inline unsigned int get_lig_carets (hb_ot_layout_context_t *c, 205 inline unsigned int get_lig_carets (hb_font_t *font,
207 hb_direction_t direction, 206 hb_direction_t direction,
208 hb_codepoint_t glyph_id, 207 hb_codepoint_t glyph_id,
209 unsigned int start_offset, 208 unsigned int start_offset,
210 unsigned int *caret_count /* IN/OUT */, 209 unsigned int *caret_count /* IN/OUT */,
211 » » » » int *caret_array /* OUT */) const 210 » » » » hb_position_t *caret_array /* OUT */) cons t
212 { 211 {
213 if (caret_count) { 212 if (caret_count) {
214 const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_ count); 213 const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_ count);
215 unsigned int count = *caret_count; 214 unsigned int count = *caret_count;
216 for (unsigned int i = 0; i < count; i++) 215 for (unsigned int i = 0; i < count; i++)
217 » caret_array[i] = (this+array[i]).get_caret_value (c, direction, glyph_id ); 216 » caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph _id);
218 } 217 }
219 218
220 return carets.len; 219 return carets.len;
221 } 220 }
222 221
223 inline bool sanitize (hb_sanitize_context_t *c) { 222 inline bool sanitize (hb_sanitize_context_t *c) {
224 TRACE_SANITIZE (); 223 TRACE_SANITIZE ();
225 return carets.sanitize (c, this); 224 return carets.sanitize (c, this);
226 } 225 }
227 226
228 private: 227 private:
229 OffsetArrayOf<CaretValue> 228 OffsetArrayOf<CaretValue>
230 carets; /* Offset array of CaretValue tables 229 carets; /* Offset array of CaretValue tables
231 * --from beginning of LigGlyph table 230 * --from beginning of LigGlyph table
232 * --in increasing coordinate order */ 231 * --in increasing coordinate order */
233 public: 232 public:
234 DEFINE_SIZE_ARRAY (2, carets); 233 DEFINE_SIZE_ARRAY (2, carets);
235 }; 234 };
236 235
237 struct LigCaretList 236 struct LigCaretList
238 { 237 {
239 inline unsigned int get_lig_carets (hb_ot_layout_context_t *c, 238 inline unsigned int get_lig_carets (hb_font_t *font,
240 hb_direction_t direction, 239 hb_direction_t direction,
241 hb_codepoint_t glyph_id, 240 hb_codepoint_t glyph_id,
242 unsigned int start_offset, 241 unsigned int start_offset,
243 unsigned int *caret_count /* IN/OUT */, 242 unsigned int *caret_count /* IN/OUT */,
244 » » » » int *caret_array /* OUT */) const 243 » » » » hb_position_t *caret_array /* OUT */) cons t
245 { 244 {
246 unsigned int index = (this+coverage) (glyph_id); 245 unsigned int index = (this+coverage) (glyph_id);
247 if (index == NOT_COVERED) 246 if (index == NOT_COVERED)
248 { 247 {
249 if (caret_count) 248 if (caret_count)
250 *caret_count = 0; 249 *caret_count = 0;
251 return 0; 250 return 0;
252 } 251 }
253 const LigGlyph &lig_glyph = this+ligGlyph[index]; 252 const LigGlyph &lig_glyph = this+ligGlyph[index];
254 return lig_glyph.get_lig_carets (c, direction, glyph_id, start_offset, caret _count, caret_array); 253 return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, ca ret_count, caret_array);
255 } 254 }
256 255
257 inline bool sanitize (hb_sanitize_context_t *c) { 256 inline bool sanitize (hb_sanitize_context_t *c) {
258 TRACE_SANITIZE (); 257 TRACE_SANITIZE ();
259 return coverage.sanitize (c, this) 258 return coverage.sanitize (c, this)
260 && ligGlyph.sanitize (c, this); 259 && ligGlyph.sanitize (c, this);
261 } 260 }
262 261
263 private: 262 private:
264 OffsetTo<Coverage> 263 OffsetTo<Coverage>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 union { 313 union {
315 USHORT format; /* Format identifier */ 314 USHORT format; /* Format identifier */
316 MarkGlyphSetsFormat1 format1; 315 MarkGlyphSetsFormat1 format1;
317 } u; 316 } u;
318 public: 317 public:
319 DEFINE_SIZE_UNION (2, format); 318 DEFINE_SIZE_UNION (2, format);
320 }; 319 };
321 320
322 321
323 /* 322 /*
324 * GDEF 323 * GDEF -- The Glyph Definition Table
325 */ 324 */
326 325
327 struct GDEF 326 struct GDEF
328 { 327 {
329 static const hb_tag_t Tag = HB_OT_TAG_GDEF; 328 static const hb_tag_t Tag = HB_OT_TAG_GDEF;
330 329
331 enum { 330 enum {
332 UnclassifiedGlyph = 0, 331 UnclassifiedGlyph = 0,
333 BaseGlyph = 1, 332 BaseGlyph = 1,
334 LigatureGlyph = 2, 333 LigatureGlyph = 2,
(...skipping 10 matching lines...) Expand all
345 { return (this+markAttachClassDef).get_class (glyph); } 344 { return (this+markAttachClassDef).get_class (glyph); }
346 345
347 inline bool has_attach_points (void) const { return attachList != 0; } 346 inline bool has_attach_points (void) const { return attachList != 0; }
348 inline unsigned int get_attach_points (hb_codepoint_t glyph_id, 347 inline unsigned int get_attach_points (hb_codepoint_t glyph_id,
349 unsigned int start_offset, 348 unsigned int start_offset,
350 unsigned int *point_count /* IN/OUT */, 349 unsigned int *point_count /* IN/OUT */,
351 unsigned int *point_array /* OUT */) co nst 350 unsigned int *point_array /* OUT */) co nst
352 { return (this+attachList).get_attach_points (glyph_id, start_offset, point_co unt, point_array); } 351 { return (this+attachList).get_attach_points (glyph_id, start_offset, point_co unt, point_array); }
353 352
354 inline bool has_lig_carets (void) const { return ligCaretList != 0; } 353 inline bool has_lig_carets (void) const { return ligCaretList != 0; }
355 inline unsigned int get_lig_carets (hb_ot_layout_context_t *c, 354 inline unsigned int get_lig_carets (hb_font_t *font,
356 hb_direction_t direction, 355 hb_direction_t direction,
357 hb_codepoint_t glyph_id, 356 hb_codepoint_t glyph_id,
358 unsigned int start_offset, 357 unsigned int start_offset,
359 unsigned int *caret_count /* IN/OUT */, 358 unsigned int *caret_count /* IN/OUT */,
360 » » » » int *caret_array /* OUT */) const 359 » » » » hb_position_t *caret_array /* OUT */) cons t
361 { return (this+ligCaretList).get_lig_carets (c, direction, glyph_id, start_off set, caret_count, caret_array); } 360 { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_ offset, caret_count, caret_array); }
362 361
363 inline bool has_mark_sets (void) const { return version >= 0x00010002 && markG lyphSetsDef[0] != 0; } 362 inline bool has_mark_sets (void) const { return version.to_int () >= 0x0001000 2 && markGlyphSetsDef[0] != 0; }
364 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const 363 inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
365 { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index , glyph_id); } 364 { return version.to_int () >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
366 365
367 inline bool sanitize (hb_sanitize_context_t *c) { 366 inline bool sanitize (hb_sanitize_context_t *c) {
368 TRACE_SANITIZE (); 367 TRACE_SANITIZE ();
369 return version.sanitize (c) && likely (version.major == 1) 368 return version.sanitize (c) && likely (version.major == 1)
370 && glyphClassDef.sanitize (c, this) 369 && glyphClassDef.sanitize (c, this)
371 && attachList.sanitize (c, this) 370 && attachList.sanitize (c, this)
372 && ligCaretList.sanitize (c, this) 371 && ligCaretList.sanitize (c, this)
373 && markAttachClassDef.sanitize (c, this) 372 && markAttachClassDef.sanitize (c, this)
374 » && (version < 0x00010002 || markGlyphSetsDef[0].sanitize (c, this)); 373 » && (version.to_int () < 0x00010002 || markGlyphSetsDef[0].sanitize (c, t his));
375 } 374 }
376 375
377 376
378 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin g 377 /* glyph_props is a 16-bit integer where the lower 8-bit have bits representin g
379 * glyph class and other bits, and high 8-bit gthe mark attachment type (if an y). 378 * glyph class and other bits, and high 8-bit gthe mark attachment type (if an y).
380 * Not to be confused with lookup_props which is very similar. */ 379 * Not to be confused with lookup_props which is very similar. */
381 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const 380 inline unsigned int get_glyph_props (hb_codepoint_t glyph) const
382 { 381 {
383 unsigned int klass = get_glyph_class (glyph); 382 unsigned int klass = get_glyph_class (glyph);
384 383
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 OffsetTo<MarkGlyphSets> 416 OffsetTo<MarkGlyphSets>
418 markGlyphSetsDef[VAR]; /* Offset to the table of mark set 417 markGlyphSetsDef[VAR]; /* Offset to the table of mark set
419 * definitions--from beginning of GDEF 418 * definitions--from beginning of GDEF
420 * header (may be NULL). Introduced 419 * header (may be NULL). Introduced
421 * in version 00010002. */ 420 * in version 00010002. */
422 public: 421 public:
423 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); 422 DEFINE_SIZE_ARRAY (12, markGlyphSetsDef);
424 }; 423 };
425 424
426 425
427 HB_END_DECLS
428 426
429 #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */ 427 #endif /* HB_OT_LAYOUT_GDEF_TABLE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-layout-gdef-private.hh ('k') | third_party/harfbuzz-ng/src/hb-ot-layout-gpos-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698