1 /****************************************************************************
5 * TrueType GX Font Variation loader (specification)
7 * Copyright (C) 2004-2020 by
8 * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
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.
29 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
31 /**************************************************************************
34 * GX_AVarCorrespondenceRec
37 * A data structure representing `shortFracCorrespondence' in `avar'
38 * table according to the specifications from Apple.
40 typedef struct GX_AVarCorrespondenceRec_
45 } GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence;
48 /**************************************************************************
54 * Data from the segment field of `avar' table.
55 * There is one of these for each axis.
57 typedef struct GX_AVarSegmentRec_
60 GX_AVarCorrespondence correspondence; /* array with pairCount entries */
62 } GX_AVarSegmentRec, *GX_AVarSegment;
65 typedef struct GX_ItemVarDataRec_
67 FT_UInt itemCount; /* number of delta sets per item */
68 FT_UInt regionIdxCount; /* number of region indices in this data */
69 FT_UInt* regionIndices; /* array of `regionCount' indices; */
70 /* these index `varRegionList' */
71 FT_Short* deltaSet; /* array of `itemCount' deltas */
72 /* use `innerIndex' for this array */
74 } GX_ItemVarDataRec, *GX_ItemVarData;
77 /* contribution of one axis to a region */
78 typedef struct GX_AxisCoordsRec_
81 FT_Fixed peakCoord; /* zero means no effect (factor = 1) */
84 } GX_AxisCoordsRec, *GX_AxisCoords;
87 typedef struct GX_VarRegionRec_
89 GX_AxisCoords axisList; /* array of axisCount records */
91 } GX_VarRegionRec, *GX_VarRegion;
94 /* item variation store */
95 typedef struct GX_ItemVarStoreRec_
98 GX_ItemVarData varData; /* array of dataCount records; */
99 /* use `outerIndex' for this array */
101 FT_UInt regionCount; /* total number of regions defined */
102 GX_VarRegion varRegionList;
104 } GX_ItemVarStoreRec, *GX_ItemVarStore;
107 typedef struct GX_DeltaSetIdxMapRec_
110 FT_UInt* outerIndex; /* indices to item var data */
111 FT_UInt* innerIndex; /* indices to delta set */
113 } GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap;
116 /**************************************************************************
122 * Data from either the `HVAR' or `VVAR' table.
124 typedef struct GX_HVVarTableRec_
126 GX_ItemVarStoreRec itemStore; /* Item Variation Store */
127 GX_DeltaSetIdxMapRec widthMap; /* Advance Width Mapping */
130 GX_DeltaSetIdxMapRec lsbMap; /* not implemented */
131 GX_DeltaSetIdxMapRec rsbMap; /* not implemented */
133 GX_DeltaSetIdxMapRec tsbMap; /* not implemented */
134 GX_DeltaSetIdxMapRec bsbMap; /* not implemented */
135 GX_DeltaSetIdxMapRec vorgMap; /* not implemented */
138 } GX_HVVarTableRec, *GX_HVVarTable;
141 #define MVAR_TAG_GASP_0 FT_MAKE_TAG( 'g', 's', 'p', '0' )
142 #define MVAR_TAG_GASP_1 FT_MAKE_TAG( 'g', 's', 'p', '1' )
143 #define MVAR_TAG_GASP_2 FT_MAKE_TAG( 'g', 's', 'p', '2' )
144 #define MVAR_TAG_GASP_3 FT_MAKE_TAG( 'g', 's', 'p', '3' )
145 #define MVAR_TAG_GASP_4 FT_MAKE_TAG( 'g', 's', 'p', '4' )
146 #define MVAR_TAG_GASP_5 FT_MAKE_TAG( 'g', 's', 'p', '5' )
147 #define MVAR_TAG_GASP_6 FT_MAKE_TAG( 'g', 's', 'p', '6' )
148 #define MVAR_TAG_GASP_7 FT_MAKE_TAG( 'g', 's', 'p', '7' )
149 #define MVAR_TAG_GASP_8 FT_MAKE_TAG( 'g', 's', 'p', '8' )
150 #define MVAR_TAG_GASP_9 FT_MAKE_TAG( 'g', 's', 'p', '9' )
152 #define MVAR_TAG_CPHT FT_MAKE_TAG( 'c', 'p', 'h', 't' )
153 #define MVAR_TAG_HASC FT_MAKE_TAG( 'h', 'a', 's', 'c' )
154 #define MVAR_TAG_HCLA FT_MAKE_TAG( 'h', 'c', 'l', 'a' )
155 #define MVAR_TAG_HCLD FT_MAKE_TAG( 'h', 'c', 'l', 'd' )
156 #define MVAR_TAG_HCOF FT_MAKE_TAG( 'h', 'c', 'o', 'f' )
157 #define MVAR_TAG_HCRN FT_MAKE_TAG( 'h', 'c', 'r', 'n' )
158 #define MVAR_TAG_HCRS FT_MAKE_TAG( 'h', 'c', 'r', 's' )
159 #define MVAR_TAG_HDSC FT_MAKE_TAG( 'h', 'd', 's', 'c' )
160 #define MVAR_TAG_HLGP FT_MAKE_TAG( 'h', 'l', 'g', 'p' )
161 #define MVAR_TAG_SBXO FT_MAKE_TAG( 's', 'b', 'x', 'o' )
162 #define MVAR_TAG_SBXS FT_MAKE_TAG( 's', 'b', 'x', 's' )
163 #define MVAR_TAG_SBYO FT_MAKE_TAG( 's', 'b', 'y', 'o' )
164 #define MVAR_TAG_SBYS FT_MAKE_TAG( 's', 'b', 'y', 's' )
165 #define MVAR_TAG_SPXO FT_MAKE_TAG( 's', 'p', 'x', 'o' )
166 #define MVAR_TAG_SPXS FT_MAKE_TAG( 's', 'p', 'x', 's' )
167 #define MVAR_TAG_SPYO FT_MAKE_TAG( 's', 'p', 'y', 'o' )
168 #define MVAR_TAG_SPYS FT_MAKE_TAG( 's', 'p', 'y', 's' )
169 #define MVAR_TAG_STRO FT_MAKE_TAG( 's', 't', 'r', 'o' )
170 #define MVAR_TAG_STRS FT_MAKE_TAG( 's', 't', 'r', 's' )
171 #define MVAR_TAG_UNDO FT_MAKE_TAG( 'u', 'n', 'd', 'o' )
172 #define MVAR_TAG_UNDS FT_MAKE_TAG( 'u', 'n', 'd', 's' )
173 #define MVAR_TAG_VASC FT_MAKE_TAG( 'v', 'a', 's', 'c' )
174 #define MVAR_TAG_VCOF FT_MAKE_TAG( 'v', 'c', 'o', 'f' )
175 #define MVAR_TAG_VCRN FT_MAKE_TAG( 'v', 'c', 'r', 'n' )
176 #define MVAR_TAG_VCRS FT_MAKE_TAG( 'v', 'c', 'r', 's' )
177 #define MVAR_TAG_VDSC FT_MAKE_TAG( 'v', 'd', 's', 'c' )
178 #define MVAR_TAG_VLGP FT_MAKE_TAG( 'v', 'l', 'g', 'p' )
179 #define MVAR_TAG_XHGT FT_MAKE_TAG( 'x', 'h', 'g', 't' )
182 typedef struct GX_ValueRec_
185 FT_UShort outerIndex;
186 FT_UShort innerIndex;
188 FT_Short unmodified; /* values are either FT_Short or FT_UShort */
190 } GX_ValueRec, *GX_Value;
193 /**************************************************************************
199 * Data from the `MVAR' table.
201 typedef struct GX_MVarTableRec_
203 FT_UShort valueCount;
205 GX_ItemVarStoreRec itemStore; /* Item Variation Store */
206 GX_Value values; /* Value Records */
208 } GX_MVarTableRec, *GX_MVarTable;
211 /**************************************************************************
217 * Data for interpolating a font from a distortable font specified
218 * by the GX *var tables ([fgcahvm]var).
222 * The number of axes along which interpolation may happen.
225 * An array of design coordinates (in user space) indicating the
226 * contribution along each axis to the final interpolated font.
227 * `normalizedcoords' holds the same values.
229 * normalizedcoords ::
230 * An array of normalized values (between [-1,1]) indicating the
231 * contribution along each axis to the final interpolated font.
232 * `coords' holds the same values.
235 * Data from the `fvar' table.
238 * The length of the `mmvar' structure.
240 * normalized_stylecoords ::
241 * A two-dimensional array that holds the named instance data from
242 * `mmvar' as normalized values.
245 * A Boolean; if set, FreeType tried to load (and parse) the `avar'
249 * Data from the `avar' table.
252 * A Boolean; if set, FreeType tried to load (and parse) the `hvar'
256 * A Boolean; if set, FreeType successfully loaded and parsed the
260 * If loading and parsing of the `hvar' table failed, this field
261 * holds the corresponding error code.
264 * Data from the `hvar' table.
267 * A Boolean; if set, FreeType tried to load (and parse) the `vvar'
271 * A Boolean; if set, FreeType successfully loaded and parsed the
275 * If loading and parsing of the `vvar' table failed, this field
276 * holds the corresponding error code.
279 * Data from the `vvar' table.
282 * Data from the `mvar' table.
285 * The number of shared tuples in the `gvar' table.
288 * A two-dimensional array that holds the shared tuple coordinates
289 * in the `gvar' table.
292 * The number of glyphs handled in the `gvar' table.
295 * Offsets into the glyph variation data array.
298 * The size of the `gvar' table.
300 typedef struct GX_BlendRec_
304 FT_Fixed* normalizedcoords;
309 FT_Fixed* normalized_stylecoords;
310 /* normalized_stylecoords[num_namedstyles][num_axis] */
313 GX_AVarSegment avar_segment; /* avar_segment[num_axis] */
316 FT_Bool hvar_checked;
318 GX_HVVarTable hvar_table;
321 FT_Bool vvar_checked;
323 GX_HVVarTable vvar_table;
325 GX_MVarTable mvar_table;
328 FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][num_axis] */
331 FT_ULong* glyphoffsets; /* glyphoffsets[gv_glyphcnt + 1] */
338 /**************************************************************************
344 * Flags used within the `TupleCount' field of the `gvar' table.
346 typedef enum GX_TupleCountFlags_
348 GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000,
349 GX_TC_RESERVED_TUPLE_FLAGS = 0x7000,
350 GX_TC_TUPLE_COUNT_MASK = 0x0FFF
352 } GX_TupleCountFlags;
355 /**************************************************************************
361 * Flags used within the `TupleIndex' field of the `gvar' and `cvar'
364 typedef enum GX_TupleIndexFlags_
366 GX_TI_EMBEDDED_TUPLE_COORD = 0x8000,
367 GX_TI_INTERMEDIATE_TUPLE = 0x4000,
368 GX_TI_PRIVATE_POINT_NUMBERS = 0x2000,
369 GX_TI_RESERVED_TUPLE_FLAG = 0x1000,
370 GX_TI_TUPLE_INDEX_MASK = 0x0FFF
372 } GX_TupleIndexFlags;
375 #define TTAG_wght FT_MAKE_TAG( 'w', 'g', 'h', 't' )
376 #define TTAG_wdth FT_MAKE_TAG( 'w', 'd', 't', 'h' )
377 #define TTAG_opsz FT_MAKE_TAG( 'o', 'p', 's', 'z' )
378 #define TTAG_slnt FT_MAKE_TAG( 's', 'l', 'n', 't' )
382 TT_Set_MM_Blend( TT_Face face,
387 TT_Get_MM_Blend( TT_Face face,
392 TT_Set_Var_Design( TT_Face face,
397 TT_Get_MM_Var( TT_Face face,
398 FT_MM_Var* *master );
401 TT_Get_Var_Design( TT_Face face,
406 TT_Set_Named_Instance( TT_Face face,
407 FT_UInt instance_index );
410 tt_face_vary_cvt( TT_Face face,
415 TT_Vary_Apply_Glyph_Deltas( TT_Face face,
418 FT_Vector* unrounded,
422 tt_hadvance_adjust( TT_Face face,
427 tt_vadvance_adjust( TT_Face face,
432 tt_apply_mvar( TT_Face face );
435 tt_get_var_blend( TT_Face face,
438 FT_Fixed* *normalizedcoords,
439 FT_MM_Var* *mm_var );
442 tt_done_blend( TT_Face face );
444 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
450 #endif /* TTGXVAR_H_ */