sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ttgxvar.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ttgxvar.h
4 *
5 * TrueType GX Font Variation loader (specification)
6 *
7 * Copyright (C) 2004-2025 by
8 * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
9 *
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
15 *
16 */
17
18
23#ifndef TTGXVAR_H_
24#define TTGXVAR_H_
25
26
28#include "ttobjs.h"
29
30
31FT_BEGIN_HEADER
32
33
34#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
35
36 /**************************************************************************
37 *
38 * @Struct:
39 * GX_AVarCorrespondenceRec
40 *
41 * @Description:
42 * A data structure representing `shortFracCorrespondence' in `avar'
43 * table according to the specifications from Apple.
44 */
45 typedef struct GX_AVarCorrespondenceRec_
46 {
47 FT_Fixed fromCoord;
48 FT_Fixed toCoord;
49
50 } GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence;
51
52
53 /**************************************************************************
54 *
55 * @Struct:
56 * GX_AVarRec
57 *
58 * @Description:
59 * Data from the segment field of `avar' table.
60 * There is one of these for each axis.
61 */
62 typedef struct GX_AVarSegmentRec_
63 {
64 FT_UShort pairCount;
65 GX_AVarCorrespondence correspondence; /* array with pairCount entries */
66
67 } GX_AVarSegmentRec, *GX_AVarSegment;
68
69
70 /**************************************************************************
71 *
72 * @Struct:
73 * GX_AVarTableRec
74 *
75 * @Description:
76 * Data from the `avar' table.
77 */
78 typedef struct GX_AVarTableRec_
79 {
80 GX_AVarSegment avar_segment; /* avar_segment[num_axis] */
81 GX_ItemVarStoreRec itemStore; /* Item Variation Store */
82 GX_DeltaSetIdxMapRec axisMap; /* Axis Mapping */
83
84 } GX_AVarTableRec, *GX_AVarTable;
85
86
87 /**************************************************************************
88 *
89 * @Struct:
90 * GX_HVVarTableRec
91 *
92 * @Description:
93 * Data from either the `HVAR' or `VVAR' table.
94 */
95 typedef struct GX_HVVarTableRec_
96 {
97 GX_ItemVarStoreRec itemStore; /* Item Variation Store */
98 GX_DeltaSetIdxMapRec widthMap; /* Advance Width Mapping */
99
100#if 0
101 GX_DeltaSetIdxMapRec lsbMap; /* not implemented */
102 GX_DeltaSetIdxMapRec rsbMap; /* not implemented */
103
104 GX_DeltaSetIdxMapRec tsbMap; /* not implemented */
105 GX_DeltaSetIdxMapRec bsbMap; /* not implemented */
106 GX_DeltaSetIdxMapRec vorgMap; /* not implemented */
107#endif
108
109 } GX_HVVarTableRec, *GX_HVVarTable;
110
111
112#define MVAR_TAG_GASP_0 FT_MAKE_TAG( 'g', 's', 'p', '0' )
113#define MVAR_TAG_GASP_1 FT_MAKE_TAG( 'g', 's', 'p', '1' )
114#define MVAR_TAG_GASP_2 FT_MAKE_TAG( 'g', 's', 'p', '2' )
115#define MVAR_TAG_GASP_3 FT_MAKE_TAG( 'g', 's', 'p', '3' )
116#define MVAR_TAG_GASP_4 FT_MAKE_TAG( 'g', 's', 'p', '4' )
117#define MVAR_TAG_GASP_5 FT_MAKE_TAG( 'g', 's', 'p', '5' )
118#define MVAR_TAG_GASP_6 FT_MAKE_TAG( 'g', 's', 'p', '6' )
119#define MVAR_TAG_GASP_7 FT_MAKE_TAG( 'g', 's', 'p', '7' )
120#define MVAR_TAG_GASP_8 FT_MAKE_TAG( 'g', 's', 'p', '8' )
121#define MVAR_TAG_GASP_9 FT_MAKE_TAG( 'g', 's', 'p', '9' )
122
123#define MVAR_TAG_CPHT FT_MAKE_TAG( 'c', 'p', 'h', 't' )
124#define MVAR_TAG_HASC FT_MAKE_TAG( 'h', 'a', 's', 'c' )
125#define MVAR_TAG_HCLA FT_MAKE_TAG( 'h', 'c', 'l', 'a' )
126#define MVAR_TAG_HCLD FT_MAKE_TAG( 'h', 'c', 'l', 'd' )
127#define MVAR_TAG_HCOF FT_MAKE_TAG( 'h', 'c', 'o', 'f' )
128#define MVAR_TAG_HCRN FT_MAKE_TAG( 'h', 'c', 'r', 'n' )
129#define MVAR_TAG_HCRS FT_MAKE_TAG( 'h', 'c', 'r', 's' )
130#define MVAR_TAG_HDSC FT_MAKE_TAG( 'h', 'd', 's', 'c' )
131#define MVAR_TAG_HLGP FT_MAKE_TAG( 'h', 'l', 'g', 'p' )
132#define MVAR_TAG_SBXO FT_MAKE_TAG( 's', 'b', 'x', 'o' )
133#define MVAR_TAG_SBXS FT_MAKE_TAG( 's', 'b', 'x', 's' )
134#define MVAR_TAG_SBYO FT_MAKE_TAG( 's', 'b', 'y', 'o' )
135#define MVAR_TAG_SBYS FT_MAKE_TAG( 's', 'b', 'y', 's' )
136#define MVAR_TAG_SPXO FT_MAKE_TAG( 's', 'p', 'x', 'o' )
137#define MVAR_TAG_SPXS FT_MAKE_TAG( 's', 'p', 'x', 's' )
138#define MVAR_TAG_SPYO FT_MAKE_TAG( 's', 'p', 'y', 'o' )
139#define MVAR_TAG_SPYS FT_MAKE_TAG( 's', 'p', 'y', 's' )
140#define MVAR_TAG_STRO FT_MAKE_TAG( 's', 't', 'r', 'o' )
141#define MVAR_TAG_STRS FT_MAKE_TAG( 's', 't', 'r', 's' )
142#define MVAR_TAG_UNDO FT_MAKE_TAG( 'u', 'n', 'd', 'o' )
143#define MVAR_TAG_UNDS FT_MAKE_TAG( 'u', 'n', 'd', 's' )
144#define MVAR_TAG_VASC FT_MAKE_TAG( 'v', 'a', 's', 'c' )
145#define MVAR_TAG_VCOF FT_MAKE_TAG( 'v', 'c', 'o', 'f' )
146#define MVAR_TAG_VCRN FT_MAKE_TAG( 'v', 'c', 'r', 'n' )
147#define MVAR_TAG_VCRS FT_MAKE_TAG( 'v', 'c', 'r', 's' )
148#define MVAR_TAG_VDSC FT_MAKE_TAG( 'v', 'd', 's', 'c' )
149#define MVAR_TAG_VLGP FT_MAKE_TAG( 'v', 'l', 'g', 'p' )
150#define MVAR_TAG_XHGT FT_MAKE_TAG( 'x', 'h', 'g', 't' )
151
152
153 typedef struct GX_ValueRec_
154 {
155 FT_ULong tag;
156 FT_UShort outerIndex;
157 FT_UShort innerIndex;
158
159 FT_Short unmodified; /* values are either FT_Short or FT_UShort */
160
161 } GX_ValueRec, *GX_Value;
162
163
164 /**************************************************************************
165 *
166 * @Struct:
167 * GX_MVarTableRec
168 *
169 * @Description:
170 * Data from the `MVAR' table.
171 */
172 typedef struct GX_MVarTableRec_
173 {
174 FT_UShort valueCount;
175
176 GX_ItemVarStoreRec itemStore; /* Item Variation Store */
177 GX_Value values; /* Value Records */
178
179 } GX_MVarTableRec, *GX_MVarTable;
180
181
182 /**************************************************************************
183 *
184 * @Struct:
185 * GX_BlendRec
186 *
187 * @Description:
188 * Data for interpolating a font from a distortable font specified
189 * by the GX *var tables ([fgcahvm]var).
190 *
191 * @Fields:
192 * num_axis ::
193 * The number of axes along which interpolation may happen.
194 *
195 * coords ::
196 * An array of design coordinates (in user space) indicating the
197 * contribution along each axis to the final interpolated font.
198 * `normalizedcoords' holds the same values.
199 *
200 * normalizedcoords ::
201 * An array of normalized values (between [-1,1]) indicating the
202 * contribution along each axis to the final interpolated font.
203 * `coords' holds the same values.
204 *
205 * mmvar ::
206 * Data from the `fvar' table.
207 *
208 * mmvar_len ::
209 * The length of the `mmvar' structure.
210 *
211 * normalized_stylecoords ::
212 * A two-dimensional array that holds the named instance data from
213 * `mmvar' as normalized values.
214 *
215 * avar_loaded ::
216 * A Boolean; if set, FreeType tried to load (and parse) the `avar'
217 * table.
218 *
219 * avar_table ::
220 * Data from the `avar' table.
221 *
222 * hvar_loaded ::
223 * A Boolean; if set, FreeType tried to load (and parse) the `hvar'
224 * table.
225 *
226 * hvar_checked ::
227 * A Boolean; if set, FreeType successfully loaded and parsed the
228 * `hvar' table.
229 *
230 * hvar_error ::
231 * If loading and parsing of the `hvar' table failed, this field
232 * holds the corresponding error code.
233 *
234 * hvar_table ::
235 * Data from the `hvar' table.
236 *
237 * vvar_loaded ::
238 * A Boolean; if set, FreeType tried to load (and parse) the `vvar'
239 * table.
240 *
241 * vvar_checked ::
242 * A Boolean; if set, FreeType successfully loaded and parsed the
243 * `vvar' table.
244 *
245 * vvar_error ::
246 * If loading and parsing of the `vvar' table failed, this field
247 * holds the corresponding error code.
248 *
249 * vvar_table ::
250 * Data from the `vvar' table.
251 *
252 * mvar_table ::
253 * Data from the `mvar' table.
254 *
255 * tuplecount ::
256 * The number of shared tuples in the `gvar' table.
257 *
258 * tuplecoords ::
259 * A two-dimensional array that holds the shared tuple coordinates
260 * in the `gvar' table.
261 *
262 * tuplescalars ::
263 * A one-dimensional array that holds the shared tuple
264 * scalars in the `gvar' table for current face coordinates.
265 *
266 * gv_glyphcnt ::
267 * The number of glyphs handled in the `gvar' table.
268 *
269 * glyphoffsets ::
270 * Offsets into the glyph variation data array.
271 *
272 * gvar_size ::
273 * The size of the `gvar' table.
274 */
275 typedef struct GX_BlendRec_
276 {
277 FT_UInt num_axis;
278 FT_Fixed* coords;
279 FT_Fixed* normalizedcoords;
280
281 FT_MM_Var* mmvar;
282 FT_Offset mmvar_len;
283
284 FT_Fixed* normalized_stylecoords;
285 /* normalized_stylecoords[num_namedstyles][num_axis] */
286
287 FT_Bool avar_loaded;
288 GX_AVarTable avar_table;
289
290 FT_Bool hvar_loaded;
291 FT_Bool hvar_checked;
292 FT_Error hvar_error;
293 GX_HVVarTable hvar_table;
294
295 FT_Bool vvar_loaded;
296 FT_Bool vvar_checked;
297 FT_Error vvar_error;
298 GX_HVVarTable vvar_table;
299
300 GX_MVarTable mvar_table;
301
302 FT_UInt tuplecount;
303 FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][num_axis] */
304 FT_Fixed* tuplescalars; /* tuplescalars[tuplecount] */
305
306 FT_UInt gv_glyphcnt;
307 FT_ULong* glyphoffsets; /* glyphoffsets[gv_glyphcnt + 1] */
308
309 FT_ULong gvar_size;
310
311 } GX_BlendRec;
312
313
314 /**************************************************************************
315 *
316 * @enum:
317 * GX_TupleCountFlags
318 *
319 * @Description:
320 * Flags used within the `TupleCount' field of the `gvar' table.
321 */
322 typedef enum GX_TupleCountFlags_
323 {
324 GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000,
325 GX_TC_RESERVED_TUPLE_FLAGS = 0x7000,
326 GX_TC_TUPLE_COUNT_MASK = 0x0FFF
327
328 } GX_TupleCountFlags;
329
330
331 /**************************************************************************
332 *
333 * @enum:
334 * GX_TupleIndexFlags
335 *
336 * @Description:
337 * Flags used within the `TupleIndex' field of the `gvar' and `cvar'
338 * tables.
339 */
340 typedef enum GX_TupleIndexFlags_
341 {
342 GX_TI_EMBEDDED_TUPLE_COORD = 0x8000,
343 GX_TI_INTERMEDIATE_TUPLE = 0x4000,
344 GX_TI_PRIVATE_POINT_NUMBERS = 0x2000,
345 GX_TI_RESERVED_TUPLE_FLAG = 0x1000,
346 GX_TI_TUPLE_INDEX_MASK = 0x0FFF
347
348 } GX_TupleIndexFlags;
349
350
351#define TTAG_wght FT_MAKE_TAG( 'w', 'g', 'h', 't' )
352#define TTAG_wdth FT_MAKE_TAG( 'w', 'd', 't', 'h' )
353#define TTAG_opsz FT_MAKE_TAG( 'o', 'p', 's', 'z' )
354#define TTAG_slnt FT_MAKE_TAG( 's', 'l', 'n', 't' )
355#define TTAG_ital FT_MAKE_TAG( 'i', 't', 'a', 'l' )
356
357
358 FT_LOCAL( FT_Error )
359 TT_Set_MM_Blend( FT_Face face,
360 FT_UInt num_coords,
361 FT_Fixed* coords );
362
363 FT_LOCAL( FT_Error )
364 TT_Get_MM_Blend( FT_Face face,
365 FT_UInt num_coords,
366 FT_Fixed* coords );
367
368 FT_LOCAL( FT_Error )
369 TT_Set_Var_Design( FT_Face face,
370 FT_UInt num_coords,
371 FT_Fixed* coords );
372
373 FT_LOCAL( FT_Error )
374 TT_Get_MM_Var( FT_Face face,
375 FT_MM_Var* *master );
376
377 FT_LOCAL( FT_Error )
378 TT_Get_Var_Design( FT_Face face,
379 FT_UInt num_coords,
380 FT_Fixed* coords );
381
382 FT_LOCAL( FT_Error )
383 TT_Set_Named_Instance( FT_Face face,
384 FT_UInt instance_index );
385
386 FT_LOCAL( FT_Error )
387 TT_Get_Default_Named_Instance( FT_Face face,
388 FT_UInt *instance_index );
389
390 FT_LOCAL( void )
391 tt_construct_ps_name( FT_Face face );
392
393 FT_LOCAL( FT_Error )
394 tt_face_vary_cvt( TT_Face face,
395 FT_Stream stream );
396
397
398 FT_LOCAL( FT_Error )
399 TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
400 FT_Outline* outline,
401 FT_Vector* unrounded );
402
403 FT_LOCAL( FT_Error )
404 tt_hadvance_adjust( FT_Face face,
405 FT_UInt gindex,
406 FT_Int *adelta );
407
408 FT_LOCAL( FT_Error )
409 tt_vadvance_adjust( FT_Face face,
410 FT_UInt gindex,
411 FT_Int *adelta );
412
413 FT_LOCAL( void )
414 tt_apply_mvar( FT_Face face );
415
416 FT_LOCAL( FT_Error )
417 tt_var_load_item_variation_store( FT_Face face,
418 FT_ULong offset,
419 GX_ItemVarStore itemStore );
420
421 FT_LOCAL( FT_Error )
422 tt_var_load_delta_set_index_mapping( FT_Face face,
423 FT_ULong offset,
424 GX_DeltaSetIdxMap map,
425 GX_ItemVarStore itemStore,
426 FT_ULong table_len );
427
428 FT_LOCAL( FT_ItemVarDelta )
429 tt_var_get_item_delta( FT_Face face,
430 GX_ItemVarStore itemStore,
431 FT_UInt outerIndex,
432 FT_UInt innerIndex );
433
434 FT_LOCAL( void )
435 tt_var_done_item_variation_store( FT_Face face,
436 GX_ItemVarStore itemStore );
437
438 FT_LOCAL( void )
439 tt_var_done_delta_set_index_map( FT_Face face,
440 GX_DeltaSetIdxMap deltaSetIdxMap );
441
442
443 FT_LOCAL( FT_Error )
444 tt_get_var_blend( FT_Face face,
445 FT_UInt *num_coords,
446 FT_Fixed* *coords,
447 FT_Fixed* *normalizedcoords,
448 FT_MM_Var* *mm_var );
449
450 FT_LOCAL( void )
451 tt_done_blend( FT_Face face );
452
453#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
454
455
456FT_END_HEADER
457
458
459#endif /* TTGXVAR_H_ */
460
461
462/* END */