779b2b4300be4116338d69493be97f857efa4467
[profile/ivi/org.tizen.video-player.git] / src / hb-ot-layout-gdef-private.h
1 #ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H
2 #define HB_OT_LAYOUT_GDEF_PRIVATE_H
3
4 #include "hb-ot-layout-open-private.h"
5
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;
11 };
12
13 /*
14  * Attachment List Table
15  */
16
17 struct AttachPoint {
18   /* countour point indices, in increasing numerical order */
19   DEFINE_ARRAY_TYPE (USHORT, pointIndex, pointCount);
20
21   private:
22   USHORT        pointCount;             /* Number of attachment points on
23                                          * this glyph */
24   USHORT        pointIndex[];           /* Array of contour point indices--in
25                                          * increasing numerical order */
26 };
27 DEFINE_NULL_ASSERT_SIZE (AttachPoint, 2);
28
29 struct AttachList {
30
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];
35   }
36
37   private:
38   /* AttachPoint tables, in Coverage Index order */
39   DEFINE_OFFSET_ARRAY_TYPE (AttachPoint, attachPoint, glyphCount);
40   DEFINE_ACCESSOR (Coverage, get_coverage, coverage);
41
42   private:
43   Offset        coverage;               /* Offset to Coverage table -- from
44                                          * beginning of AttachList table */
45   USHORT        glyphCount;             /* Number of glyphs with attachment
46                                          * points */
47   Offset        attachPoint[];          /* Array of offsets to AttachPoint
48                                          * tables--from beginning of AttachList
49                                          * table--in Coverage Index order */
50 };
51 DEFINE_NULL_ASSERT_SIZE (AttachList, 4);
52
53 /*
54  * Ligature Caret Table
55  */
56
57 struct CaretValue;
58
59 struct LigCaretList {
60   /* TODO */
61
62   private:
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
69                                          * Index order */
70 };
71 DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4);
72
73 struct CaretValueFormat1 {
74
75   inline int get_caret_value (int ppem) const {
76     return /* TODO garbage */ coordinate / ppem;
77   }
78
79   private:
80   USHORT        caretValueFormat;       /* Format identifier--format = 1 */
81   SHORT         coordinate;             /* X or Y value, in design units */
82 };
83 DEFINE_NULL_ASSERT_SIZE (CaretValueFormat1, 4);
84
85 struct CaretValueFormat2 {
86
87   inline int get_caret_value (int ppem) const {
88     return /* TODO garbage */ 0 / ppem;
89   }
90
91   private:
92   USHORT        caretValueFormat;       /* Format identifier--format = 2 */
93   USHORT        caretValuePoint;        /* Contour point index on glyph */
94 };
95 DEFINE_NULL_ASSERT_SIZE (CaretValueFormat2, 4);
96
97 struct CaretValueFormat3 {
98
99   inline const Device& get_device (void) const {
100     if (!deviceTable) return NullDevice;
101     return *(const Device*)((const char*)this + deviceTable);
102   }
103
104   inline int get_caret_value (int ppem) const {
105     return /* TODO garbage */ (coordinate + get_device().get_delta (ppem)) / ppem;
106   }
107
108   private:
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
113                                          * table */
114 };
115 DEFINE_NULL_ASSERT_SIZE (CaretValueFormat3, 6);
116
117 struct CaretValue {
118   DEFINE_NON_INSTANTIABLE(CaretValue);
119
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);
126     }
127   }
128
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);
135     default:return 0;
136     }
137   }
138
139   private:
140   union {
141   USHORT        caretValueFormat;       /* Format identifier */
142   CaretValueFormat1     format1;
143   CaretValueFormat2     format2;
144   CaretValueFormat3     format3;
145   /* FIXME old HarfBuzz code has a format 4 here! */
146   } u;
147 };
148 DEFINE_NULL (CaretValue, 2);
149
150 struct LigGlyph {
151   /* Caret value tables, in increasing coordinate order */
152   DEFINE_OFFSET_ARRAY_TYPE (CaretValue, caretValue, caretCount);
153   /* TODO */
154
155   private:
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
161                                          * order */
162 };
163 DEFINE_NULL_ASSERT_SIZE (LigGlyph, 2);
164
165 /*
166  * GDEF Header
167  */
168
169 struct GDEFHeader {
170   static const hb_tag_t GDEFTag         = HB_TAG ('G','D','E','F');
171
172   STATIC_DEFINE_GET_FOR_DATA (GDEFHeader);
173
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);
178
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);
183   }
184
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);
189   }
190
191   /* TODO get_glyph_property */
192
193   /* TODO get_attach and get_lig_caret */
194
195   private:
196   Fixed         version;                /* Version of the GDEF table--initially
197                                          * 0x00010000 */
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) */
210 };
211 DEFINE_NULL_ASSERT_SIZE (GDEFHeader, 12);
212
213 #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_H */