1/***************************************************************************
2*
3*   Copyright (C) 1998-2011, International Business Machines
4*   Corporation and others.  All Rights Reserved.
5*
6************************************************************************/
7
8#ifndef __SFNT_H
9#define __SFNT_H
10
11#include "layout/LETypes.h"
12#include "letest.h"
13
14HB_BEGIN_VISIBILITY
15
16U_NAMESPACE_USE
17
18#ifndef ANY_NUMBER
19#define ANY_NUMBER 1
20#endif
21
22struct DirectoryEntry
23{
24    le_uint32   tag;
25    le_uint32   checksum;
26    le_uint32   offset;
27    le_uint32   length;
28};
29
30#ifndef __cplusplus
31typedef struct DirectoryEntry DirectoryEntry;
32#endif
33
34struct SFNTDirectory
35{
36    le_uint32       scalerType;
37    le_uint16       numTables;
38    le_uint16       searchRange;
39    le_uint16       entrySelector;
40    le_uint16       rangeShift;
41    DirectoryEntry  tableDirectory[ANY_NUMBER];
42};
43
44#ifndef __cplusplus
45typedef struct SFNTDirectory SFNTDirectory;
46#endif
47
48
49struct CMAPEncodingSubtableHeader
50{
51    le_uint16   platformID;
52    le_uint16   platformSpecificID;
53    le_uint32   encodingOffset;
54};
55
56#ifndef __cplusplus
57typedef struct CMAPEncodingSubtableHeader CMAPEncodingSubtableHeader;
58#endif
59
60struct CMAPTable
61{
62    le_uint16   version;
63    le_uint16   numberSubtables;
64    CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
65};
66
67#ifndef __cplusplus
68typedef struct CMAPTable CMAPTable;
69#endif
70
71struct CMAPEncodingSubtable
72{
73    le_uint16   format;
74    le_uint16   length;
75    le_uint16   language;
76};
77
78#ifndef __cplusplus
79typedef struct CMAPEncodingSubtable CMAPEncodingSubtable;
80#endif
81
82#ifdef __cplusplus
83struct CMAPFormat0Encoding : CMAPEncodingSubtable
84{
85    le_uint8    glyphIndexArray[256];
86};
87#else
88struct CMAPFormat0Encoding
89{
90	CMAPEncodingSubtable base;
91
92	le_uint8 glyphIndexArray[256];
93};
94
95typedef struct CMAPFormat0Encoding CMAPFormat0Encoding;
96#endif
97
98struct CMAPFormat2Subheader
99{
100    le_uint16   firstCode;
101    le_uint16   entryCount;
102    le_int16    idDelta;
103    le_uint16   idRangeOffset;
104};
105
106#ifndef __cplusplus
107typedef struct CMAPFormat2Subheader CMAPFormat2Subheader;
108#endif
109
110#ifdef __cplusplus
111struct CMAPFormat2Encoding : CMAPEncodingSubtable
112{
113    le_uint16  subHeadKeys[256];
114    CMAPFormat2Subheader subheaders[ANY_NUMBER];
115};
116#else
117struct CMAPFormat2Encoding
118{
119	CMAPEncodingSubtable base;
120
121    le_uint16  subHeadKeys[256];
122    CMAPFormat2Subheader subheaders[ANY_NUMBER];
123};
124
125typedef struct CMAPFormat2Encoding CMAPFormat2Encoding;
126#endif
127
128#ifdef __cplusplus
129struct CMAPFormat4Encoding : CMAPEncodingSubtable
130{
131    le_uint16   segCountX2;
132    le_uint16   searchRange;
133    le_uint16   entrySelector;
134    le_uint16   rangeShift;
135    le_uint16   endCodes[ANY_NUMBER];
136/*
137    le_uint16   reservedPad;
138    le_uint16   startCodes[ANY_NUMBER];
139    le_uint16   idDelta[ANY_NUMBER];
140    le_uint16   idRangeOffset[ANY_NUMBER];
141    le_uint16   glyphIndexArray[ANY_NUMBER];
142*/
143};
144#else
145struct CMAPFormat4Encoding
146{
147	CMAPEncodingSubtable base;
148
149    le_uint16   segCountX2;
150    le_uint16   searchRange;
151    le_uint16   entrySelector;
152    le_uint16   rangeShift;
153    le_uint16   endCodes[ANY_NUMBER];
154/*
155//  le_uint16   reservedPad;
156//  le_uint16   startCodes[ANY_NUMBER];
157//  le_uint16   idDelta[ANY_NUMBER];
158//  le_uint16   idRangeOffset[ANY_NUMBER];
159//  le_uint16   glyphIndexArray[ANY_NUMBER];
160*/
161};
162
163typedef struct CMAPFormat4Encoding CMAPFormat4Encoding;
164#endif
165
166#ifdef __cplusplus
167struct CMAPFormat6Encoding : CMAPEncodingSubtable
168{
169    le_uint16   firstCode;
170    le_uint16   entryCount;
171    le_uint16   glyphIndexArray[ANY_NUMBER];
172};
173#else
174struct CMAPFormat6Encoding
175{
176	CMAPEncodingSubtable base;
177
178    le_uint16   firstCode;
179    le_uint16   entryCount;
180    le_uint16   glyphIndexArray[ANY_NUMBER];
181};
182
183typedef struct CMAPFormat6Encoding CMAPFormat6Encoding;
184#endif
185
186struct CMAPEncodingSubtable32
187{
188    le_uint32   format;
189    le_uint32   length;
190    le_uint32   language;
191};
192
193#ifndef __cplusplus
194typedef struct CMAPEncodingSubtable32 CMAPEncodingSubtable32;
195#endif
196
197struct CMAPGroup
198{
199    le_uint32   startCharCode;
200    le_uint32   endCharCode;
201    le_uint32   startGlyphCode;
202};
203
204#ifndef __cplusplus
205typedef struct CMAPGroup CMAPGroup;
206#endif
207
208#ifdef __cplusplus
209struct CMAPFormat8Encoding : CMAPEncodingSubtable32
210{
211    le_uint32   is32[65536/32];
212    le_uint32   nGroups;
213    CMAPGroup   groups[ANY_NUMBER];
214};
215#else
216struct CMAPFormat8Encoding
217{
218	CMAPEncodingSubtable32 base;
219
220    le_uint32   is32[65536/32];
221    le_uint32   nGroups;
222    CMAPGroup   groups[ANY_NUMBER];
223};
224
225typedef struct CMAPFormat8Encoding CMAPFormat8Encoding;
226#endif
227
228#ifdef __cplusplus
229struct CMAPFormat10Encoding : CMAPEncodingSubtable32
230{
231    le_uint32   startCharCode;
232    le_uint32   numCharCodes;
233    le_uint16   glyphs[ANY_NUMBER];
234};
235#else
236struct CMAPFormat10Encoding
237{
238	CMAPEncodingSubtable32 base;
239
240    le_uint32   startCharCode;
241    le_uint32   numCharCodes;
242    le_uint16   glyphs[ANY_NUMBER];
243};
244
245typedef struct CMAPFormat10Encoding CMAPFormat10Encoding;
246#endif
247
248#ifdef __cplusplus
249struct CMAPFormat12Encoding : CMAPEncodingSubtable32
250{
251    le_uint32   nGroups;
252    CMAPGroup   groups[ANY_NUMBER];
253};
254#else
255struct CMAPFormat12Encoding
256{
257	CMAPEncodingSubtable32 base;
258
259    le_uint32   nGroups;
260    CMAPGroup   groups[ANY_NUMBER];
261};
262
263typedef struct CMAPFormat12Encoding CMAPFormat12Encoding;
264#endif
265
266typedef le_int32 fixed;
267
268struct BigDate
269{
270    le_uint32   bc;
271    le_uint32   ad;
272};
273
274#ifndef __cplusplus
275typedef struct BigDate BigDate;
276#endif
277
278struct HEADTable
279{
280    fixed       version;
281    fixed       fontRevision;
282    le_uint32   checksumAdjustment;
283    le_uint32   magicNumber;
284    le_uint16   flags;
285    le_uint16   unitsPerEm;
286    BigDate     created;
287    BigDate     modified;
288    le_int16    xMin;
289    le_int16    yMin;
290    le_int16    xMax;
291    le_int16    yMax;
292    le_int16    lowestRecPPEM;
293    le_int16    fontDirectionHint;
294    le_int16    indexToLocFormat;
295    le_int16    glyphDataFormat;
296};
297
298#ifndef __cplusplus
299typedef struct HEADTable HEADTable;
300#endif
301
302struct MAXPTable
303{
304    fixed       version;
305    le_uint16   numGlyphs;
306    le_uint16   maxPoints;
307    le_uint16   maxContours;
308    le_uint16   maxComponentPoints;
309    le_uint16   maxComponentContours;
310    le_uint16   maxZones;
311    le_uint16   maxTwilightPoints;
312    le_uint16   maxStorage;
313    le_uint16   maxFunctionDefs;
314    le_uint16   maxInstructionDefs;
315    le_uint16   maxStackElements;
316    le_uint16   maxSizeOfInstructions;
317    le_uint16   maxComponentElements;
318    le_uint16   maxComponentDepth;
319};
320
321#ifndef __cplusplus
322typedef struct MAXPTable MAXPTable;
323#endif
324
325struct HHEATable
326{
327    fixed       version;
328    le_int16    ascent;
329    le_int16    descent;
330    le_int16    lineGap;
331    le_uint16   advanceWidthMax;
332    le_int16    minLeftSideBearing;
333    le_int16    minRightSideBearing;
334    le_int16    xMaxExtent;
335    le_int16    caretSlopeRise;
336    le_int16    caretSlopeRun;
337    le_int16    caretOffset;
338    le_int16    reserved1;
339    le_int16    reserved2;
340    le_int16    reserved3;
341    le_int16    reserved4;
342    le_int16    metricDataFormat;
343    le_uint16   numOfLongHorMetrics;
344};
345
346#ifndef __cplusplus
347typedef struct HHEATable HHEATable;
348#endif
349
350struct LongHorMetric
351{
352    le_uint16   advanceWidth;
353    le_int16    leftSideBearing;
354};
355
356#ifndef __cplusplus
357typedef struct LongHorMetric LongHorMetric;
358#endif
359
360struct HMTXTable
361{
362    LongHorMetric hMetrics[ANY_NUMBER];       /* ANY_NUMBER = numOfLongHorMetrics from hhea table */
363/* le_int16        leftSideBearing[ANY_NUMBER];  ANY_NUMBER = numGlyphs - numOfLongHorMetrics     */
364};
365
366#ifndef __cplusplus
367typedef struct HMTXTable HMTXTable;
368#endif
369
370enum PlatformID
371{
372    PLATFORM_UNICODE = 0,
373    PLATFORM_MACINTOSH = 1,
374    PLATFORM_ISO       = 2,
375    PLATFORM_MICROSOFT = 3,
376    PLATFORM_CUSTOM    = 4
377};
378
379enum MacintoshEncodingID
380{
381    MACINTOSH_ROMAN = 0
382};
383
384enum MacintoshLanguageID
385{
386    MACINTOSH_ENGLISH = 0
387};
388
389enum MicrosoftEncodingID
390{
391    MICROSOFT_UNICODE_BMP  =  1,
392    MICROSOFT_UNICODE_FULL = 10
393};
394
395enum MicrosoftLanguageID
396{
397    MICROSOFT_ENGLISH = 0x409
398};
399
400enum NameID
401{
402    NAME_COPYRIGHT_NOTICE     = 0,
403    NAME_FONT_FAMILY          = 1,
404    NAME_FONT_SUB_FAMILY      = 2,
405    NAME_UNIQUE_FONT_ID       = 3,
406    NAME_FULL_FONT_NAME       = 4,
407    NAME_VERSION_STRING       = 5,
408    NAME_POSTSCRIPT_NAME      = 6,
409    NAME_TRADEMARK            = 7,
410    NAME_MANUFACTURER         = 8,
411    NAME_DESIGNER             = 9,
412    NAME_DESCRIPTION          = 10,
413    NAME_VENDOR_URL           = 11,
414    NAME_DESIGNER_URL         = 12,
415    NAME_LICENSE_DESCRIPTION  = 13,
416    NAME_LICENSE_URL          = 14,
417    NAME_RESERVED             = 15,
418    NAME_PREFERRED_FAMILY     = 16,
419    NAME_PREFERRED_SUB_FAMILY = 17,
420    NAME_COMPATIBLE_FULL      = 18,
421    NAME_SAMPLE_TEXT          = 19,
422    NAME_POSTSCRIPT_CID       = 20
423};
424
425struct NameRecord
426{
427    le_uint16 platformID;
428    le_uint16 encodingID;
429    le_uint16 languageID;
430    le_uint16 nameID;
431    le_uint16 length;
432    le_uint16 offset;
433};
434
435#ifndef __cplusplus
436typedef struct NameRecord NameRecord;
437#endif
438
439struct NAMETable
440{
441    le_uint16 version;
442    le_uint16 count;
443    le_uint16 stringOffset;
444    NameRecord nameRecords[ANY_NUMBER];
445};
446
447#ifndef __cplusplus
448typedef struct NAMETable NAMETable;
449#endif
450
451HB_END_VISIBILITY
452
453#endif
454