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