sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
wofftypes.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * wofftypes.h
4 *
5 * Basic WOFF/WOFF2 type definitions and interface (specification
6 * only).
7 *
8 * Copyright (C) 1996-2025 by
9 * David Turner, Robert Wilhelm, and Werner Lemberg.
10 *
11 * This file is part of the FreeType project, and may only be used,
12 * modified, and distributed under the terms of the FreeType project
13 * license, LICENSE.TXT. By continuing to use, modify, or distribute
14 * this file you indicate that you have read the license and
15 * understand and accept it fully.
16 *
17 */
18
19
24#ifndef WOFFTYPES_H_
25#define WOFFTYPES_H_
26
27
28#include <freetype/tttables.h>
30
31
32FT_BEGIN_HEADER
33
34
35 /**************************************************************************
36 *
37 * @struct:
38 * WOFF_HeaderRec
39 *
40 * @description:
41 * WOFF file format header.
42 *
43 * @fields:
44 * See
45 *
46 * https://www.w3.org/TR/WOFF/#WOFFHeader
47 */
48 typedef struct WOFF_HeaderRec_
49 {
50 FT_ULong signature;
51 FT_ULong flavor;
52 FT_ULong length;
53 FT_UShort num_tables;
54 FT_UShort reserved;
55 FT_ULong totalSfntSize;
56 FT_UShort majorVersion;
57 FT_UShort minorVersion;
58 FT_ULong metaOffset;
59 FT_ULong metaLength;
60 FT_ULong metaOrigLength;
61 FT_ULong privOffset;
62 FT_ULong privLength;
63
64 } WOFF_HeaderRec, *WOFF_Header;
65
66
67 /**************************************************************************
68 *
69 * @struct:
70 * WOFF_TableRec
71 *
72 * @description:
73 * This structure describes a given table of a WOFF font.
74 *
75 * @fields:
76 * Tag ::
77 * A four-bytes tag describing the table.
78 *
79 * Offset ::
80 * The offset of the table from the start of the WOFF font in its
81 * resource.
82 *
83 * CompLength ::
84 * Compressed table length (in bytes).
85 *
86 * OrigLength ::
87 * Uncompressed table length (in bytes).
88 *
89 * CheckSum ::
90 * The table checksum. This value can be ignored.
91 *
92 * OrigOffset ::
93 * The uncompressed table file offset. This value gets computed while
94 * constructing the (uncompressed) SFNT header. It is not contained in
95 * the WOFF file.
96 */
97 typedef struct WOFF_TableRec_
98 {
99 FT_Tag Tag; /* table ID */
100 FT_ULong Offset; /* table file offset */
101 FT_ULong CompLength; /* compressed table length */
102 FT_ULong OrigLength; /* uncompressed table length */
103 FT_ULong CheckSum; /* uncompressed checksum */
104
105 FT_ULong OrigOffset; /* uncompressed table file offset */
106 /* (not in the WOFF file) */
107 } WOFF_TableRec, *WOFF_Table;
108
109
110 /**************************************************************************
111 *
112 * @struct:
113 * WOFF2_TtcFontRec
114 *
115 * @description:
116 * Metadata for a TTC font entry in WOFF2.
117 *
118 * @fields:
119 * flavor ::
120 * TTC font flavor.
121 *
122 * num_tables ::
123 * Number of tables in TTC, indicating number of elements in
124 * `table_indices`.
125 *
126 * table_indices ::
127 * Array of table indices for each TTC font.
128 */
129 typedef struct WOFF2_TtcFontRec_
130 {
131 FT_ULong flavor;
132 FT_UShort num_tables;
133 FT_UShort* table_indices;
134
135 } WOFF2_TtcFontRec, *WOFF2_TtcFont;
136
137
138 /**************************************************************************
139 *
140 * @struct:
141 * WOFF2_HeaderRec
142 *
143 * @description:
144 * WOFF2 file format header.
145 *
146 * @fields:
147 * See
148 *
149 * https://www.w3.org/TR/WOFF2/#woff20Header
150 *
151 * @note:
152 * We don't care about the fields `reserved`, `majorVersion` and
153 * `minorVersion`, so they are not included. The `totalSfntSize` field
154 * does not necessarily represent the actual size of the uncompressed
155 * SFNT font stream, so that is used as a reference value instead.
156 */
157 typedef struct WOFF2_HeaderRec_
158 {
159 FT_ULong signature;
160 FT_ULong flavor;
161 FT_ULong length;
162 FT_UShort num_tables;
163 FT_ULong totalSfntSize;
164 FT_ULong totalCompressedSize;
165 FT_ULong metaOffset;
166 FT_ULong metaLength;
167 FT_ULong metaOrigLength;
168 FT_ULong privOffset;
169 FT_ULong privLength;
170
171 FT_ULong uncompressed_size; /* uncompressed brotli stream size */
172 FT_ULong compressed_offset; /* compressed stream offset */
173 FT_ULong header_version; /* version of original TTC Header */
174 FT_UShort num_fonts; /* number of fonts in TTC */
175 FT_ULong actual_sfnt_size; /* actual size of sfnt stream */
176
177 WOFF2_TtcFont ttc_fonts; /* metadata for fonts in a TTC */
178
179 } WOFF2_HeaderRec, *WOFF2_Header;
180
181
182 /**************************************************************************
183 *
184 * @struct:
185 * WOFF2_TableRec
186 *
187 * @description:
188 * This structure describes a given table of a WOFF2 font.
189 *
190 * @fields:
191 * See
192 *
193 * https://www.w3.org/TR/WOFF2/#table_dir_format
194 */
195 typedef struct WOFF2_TableRec_
196 {
197 FT_Byte FlagByte; /* table type and flags */
198 FT_Tag Tag; /* table file offset */
199 FT_ULong dst_length; /* uncompressed table length */
200 FT_ULong TransformLength; /* transformed length */
201
202 FT_ULong flags; /* calculated flags */
203 FT_ULong src_offset; /* compressed table offset */
204 FT_ULong src_length; /* compressed table length */
205 FT_ULong dst_offset; /* uncompressed table offset */
206
207 } WOFF2_TableRec, *WOFF2_Table;
208
209
210 /**************************************************************************
211 *
212 * @struct:
213 * WOFF2_InfoRec
214 *
215 * @description:
216 * Metadata for WOFF2 font that may be required for reconstruction of
217 * sfnt tables.
218 *
219 * @fields:
220 * header_checksum ::
221 * Checksum of SFNT offset table.
222 *
223 * num_glyphs ::
224 * Number of glyphs in the font.
225 *
226 * num_hmetrics ::
227 * `numberOfHMetrics` field in the 'hhea' table.
228 *
229 * x_mins ::
230 * `xMin` values of glyph bounding box.
231 *
232 * glyf_table ::
233 * A pointer to the `glyf' table record.
234 *
235 * loca_table ::
236 * A pointer to the `loca' table record.
237 *
238 * head_table ::
239 * A pointer to the `head' table record.
240 */
241 typedef struct WOFF2_InfoRec_
242 {
243 FT_ULong header_checksum;
244 FT_UShort num_glyphs;
245 FT_UShort num_hmetrics;
246 FT_Short* x_mins;
247
248 WOFF2_Table glyf_table;
249 WOFF2_Table loca_table;
250 WOFF2_Table head_table;
251
252 } WOFF2_InfoRec, *WOFF2_Info;
253
254
255 /**************************************************************************
256 *
257 * @struct:
258 * WOFF2_SubstreamRec
259 *
260 * @description:
261 * This structure stores information about a substream in the transformed
262 * 'glyf' table in a WOFF2 stream.
263 *
264 * @fields:
265 * start ::
266 * Beginning of the substream relative to uncompressed table stream.
267 *
268 * offset ::
269 * Offset of the substream relative to uncompressed table stream.
270 *
271 * size ::
272 * Size of the substream.
273 */
274 typedef struct WOFF2_SubstreamRec_
275 {
276 FT_ULong start;
277 FT_ULong offset;
278 FT_ULong size;
279
280 } WOFF2_SubstreamRec, *WOFF2_Substream;
281
282
283 /**************************************************************************
284 *
285 * @struct:
286 * WOFF2_PointRec
287 *
288 * @description:
289 * This structure stores information about a point in the transformed
290 * 'glyf' table in a WOFF2 stream.
291 *
292 * @fields:
293 * x ::
294 * x-coordinate of point.
295 *
296 * y ::
297 * y-coordinate of point.
298 *
299 * on_curve ::
300 * Set if point is on-curve.
301 */
302 typedef struct WOFF2_PointRec_
303 {
304 FT_Int x;
305 FT_Int y;
306 FT_Bool on_curve;
307
308 } WOFF2_PointRec, *WOFF2_Point;
309
310
311FT_END_HEADER
312
313#endif /* WOFFTYPES_H_ */
314
315
316/* END */