1 #ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H
2 #define HB_OT_LAYOUT_GDEF_PRIVATE_H
4 #include "hb-ot-layout-open-private.h"
6 struct GlyphClassDef : ClassDef {
7 static const uint16_t BaseGlyph = 0x0001u;
8 static const uint16_t LigatureGlyph = 0x0002u;
9 static const uint16_t MarkGlyph = 0x0003u;
10 static const uint16_t ComponentGlyph = 0x0004u;
14 * Attachment List Table
18 /* countour point indices, in increasing numerical order */
19 DEFINE_ARRAY_TYPE (USHORT, pointIndex, pointCount);
22 USHORT pointCount; /* Number of attachment points on
24 USHORT pointIndex[]; /* Array of contour point indices--in
25 * increasing numerical order */
27 DEFINE_NULL_ASSERT_SIZE (AttachPoint, 2);
31 inline const AttachPoint* get_attach_points (uint16_t glyph_id) {
32 const Coverage &c = get_coverage ();
33 int c_index = c.get_coverage (glyph_id);
34 return &(*this)[c_index];
38 /* AttachPoint tables, in Coverage Index order */
39 DEFINE_OFFSET_ARRAY_TYPE (AttachPoint, attachPoint, glyphCount);
40 DEFINE_ACCESSOR (Coverage, get_coverage, coverage);
43 Offset coverage; /* Offset to Coverage table -- from
44 * beginning of AttachList table */
45 USHORT glyphCount; /* Number of glyphs with attachment
47 Offset attachPoint[]; /* Array of offsets to AttachPoint
48 * tables--from beginning of AttachList
49 * table--in Coverage Index order */
51 DEFINE_NULL_ASSERT_SIZE (AttachList, 4);
54 * Ligature Caret Table
63 Offset coverage; /* Offset to Coverage table--from
64 * beginning of LigCaretList table */
65 USHORT ligGlyphCount; /* Number of ligature glyphs */
66 Offset ligGlyph[]; /* Array of offsets to LigGlyph
67 * tables--from beginning of
68 * LigCaretList table--in Coverage
71 DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4);
73 struct CaretValueFormat1 {
75 inline int get_caret_value (int ppem) const {
76 return /* TODO garbage */ coordinate / ppem;
80 USHORT caretValueFormat; /* Format identifier--format = 1 */
81 SHORT coordinate; /* X or Y value, in design units */
83 DEFINE_NULL_ASSERT_SIZE (CaretValueFormat1, 4);
85 struct CaretValueFormat2 {
87 inline int get_caret_value (int ppem) const {
88 return /* TODO garbage */ 0 / ppem;
92 USHORT caretValueFormat; /* Format identifier--format = 2 */
93 USHORT caretValuePoint; /* Contour point index on glyph */
95 DEFINE_NULL_ASSERT_SIZE (CaretValueFormat2, 4);
97 struct CaretValueFormat3 {
99 inline const Device& get_device (void) const {
100 if (!deviceTable) return NullDevice;
101 return *(const Device*)((const char*)this + deviceTable);
104 inline int get_caret_value (int ppem) const {
105 return /* TODO garbage */ (coordinate + get_device().get_delta (ppem)) / ppem;
109 USHORT caretValueFormat; /* Format identifier--format = 3 */
110 SHORT coordinate; /* X or Y value, in design units */
111 Offset deviceTable; /* Offset to Device table for X or Y
112 * value--from beginning of CaretValue
115 DEFINE_NULL_ASSERT_SIZE (CaretValueFormat3, 6);
118 DEFINE_NON_INSTANTIABLE(CaretValue);
120 inline unsigned int get_size (void) const {
121 switch (u.caretValueFormat) {
122 case 1: return sizeof (u.format1);
123 case 2: return sizeof (u.format2);
124 case 3: return sizeof (u.format3);
125 default:return sizeof (u.caretValueFormat);
129 /* XXX we need access to a load-contour-point vfunc here */
130 inline int get_caret_value (int ppem) const {
131 switch (u.caretValueFormat) {
132 case 1: return u.format1.get_caret_value(ppem);
133 case 2: return u.format2.get_caret_value(ppem);
134 case 3: return u.format3.get_caret_value(ppem);
141 USHORT caretValueFormat; /* Format identifier */
142 CaretValueFormat1 format1;
143 CaretValueFormat2 format2;
144 CaretValueFormat3 format3;
145 /* FIXME old HarfBuzz code has a format 4 here! */
148 DEFINE_NULL (CaretValue, 2);
151 /* Caret value tables, in increasing coordinate order */
152 DEFINE_OFFSET_ARRAY_TYPE (CaretValue, caretValue, caretCount);
156 USHORT caretCount; /* Number of CaretValues for this
157 * ligature (components - 1) */
158 Offset caretValue[]; /* Array of offsets to CaretValue
159 * tables--from beginning of LigGlyph
160 * table--in increasing coordinate
163 DEFINE_NULL_ASSERT_SIZE (LigGlyph, 2);
170 static const hb_tag_t GDEFTag = HB_TAG ('G','D','E','F');
172 STATIC_DEFINE_GET_FOR_DATA (GDEFHeader);
174 DEFINE_ACCESSOR (ClassDef, get_glyph_class_def, glyphClassDef);
175 DEFINE_ACCESSOR (AttachList, get_attach_list, attachList);
176 DEFINE_ACCESSOR (LigCaretList, get_lig_caret_list, ligCaretList);
177 DEFINE_ACCESSOR (ClassDef, get_mark_attach_class_def, markAttachClassDef);
179 /* Returns 0 if not found. */
180 inline int get_glyph_class (uint16_t glyph_id) const {
181 const ClassDef &class_def = get_glyph_class_def ();
182 return class_def.get_class (glyph_id);
185 /* Returns 0 if not found. */
186 inline int get_mark_attachment_type (uint16_t glyph_id) const {
187 const ClassDef &class_def = get_mark_attach_class_def ();
188 return class_def.get_class (glyph_id);
191 /* TODO get_glyph_property */
193 /* TODO get_attach and get_lig_caret */
196 Fixed version; /* Version of the GDEF table--initially
198 Offset glyphClassDef; /* Offset to class definition table
199 * for glyph type--from beginning of
200 * GDEF header (may be Null) */
201 Offset attachList; /* Offset to list of glyphs with
202 * attachment points--from beginning
203 * of GDEF header (may be Null) */
204 Offset ligCaretList; /* Offset to list of positioning points
205 * for ligature carets--from beginning
206 * of GDEF header (may be Null) */
207 Offset markAttachClassDef; /* Offset to class definition table for
208 * mark attachment type--from beginning
209 * of GDEF header (may be Null) */
211 DEFINE_NULL_ASSERT_SIZE (GDEFHeader, 12);
213 #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_H */