]> git.saurik.com Git - apple/icu.git/blob - icuSources/samples/layout/sfnt.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / samples / layout / sfnt.h
1 /*
2 ******************************************************************************
3 *
4 * © 2016 and later: Unicode, Inc. and others.
5 * License & terms of use: http://www.unicode.org/copyright.html#License
6 *
7 ******************************************************************************
8 ****************************************************************************** *
9 *
10 * Copyright (C) 1999-2001, International Business Machines
11 * Corporation and others. All Rights Reserved.
12 *
13 ****************************************************************************** *
14 * file name: sfnt.h
15 *
16 * created on: ??/??/2001
17 * created by: Eric R. Mader
18 */
19
20 #ifndef __SFNT_H
21 #define __SFNT_H
22
23 #include "LETypes.h"
24
25
26 #ifndef ANY_NUMBER
27 #define ANY_NUMBER 1
28 #endif
29
30 struct DirectoryEntry
31 {
32 le_uint32 tag;
33 le_uint32 checksum;
34 le_uint32 offset;
35 le_uint32 length;
36 };
37
38 struct SFNTDirectory
39 {
40 le_uint32 scalerType;
41 le_uint16 numTables;
42 le_uint16 searchRange;
43 le_uint16 entrySelector;
44 le_uint16 rangeShift;
45 DirectoryEntry tableDirectory[ANY_NUMBER];
46 };
47
48
49 struct CMAPEncodingSubtableHeader
50 {
51 le_uint16 platformID;
52 le_uint16 platformSpecificID;
53 le_uint32 encodingOffset;
54 };
55
56 struct CMAPTable
57 {
58 le_uint16 version;
59 le_uint16 numberSubtables;
60 CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER];
61 };
62
63 struct CMAPEncodingSubtable
64 {
65 le_uint16 format;
66 le_uint16 length;
67 le_uint16 language;
68 };
69
70 struct CMAPFormat0Encoding : CMAPEncodingSubtable
71 {
72 le_uint8 glyphIndexArray[256];
73 };
74
75 struct CMAPFormat2Subheader
76 {
77 le_uint16 firstCode;
78 le_uint16 entryCount;
79 le_int16 idDelta;
80 le_uint16 idRangeOffset;
81 };
82
83 struct CMAPFormat2Encoding : CMAPEncodingSubtable
84 {
85 le_uint16 subHeadKeys[256];
86 CMAPFormat2Subheader subheaders[ANY_NUMBER];
87 };
88
89 struct CMAPFormat4Encoding : CMAPEncodingSubtable
90 {
91 le_uint16 segCountX2;
92 le_uint16 searchRange;
93 le_uint16 entrySelector;
94 le_uint16 rangeShift;
95 le_uint16 endCodes[ANY_NUMBER];
96 // le_uint16 reservedPad;
97 // le_uint16 startCodes[ANY_NUMBER];
98 // le_uint16 idDelta[ANY_NUMBER];
99 // le_uint16 idRangeOffset[ANY_NUMBER];
100 // le_uint16 glyphIndexArray[ANY_NUMBER];
101 };
102
103 struct CMAPFormat6Encoding : CMAPEncodingSubtable
104 {
105 le_uint16 firstCode;
106 le_uint16 entryCount;
107 le_uint16 glyphIndexArray[ANY_NUMBER];
108 };
109
110 struct CMAPEncodingSubtable32
111 {
112 le_uint32 format;
113 le_uint32 length;
114 le_uint32 language;
115 };
116
117 struct CMAPGroup
118 {
119 le_uint32 startCharCode;
120 le_uint32 endCharCode;
121 le_uint32 startGlyphCode;
122 };
123
124 struct CMAPFormat8Encoding : CMAPEncodingSubtable32
125 {
126 le_uint32 is32[65536/32];
127 le_uint32 nGroups;
128 CMAPGroup groups[ANY_NUMBER];
129 };
130
131 struct CMAPFormat10Encoding : CMAPEncodingSubtable32
132 {
133 le_uint32 startCharCode;
134 le_uint32 numCharCodes;
135 le_uint16 glyphs[ANY_NUMBER];
136 };
137
138 struct CMAPFormat12Encoding : CMAPEncodingSubtable32
139 {
140 le_uint32 nGroups;
141 CMAPGroup groups[ANY_NUMBER];
142 };
143
144 typedef le_int32 fixed;
145
146 struct BigDate
147 {
148 le_uint32 bc;
149 le_uint32 ad;
150 };
151
152 struct HEADTable
153 {
154 fixed version;
155 fixed fontRevision;
156 le_uint32 checksumAdjustment;
157 le_uint32 magicNumber;
158 le_uint16 flags;
159 le_uint16 unitsPerEm;
160 BigDate created;
161 BigDate modified;
162 le_int16 xMin;
163 le_int16 yMin;
164 le_int16 xMax;
165 le_int16 yMax;
166 le_int16 lowestRecPPEM;
167 le_int16 fontDirectionHint;
168 le_int16 indexToLocFormat;
169 le_int16 glyphDataFormat;
170 };
171
172 struct MAXPTable
173 {
174 fixed version;
175 le_uint16 numGlyphs;
176 le_uint16 maxPoints;
177 le_uint16 maxContours;
178 le_uint16 maxComponentPoints;
179 le_uint16 maxComponentContours;
180 le_uint16 maxZones;
181 le_uint16 maxTwilightPoints;
182 le_uint16 maxStorage;
183 le_uint16 maxFunctionDefs;
184 le_uint16 maxInstructionDefs;
185 le_uint16 maxStackElements;
186 le_uint16 maxSizeOfInstructions;
187 le_uint16 maxComponentElements;
188 le_uint16 maxComponentDepth;
189 };
190
191 struct HHEATable
192 {
193 fixed version;
194 le_int16 ascent;
195 le_int16 descent;
196 le_int16 lineGap;
197 le_uint16 advanceWidthMax;
198 le_int16 minLeftSideBearing;
199 le_int16 minRightSideBearing;
200 le_int16 xMaxExtent;
201 le_int16 caretSlopeRise;
202 le_int16 caretSlopeRun;
203 le_int16 caretOffset;
204 le_int16 reserved1;
205 le_int16 reserved2;
206 le_int16 reserved3;
207 le_int16 reserved4;
208 le_int16 metricDataFormat;
209 le_uint16 numOfLongHorMetrics;
210 };
211
212 struct LongHorMetric
213 {
214 le_uint16 advanceWidth;
215 le_int16 leftSideBearing;
216 };
217
218 struct HMTXTable
219 {
220 LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
221 // le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
222 };
223
224 #endif
225