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 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' ) 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, | 1 /**************************************************************************** 2 * 3 * ttgxvar.h 4 * 5 * TrueType GX Font Variation loader (specification) 6 * 7 * Copyright (C) 2004-2019 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 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' ) 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, |