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