1 /*
2  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
3  * Copyright (C) 2006  Behdad Esfahbod
4  *
5  * This is part of HarfBuzz, an OpenType Layout engine library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  */
25 
26 #ifndef HARFBUZZ_OPEN_H
27 #define HARFBUZZ_OPEN_H
28 
29 #include "harfbuzz-global.h"
30 
31 HB_BEGIN_HEADER
32 
33 /* Use this if a feature applies to all glyphs */
34 #define HB_ALL_GLYPHS                    0xFFFF
35 
36 #define HB_DEFAULT_LANGUAGE              0xFFFF
37 
38 #define HB_MAX_NESTING_LEVEL             100
39 
40 
41 /* Script list related structures */
42 
43 struct  HB_LangSys_
44 {
45   HB_UShort*  FeatureIndex;           /* array of Feature indices  */
46   HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */
47   HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */
48   HB_UShort   FeatureCount;           /* number of Feature indices */
49 };
50 
51 typedef struct HB_LangSys_  HB_LangSys;
52 
53 
54 struct  HB_LangSysRecord_
55 {
56   HB_LangSys  LangSys;               /* LangSys table         */
57   HB_UInt     LangSysTag;            /* LangSysTag identifier */
58 };
59 
60 typedef struct HB_LangSysRecord_  HB_LangSysRecord;
61 
62 
63 struct  HB_ScriptTable_
64 {
65   HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */
66   HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */
67   HB_UShort           LangSysCount;   /* number of LangSysRecords */
68 };
69 
70 typedef struct HB_ScriptTable_  HB_ScriptTable;
71 
72 
73 struct  HB_ScriptRecord_
74 {
75   HB_UInt        ScriptTag;              /* ScriptTag identifier */
76   HB_ScriptTable  Script;                 /* Script table         */
77 };
78 
79 typedef struct HB_ScriptRecord_  HB_ScriptRecord;
80 
81 
82 struct  HB_ScriptList_
83 {
84   HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */
85   HB_UShort          ScriptCount;     /* number of ScriptRecords */
86 };
87 
88 typedef struct HB_ScriptList_  HB_ScriptList;
89 
90 
91 /* Feature list related structures */
92 
93 struct HB_Feature_
94 {
95   HB_UShort*  LookupListIndex;        /* array of LookupList indices  */
96   HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */
97   HB_UShort   LookupListCount;        /* number of LookupList indices */
98 };
99 
100 typedef struct HB_Feature_  HB_Feature;
101 
102 
103 struct  HB_FeatureRecord_
104 {
105   HB_UInt     FeatureTag;            /* FeatureTag identifier */
106   HB_Feature  Feature;               /* Feature table         */
107 };
108 
109 typedef struct HB_FeatureRecord_  HB_FeatureRecord;
110 
111 
112 struct  HB_FeatureList_
113 {
114   HB_UShort*		ApplyOrder;	/* order to apply features */
115   HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */
116   HB_UShort           FeatureCount;   /* number of FeatureRecords */
117   HB_UShort		ApplyCount;	/* number of elements in ApplyOrder */
118 };
119 
120 typedef struct HB_FeatureList_  HB_FeatureList;
121 
122 
123 /* Lookup list related structures */
124 
125 typedef struct HB_SubTable_  HB_SubTable;
126 
127 
128 struct  HB_Lookup_
129 {
130   HB_SubTable*  SubTable;            /* array of SubTables  */
131   HB_UShort      LookupType;          /* Lookup type         */
132   HB_UShort      LookupFlag;          /* Lookup qualifiers   */
133   HB_UShort      SubTableCount;       /* number of SubTables */
134 };
135 
136 typedef struct HB_Lookup_  HB_Lookup;
137 
138 
139 /* The `Properties' field is not defined in the OpenType specification but
140    is needed for processing lookups.  If properties[n] is > 0, the
141    functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will
142    process Lookup[n] for glyphs which have the specific bit not set in
143    the `properties' field of the input string object.                  */
144 
145 struct  HB_LookupList_
146 {
147   HB_Lookup*  Lookup;                /* array of Lookup records */
148   HB_UInt*     Properties;            /* array of flags          */
149   HB_UShort    LookupCount;           /* number of Lookups       */
150 };
151 
152 typedef struct HB_LookupList_  HB_LookupList;
153 
154 
155 /* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the
156    OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in
157    OpenType 1.3 -- if set, the last glyph in a cursive attachment
158    sequence has to be positioned on the baseline -- regardless of the
159    writing direction.                                                    */
160 
161 #define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001
162 #define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002
163 #define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004
164 #define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008
165 #define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00
166 
167 
168 struct  HB_CoverageFormat1_
169 {
170   HB_UShort*  GlyphArray;             /* array of glyph IDs             */
171   HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */
172 };
173 
174 typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;
175 
176 
177 struct HB_RangeRecord_
178 {
179   HB_UShort  Start;                   /* first glyph ID in the range */
180   HB_UShort  End;                     /* last glyph ID in the range  */
181   HB_UShort  StartCoverageIndex;      /* coverage index of first
182 					 glyph ID in the range       */
183 };
184 
185 typedef struct HB_RangeRecord_  HB_RangeRecord;
186 
187 
188 struct  HB_CoverageFormat2_
189 {
190   HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */
191   HB_UShort         RangeCount;       /* number of RangeRecords */
192 };
193 
194 typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;
195 
196 
197 struct  HB_Coverage_
198 {
199   HB_Byte    CoverageFormat;          /* 1 or 2 */
200 
201   union
202   {
203     HB_CoverageFormat1  cf1;
204     HB_CoverageFormat2  cf2;
205   } cf;
206 };
207 
208 typedef struct HB_Coverage_  HB_Coverage;
209 
210 
211 struct  HB_ClassDefFormat1_
212 {
213   HB_UShort*  ClassValueArray;        /* array of class values       */
214   HB_UShort   StartGlyph;             /* first glyph ID of the
215 					 ClassValueArray             */
216   HB_UShort   GlyphCount;             /* size of the ClassValueArray */
217 };
218 
219 typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;
220 
221 
222 struct  HB_ClassRangeRecord_
223 {
224   HB_UShort  Start;                   /* first glyph ID in the range    */
225   HB_UShort  End;                     /* last glyph ID in the range     */
226   HB_UShort  Class;                   /* applied to all glyphs in range */
227 };
228 
229 typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;
230 
231 
232 struct  HB_ClassDefFormat2_
233 {
234   HB_ClassRangeRecord*  ClassRangeRecord;
235 				      /* array of ClassRangeRecords  */
236   HB_UShort              ClassRangeCount;
237 				      /* number of ClassRangeRecords */
238 };
239 
240 typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;
241 
242 
243 struct  HB_ClassDefinition_
244 {
245   union
246   {
247     HB_ClassDefFormat1  cd1;
248     HB_ClassDefFormat2  cd2;
249   } cd;
250 
251   HB_Byte    ClassFormat;             /* 1 or 2                      */
252   HB_Bool    loaded;
253 };
254 
255 typedef struct HB_ClassDefinition_  HB_ClassDefinition;
256 
257 
258 struct HB_Device_
259 {
260   HB_UShort*  DeltaValue;             /* array of compressed data      */
261   HB_UShort   StartSize;              /* smallest size to correct      */
262   HB_UShort   EndSize;                /* largest size to correct       */
263   HB_Byte     DeltaFormat;            /* DeltaValue array data format:
264 					 1, 2, or 3                    */
265 };
266 
267 typedef struct HB_Device_  HB_Device;
268 
269 
270 enum  HB_Type_
271 {
272   HB_Type_GSUB,
273   HB_Type_GPOS
274 };
275 
276 typedef enum HB_Type_  HB_Type;
277 
278 HB_END_HEADER
279 
280 #endif /* HARFBUZZ_OPEN_H */
281