Behdad Esfahbod | 8dd1c8b | 2008-01-23 05:00:30 -0500 | [diff] [blame^] | 1 | #ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H |
| 2 | #define HB_OT_LAYOUT_GDEF_PRIVATE_H |
Behdad Esfahbod | 5b3f770 | 2006-12-28 06:42:37 -0500 | [diff] [blame] | 3 | |
Behdad Esfahbod | 8dd1c8b | 2008-01-23 05:00:30 -0500 | [diff] [blame^] | 4 | #include "hb-ot-layout-open-private.h" |
Behdad Esfahbod | 5b3f770 | 2006-12-28 06:42:37 -0500 | [diff] [blame] | 5 | |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 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 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 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); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 28 | |
| 29 | struct AttachList { |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 30 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 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]; |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 35 | } |
| 36 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 37 | private: |
| 38 | /* AttachPoint tables, in Coverage Index order */ |
| 39 | DEFINE_OFFSET_ARRAY_TYPE (AttachPoint, attachPoint, glyphCount); |
| 40 | DEFINE_ACCESSOR (Coverage, get_coverage, coverage); |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 41 | |
| 42 | private: |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 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 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 51 | DEFINE_NULL_ASSERT_SIZE (AttachList, 4); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * Ligature Caret Table |
| 55 | */ |
| 56 | |
| 57 | struct CaretValue; |
| 58 | |
| 59 | struct LigCaretList { |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 60 | /* TODO */ |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 61 | |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 62 | private: |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 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 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 71 | DEFINE_NULL_ASSERT_SIZE (LigCaretList, 4); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 72 | |
| 73 | struct CaretValueFormat1 { |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 74 | |
| 75 | inline int get_caret_value (int ppem) const { |
| 76 | return /* TODO garbage */ coordinate / ppem; |
| 77 | } |
| 78 | |
| 79 | private: |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 80 | USHORT caretValueFormat; /* Format identifier--format = 1 */ |
| 81 | SHORT coordinate; /* X or Y value, in design units */ |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 82 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 83 | DEFINE_NULL_ASSERT_SIZE (CaretValueFormat1, 4); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 84 | |
| 85 | struct CaretValueFormat2 { |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 86 | |
| 87 | inline int get_caret_value (int ppem) const { |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 88 | return /* TODO garbage */ 0 / ppem; |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 89 | } |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 90 | |
| 91 | private: |
| 92 | USHORT caretValueFormat; /* Format identifier--format = 2 */ |
| 93 | USHORT caretValuePoint; /* Contour point index on glyph */ |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 94 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 95 | DEFINE_NULL_ASSERT_SIZE (CaretValueFormat2, 4); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 96 | |
| 97 | struct CaretValueFormat3 { |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 98 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 99 | inline const Device& get_device (void) const { |
| 100 | if (!deviceTable) return NullDevice; |
| 101 | return *(const Device*)((const char*)this + deviceTable); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 102 | } |
| 103 | |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 104 | inline int get_caret_value (int ppem) const { |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 105 | return /* TODO garbage */ (coordinate + get_device().get_delta (ppem)) / ppem; |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | private: |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 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 */ |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 114 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 115 | DEFINE_NULL_ASSERT_SIZE (CaretValueFormat3, 6); |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 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 | |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 139 | private: |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 140 | union { |
| 141 | USHORT caretValueFormat; /* Format identifier */ |
| 142 | CaretValueFormat1 format1; |
| 143 | CaretValueFormat2 format2; |
| 144 | CaretValueFormat3 format3; |
Behdad Esfahbod | 303fe62 | 2008-01-23 00:20:48 -0500 | [diff] [blame] | 145 | /* FIXME old HarfBuzz code has a format 4 here! */ |
Behdad Esfahbod | 4c2556c | 2007-07-06 11:29:21 -0400 | [diff] [blame] | 146 | } u; |
| 147 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 148 | DEFINE_NULL (CaretValue, 2); |
Behdad Esfahbod | 5b3f770 | 2006-12-28 06:42:37 -0500 | [diff] [blame] | 149 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 150 | struct LigGlyph { |
| 151 | /* Caret value tables, in increasing coordinate order */ |
| 152 | DEFINE_OFFSET_ARRAY_TYPE (CaretValue, caretValue, caretCount); |
| 153 | /* TODO */ |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 154 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 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 | */ |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 168 | |
| 169 | struct GDEFHeader { |
Behdad Esfahbod | 600e5eb | 2008-01-23 02:01:37 -0500 | [diff] [blame] | 170 | static const hb_tag_t GDEFTag = HB_TAG ('G','D','E','F'); |
| 171 | |
| 172 | STATIC_DEFINE_GET_FOR_DATA (GDEFHeader); |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 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 { |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 181 | const ClassDef &class_def = get_glyph_class_def (); |
| 182 | return class_def.get_class (glyph_id); |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* Returns 0 if not found. */ |
| 186 | inline int get_mark_attachment_type (uint16_t glyph_id) const { |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 187 | const ClassDef &class_def = get_mark_attach_class_def (); |
| 188 | return class_def.get_class (glyph_id); |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 189 | } |
| 190 | |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 191 | /* TODO get_glyph_property */ |
| 192 | |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 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 |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 200 | * GDEF header (may be Null) */ |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 201 | Offset attachList; /* Offset to list of glyphs with |
| 202 | * attachment points--from beginning |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 203 | * of GDEF header (may be Null) */ |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 204 | Offset ligCaretList; /* Offset to list of positioning points |
| 205 | * for ligature carets--from beginning |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 206 | * of GDEF header (may be Null) */ |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 207 | Offset markAttachClassDef; /* Offset to class definition table for |
| 208 | * mark attachment type--from beginning |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 209 | * of GDEF header (may be Null) */ |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 210 | }; |
Behdad Esfahbod | 1f437e6 | 2008-01-23 04:36:40 -0500 | [diff] [blame] | 211 | DEFINE_NULL_ASSERT_SIZE (GDEFHeader, 12); |
Behdad Esfahbod | b9d7688 | 2008-01-23 01:38:10 -0500 | [diff] [blame] | 212 | |
Behdad Esfahbod | 8dd1c8b | 2008-01-23 05:00:30 -0500 | [diff] [blame^] | 213 | #endif /* HB_OT_LAYOUT_GDEF_PRIVATE_H */ |