2 * Copyright (C) 2007,2008 Red Hat, Inc.
4 * This is part of HarfBuzz, an OpenType Layout engine library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Red Hat Author(s): Behdad Esfahbod
27 #ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H
28 #define HB_OT_LAYOUT_GDEF_PRIVATE_H
30 #include "hb-ot-layout-private.h"
32 #include "hb-ot-layout-open-private.h"
35 #define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
36 inline const Type& name (hb_codepoint_t glyph) { \
37 const Coverage &c = get_coverage (); \
38 hb_ot_layout_coverage_t c_index = c.get_coverage (glyph); \
39 return (*this)[c_index]; \
43 struct GlyphClassDef : ClassDef {
44 static const unsigned int BaseGlyph = 0x0001u;
45 static const unsigned int LigatureGlyph = 0x0002u;
46 static const unsigned int MarkGlyph = 0x0003u;
47 static const unsigned int ComponentGlyph = 0x0004u;
51 * Attachment List Table
56 friend struct AttachList;
59 /* countour point indices, in increasing numerical order */
60 DEFINE_ARRAY_TYPE (USHORT, pointIndex, pointCount);
63 USHORT pointCount; /* Number of attachment points on
65 USHORT pointIndex[]; /* Array of contour point indices--in
66 * increasing numerical order */
68 DEFINE_NULL_ASSERT_SIZE (AttachPoint, 2);
75 /* const AttachPoint& get_attach_points (hb_codepoint_t glyph); */
76 DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (AttachPoint, get_attach_points);
79 /* AttachPoint tables, in Coverage Index order */
80 DEFINE_OFFSET_ARRAY_TYPE (AttachPoint, attachPoint, glyphCount);
81 DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
84 Offset coverage; /* Offset to Coverage table -- from
85 * beginning of AttachList table */
86 USHORT glyphCount; /* Number of glyphs with attachment
88 Offset attachPoint[]; /* Array of offsets to AttachPoint
89 * tables--from beginning of AttachList
90 * table--in Coverage Index order */
92 DEFINE_NULL_ASSERT_SIZE (AttachList, 4);
95 * Ligature Caret Table
98 struct CaretValueFormat1 {
100 friend struct CaretValue;
103 inline int get_caret_value (int ppem) const {
104 return /* TODO garbage */ coordinate / ppem;
108 USHORT caretValueFormat; /* Format identifier--format = 1 */
109 SHORT coordinate; /* X or Y value, in design units */
111 ASSERT_SIZE (CaretValueFormat1, 4);
113 struct CaretValueFormat2 {
115 friend struct CaretValue;
118 inline int get_caret_value (int ppem) const {
119 return /* TODO garbage */ 0 / ppem;
123 USHORT caretValueFormat; /* Format identifier--format = 2 */
124 USHORT caretValuePoint; /* Contour point index on glyph */
126 ASSERT_SIZE (CaretValueFormat2, 4);
128 struct CaretValueFormat3 {
130 friend struct CaretValue;
133 inline const Device& get_device (void) const {
134 if (HB_UNLIKELY (!deviceTable)) return NullDevice;
135 return *(const Device*)((const char*)this + deviceTable);
138 inline int get_caret_value (int ppem) const {
139 return /* TODO garbage */ (coordinate + get_device().get_delta (ppem)) / ppem;
143 USHORT caretValueFormat; /* Format identifier--format = 3 */
144 SHORT coordinate; /* X or Y value, in design units */
145 Offset deviceTable; /* Offset to Device table for X or Y
146 * value--from beginning of CaretValue
149 ASSERT_SIZE (CaretValueFormat3, 6);
152 DEFINE_NON_INSTANTIABLE(CaretValue);
154 unsigned int get_size (void) const {
155 switch (u.caretValueFormat) {
156 case 1: return sizeof (u.format1);
157 case 2: return sizeof (u.format2);
158 case 3: return sizeof (u.format3);
159 default:return sizeof (u.caretValueFormat);
163 /* XXX we need access to a load-contour-point vfunc here */
164 int get_caret_value (int ppem) const {
165 switch (u.caretValueFormat) {
166 case 1: return u.format1.get_caret_value(ppem);
167 case 2: return u.format2.get_caret_value(ppem);
168 case 3: return u.format3.get_caret_value(ppem);
175 USHORT caretValueFormat; /* Format identifier */
176 CaretValueFormat1 format1;
177 CaretValueFormat2 format2;
178 CaretValueFormat3 format3;
179 /* FIXME old HarfBuzz code has a format 4 here! */
182 DEFINE_NULL (CaretValue, 2);
186 friend struct LigCaretList;
189 /* Caret value tables, in increasing coordinate order */
190 DEFINE_OFFSET_ARRAY_TYPE (CaretValue, caretValue, caretCount);
194 USHORT caretCount; /* Number of CaretValues for this
195 * ligature (components - 1) */
196 Offset caretValue[]; /* Array of offsets to CaretValue
197 * tables--from beginning of LigGlyph
198 * table--in increasing coordinate
201 DEFINE_NULL_ASSERT_SIZE (LigGlyph, 2);
203 struct LigCaretList {
208 /* const LigGlyph& get_lig_glyph (hb_codepoint_t glyph); */
209 DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP (LigGlyph, get_lig_glyph);
212 /* AttachPoint tables, in Coverage Index order */
213 DEFINE_OFFSET_ARRAY_TYPE (LigGlyph, ligGlyph, ligGlyphCount);
214 DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
217 Offset coverage; /* Offset to Coverage table--from
218 * beginning of LigCaretList table */
219 USHORT ligGlyphCount; /* Number of ligature glyphs */
220 Offset ligGlyph[]; /* Array of offsets to LigGlyph
221 * tables--from beginning of
222 * LigCaretList table--in Coverage
225 DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4);
232 static const hb_tag_t Tag = HB_TAG ('G','D','E','F');
234 static const hb_ot_layout_class_t UnclassifiedGlyph = 0;
235 static const hb_ot_layout_class_t BaseGlyph = 1;
236 static const hb_ot_layout_class_t LigatureGlyph = 2;
237 static const hb_ot_layout_class_t MarkGlyph = 3;
238 static const hb_ot_layout_class_t ComponentGlyph = 4;
240 STATIC_DEFINE_GET_FOR_DATA (GDEF);
241 /* XXX check version here? */
243 DEFINE_GET_HAS_ACCESSOR (ClassDef, glyph_classes, glyphClassDef);
244 DEFINE_GET_HAS_ACCESSOR (AttachList, attach_list, attachList);
245 DEFINE_GET_HAS_ACCESSOR (LigCaretList, lig_caret_list, ligCaretList);
246 DEFINE_GET_HAS_ACCESSOR (ClassDef, mark_attachment_types, markAttachClassDef);
248 inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const {
249 return get_glyph_classes ().get_class (glyph);
252 inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const {
253 return get_mark_attachment_types ().get_class (glyph);
256 /* TODO get_attach and get_lig_caret */
259 Fixed version; /* Version of the GDEF table--initially
261 Offset glyphClassDef; /* Offset to class definition table
262 * for glyph type--from beginning of
263 * GDEF header (may be Null) */
264 Offset attachList; /* Offset to list of glyphs with
265 * attachment points--from beginning
266 * of GDEF header (may be Null) */
267 Offset ligCaretList; /* Offset to list of positioning points
268 * for ligature carets--from beginning
269 * of GDEF header (may be Null) */
270 Offset markAttachClassDef; /* Offset to class definition table for
271 * mark attachment type--from beginning
272 * of GDEF header (may be Null) */
274 DEFINE_NULL_ASSERT_SIZE (GDEF, 12);
276 #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_H */