1 #ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H
2 #define HB_OT_LAYOUT_GDEF_PRIVATE_H
4 #include "hb-ot-layout-open-private.h"
7 #define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
8 inline const Type& name (uint16_t glyph_id) { \
9 const Coverage &c = get_coverage (); \
10 int c_index = c.get_coverage (glyph_id); \
11 return (*this)[c_index]; \
15 struct GlyphClassDef : ClassDef {
16 static const uint16_t BaseGlyph = 0x0001u;
17 static const uint16_t LigatureGlyph = 0x0002u;
18 static const uint16_t MarkGlyph = 0x0003u;
19 static const uint16_t ComponentGlyph = 0x0004u;
23 * Attachment List Table
27 /* countour point indices, in increasing numerical order */
28 DEFINE_ARRAY_TYPE (USHORT, pointIndex, pointCount);
31 USHORT pointCount; /* Number of attachment points on
33 USHORT pointIndex[]; /* Array of contour point indices--in
34 * increasing numerical order */
36 DEFINE_NULL_ASSERT_SIZE (AttachPoint, 2);
39 /* const AttachPoint& get_attach_points (uint16_t glyph_id); */
40 DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (AttachPoint, get_attach_points);
43 /* AttachPoint tables, in Coverage Index order */
44 DEFINE_OFFSET_ARRAY_TYPE (AttachPoint, attachPoint, glyphCount);
45 DEFINE_ACCESSOR (Coverage, get_coverage, coverage);
48 Offset coverage; /* Offset to Coverage table -- from
49 * beginning of AttachList table */
50 USHORT glyphCount; /* Number of glyphs with attachment
52 Offset attachPoint[]; /* Array of offsets to AttachPoint
53 * tables--from beginning of AttachList
54 * table--in Coverage Index order */
56 DEFINE_NULL_ASSERT_SIZE (AttachList, 4);
59 * Ligature Caret Table
62 struct CaretValueFormat1 {
64 inline int get_caret_value (int ppem) const {
65 return /* TODO garbage */ coordinate / ppem;
69 USHORT caretValueFormat; /* Format identifier--format = 1 */
70 SHORT coordinate; /* X or Y value, in design units */
72 ASSERT_SIZE (CaretValueFormat1, 4);
74 struct CaretValueFormat2 {
76 inline int get_caret_value (int ppem) const {
77 return /* TODO garbage */ 0 / ppem;
81 USHORT caretValueFormat; /* Format identifier--format = 2 */
82 USHORT caretValuePoint; /* Contour point index on glyph */
84 ASSERT_SIZE (CaretValueFormat2, 4);
86 struct CaretValueFormat3 {
88 inline const Device& get_device (void) const {
89 if (HB_UNLIKELY (!deviceTable)) return NullDevice;
90 return *(const Device*)((const char*)this + deviceTable);
93 inline int get_caret_value (int ppem) const {
94 return /* TODO garbage */ (coordinate + get_device().get_delta (ppem)) / ppem;
98 USHORT caretValueFormat; /* Format identifier--format = 3 */
99 SHORT coordinate; /* X or Y value, in design units */
100 Offset deviceTable; /* Offset to Device table for X or Y
101 * value--from beginning of CaretValue
104 ASSERT_SIZE (CaretValueFormat3, 6);
107 DEFINE_NON_INSTANTIABLE(CaretValue);
109 inline unsigned int get_size (void) const {
110 switch (u.caretValueFormat) {
111 case 1: return sizeof (u.format1);
112 case 2: return sizeof (u.format2);
113 case 3: return sizeof (u.format3);
114 default:return sizeof (u.caretValueFormat);
118 /* XXX we need access to a load-contour-point vfunc here */
119 inline int get_caret_value (int ppem) const {
120 switch (u.caretValueFormat) {
121 case 1: return u.format1.get_caret_value(ppem);
122 case 2: return u.format2.get_caret_value(ppem);
123 case 3: return u.format3.get_caret_value(ppem);
130 USHORT caretValueFormat; /* Format identifier */
131 CaretValueFormat1 format1;
132 CaretValueFormat2 format2;
133 CaretValueFormat3 format3;
134 /* FIXME old HarfBuzz code has a format 4 here! */
137 DEFINE_NULL (CaretValue, 2);
140 /* Caret value tables, in increasing coordinate order */
141 DEFINE_OFFSET_ARRAY_TYPE (CaretValue, caretValue, caretCount);
145 USHORT caretCount; /* Number of CaretValues for this
146 * ligature (components - 1) */
147 Offset caretValue[]; /* Array of offsets to CaretValue
148 * tables--from beginning of LigGlyph
149 * table--in increasing coordinate
152 DEFINE_NULL_ASSERT_SIZE (LigGlyph, 2);
154 struct LigCaretList {
155 /* const LigGlyph& get_lig_glyph (uint16_t glyph_id); */
156 DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (LigGlyph, get_lig_glyph);
159 /* AttachPoint tables, in Coverage Index order */
160 DEFINE_OFFSET_ARRAY_TYPE (LigGlyph, ligGlyph, ligGlyphCount);
161 DEFINE_ACCESSOR (Coverage, get_coverage, coverage);
164 Offset coverage; /* Offset to Coverage table--from
165 * beginning of LigCaretList table */
166 USHORT ligGlyphCount; /* Number of ligature glyphs */
167 Offset ligGlyph[]; /* Array of offsets to LigGlyph
168 * tables--from beginning of
169 * LigCaretList table--in Coverage
172 DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4);
179 static const hb_tag_t GDEFTag = HB_TAG ('G','D','E','F');
181 STATIC_DEFINE_GET_FOR_DATA (GDEFHeader);
183 DEFINE_ACCESSOR (ClassDef, get_glyph_class_def, glyphClassDef);
184 DEFINE_ACCESSOR (AttachList, get_attach_list, attachList);
185 DEFINE_ACCESSOR (LigCaretList, get_lig_caret_list, ligCaretList);
186 DEFINE_ACCESSOR (ClassDef, get_mark_attach_class_def, markAttachClassDef);
188 /* Returns 0 if not found. */
189 inline int get_glyph_class (uint16_t glyph_id) const {
190 const ClassDef &class_def = get_glyph_class_def ();
191 return class_def.get_class (glyph_id);
194 /* Returns 0 if not found. */
195 inline int get_mark_attachment_type (uint16_t glyph_id) const {
196 const ClassDef &class_def = get_mark_attach_class_def ();
197 return class_def.get_class (glyph_id);
200 /* TODO get_glyph_property */
202 /* TODO get_attach and get_lig_caret */
205 Fixed version; /* Version of the GDEF table--initially
207 Offset glyphClassDef; /* Offset to class definition table
208 * for glyph type--from beginning of
209 * GDEF header (may be Null) */
210 Offset attachList; /* Offset to list of glyphs with
211 * attachment points--from beginning
212 * of GDEF header (may be Null) */
213 Offset ligCaretList; /* Offset to list of positioning points
214 * for ligature carets--from beginning
215 * of GDEF header (may be Null) */
216 Offset markAttachClassDef; /* Offset to class definition table for
217 * mark attachment type--from beginning
218 * of GDEF header (may be Null) */
220 DEFINE_NULL_ASSERT_SIZE (GDEFHeader, 12);
222 #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_H */