1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
/***************************************************************************/
/* */
/* cfftypes.h */
/* */
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef CFFTYPES_H_
#define CFFTYPES_H_
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TYPE1_TABLES_H
#include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Struct> */
/* CFF_IndexRec */
/* */
/* <Description> */
/* A structure used to model a CFF Index table. */
/* */
/* <Fields> */
/* stream :: The source input stream. */
/* */
/* start :: The position of the first index byte in the */
/* input stream. */
/* */
/* count :: The number of elements in the index. */
/* */
/* off_size :: The size in bytes of object offsets in index. */
/* */
/* data_offset :: The position of first data byte in the index's */
/* bytes. */
/* */
/* data_size :: The size of the data table in this index. */
/* */
/* offsets :: A table of element offsets in the index. Must be */
/* loaded explicitly. */
/* */
/* bytes :: If the index is loaded in memory, its bytes. */
/* */
typedef struct CFF_IndexRec_
{
FT_Stream stream;
FT_ULong start;
FT_UInt hdr_size;
FT_UInt count;
FT_Byte off_size;
FT_ULong data_offset;
FT_ULong data_size;
FT_ULong* offsets;
FT_Byte* bytes;
} CFF_IndexRec, *CFF_Index;
typedef struct CFF_EncodingRec_
{
FT_UInt format;
FT_ULong offset;
FT_UInt count;
FT_UShort sids [256]; /* avoid dynamic allocations */
FT_UShort codes[256];
} CFF_EncodingRec, *CFF_Encoding;
typedef struct CFF_CharsetRec_
{
FT_UInt format;
FT_ULong offset;
FT_UShort* sids;
FT_UShort* cids; /* the inverse mapping of `sids'; only needed */
/* for CID-keyed fonts */
FT_UInt max_cid;
FT_UInt num_glyphs;
} CFF_CharsetRec, *CFF_Charset;
/* cf. similar fields in file `ttgxvar.h' from the `truetype' module */
typedef struct CFF_VarData_
{
#if 0
FT_UInt itemCount; /* not used; always zero */
FT_UInt shortDeltaCount; /* not used; always zero */
#endif
FT_UInt regionIdxCount; /* number of regions in this var data */
FT_UInt* regionIndices; /* array of `regionCount' indices; */
/* these index `varRegionList' */
} CFF_VarData;
/* contribution of one axis to a region */
typedef struct CFF_AxisCoords_
{
FT_Fixed startCoord;
FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */
FT_Fixed endCoord;
} CFF_AxisCoords;
typedef struct CFF_VarRegion_
{
CFF_AxisCoords* axisList; /* array of axisCount records */
} CFF_VarRegion;
typedef struct CFF_VStoreRec_
{
FT_UInt dataCount;
CFF_VarData* varData; /* array of dataCount records */
/* vsindex indexes this array */
FT_UShort axisCount;
FT_UInt regionCount; /* total number of regions defined */
CFF_VarRegion* varRegionList;
} CFF_VStoreRec, *CFF_VStore;
/* forward reference */
typedef struct CFF_FontRec_* CFF_Font;
/* This object manages one cached blend vector. */
/* */
/* There is a BlendRec for Private DICT parsing in each subfont */
/* and a BlendRec for charstrings in CF2_Font instance data. */
/* A cached BV may be used across DICTs or Charstrings if inputs */
/* have not changed. */
/* */
/* `usedBV' is reset at the start of each parse or charstring. */
/* vsindex cannot be changed after a BV is used. */
/* */
/* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */
typedef struct CFF_BlendRec_
{
FT_Bool builtBV; /* blendV has been built */
FT_Bool usedBV; /* blendV has been used */
CFF_Font font; /* top level font struct */
FT_UInt lastVsindex; /* last vsindex used */
FT_UInt lenNDV; /* normDV length (aka numAxes) */
FT_Fixed* lastNDV; /* last NDV used */
FT_UInt lenBV; /* BlendV length (aka numMasters) */
FT_Int32* BV; /* current blendV (per DICT/glyph) */
} CFF_BlendRec, *CFF_Blend;
typedef struct CFF_FontRecDictRec_
{
FT_UInt version;
FT_UInt notice;
FT_UInt copyright;
FT_UInt full_name;
FT_UInt family_name;
FT_UInt weight;
FT_Bool is_fixed_pitch;
FT_Fixed italic_angle;
FT_Fixed underline_position;
FT_Fixed underline_thickness;
FT_Int paint_type;
FT_Int charstring_type;
FT_Matrix font_matrix;
FT_Bool has_font_matrix;
FT_ULong units_per_em; /* temporarily used as scaling value also */
FT_Vector font_offset;
FT_ULong unique_id;
FT_BBox font_bbox;
FT_Pos stroke_width;
FT_ULong charset_offset;
FT_ULong encoding_offset;
FT_ULong charstrings_offset;
FT_ULong private_offset;
FT_ULong private_size;
FT_Long synthetic_base;
FT_UInt embedded_postscript;
/* these should only be used for the top-level font dictionary */
FT_UInt cid_registry;
FT_UInt cid_ordering;
FT_Long cid_supplement;
FT_Long cid_font_version;
FT_Long cid_font_revision;
FT_Long cid_font_type;
FT_ULong cid_count;
FT_ULong cid_uid_base;
FT_ULong cid_fd_array_offset;
FT_ULong cid_fd_select_offset;
FT_UInt cid_font_name;
/* the next fields come from the data of the deprecated */
/* `MultipleMaster' operator; they are needed to parse the (also */
/* deprecated) `blend' operator in Type 2 charstrings */
FT_UShort num_designs;
FT_UShort num_axes;
/* fields for CFF2 */
FT_ULong vstore_offset;
FT_UInt maxstack;
} CFF_FontRecDictRec, *CFF_FontRecDict;
/* forward reference */
typedef struct CFF_SubFontRec_* CFF_SubFont;
typedef struct CFF_PrivateRec_
{
FT_Byte num_blue_values;
FT_Byte num_other_blues;
FT_Byte num_family_blues;
FT_Byte num_family_other_blues;
FT_Pos blue_values[14];
FT_Pos other_blues[10];
FT_Pos family_blues[14];
FT_Pos family_other_blues[10];
FT_Fixed blue_scale;
FT_Pos blue_shift;
FT_Pos blue_fuzz;
FT_Pos standard_width;
FT_Pos standard_height;
FT_Byte num_snap_widths;
FT_Byte num_snap_heights;
FT_Pos snap_widths[13];
FT_Pos snap_heights[13];
FT_Bool force_bold;
FT_Fixed force_bold_threshold;
FT_Int lenIV;
FT_Int language_group;
FT_Fixed expansion_factor;
FT_Long initial_random_seed;
FT_ULong local_subrs_offset;
FT_Pos default_width;
FT_Pos nominal_width;
/* fields for CFF2 */
FT_UInt vsindex;
CFF_SubFont subfont;
} CFF_PrivateRec, *CFF_Private;
typedef struct CFF_FDSelectRec_
{
FT_Byte format;
FT_UInt range_count;
/* that's the table, taken from the file `as is' */
FT_Byte* data;
FT_UInt data_size;
/* small cache for format 3 only */
FT_UInt cache_first;
FT_UInt cache_count;
FT_Byte cache_fd;
} CFF_FDSelectRec, *CFF_FDSelect;
/* A SubFont packs a font dict and a private dict together. They are */
/* needed to support CID-keyed CFF fonts. */
typedef struct CFF_SubFontRec_
{
CFF_FontRecDictRec font_dict;
CFF_PrivateRec private_dict;
/* fields for CFF2 */
CFF_BlendRec blend; /* current blend vector */
FT_UInt lenNDV; /* current length NDV or zero */
FT_Fixed* NDV; /* ptr to current NDV or NULL */
/* `blend_stack' is a writable buffer to hold blend results. */
/* This buffer is to the side of the normal cff parser stack; */
/* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */
/* The normal stack then points to these values instead of the DICT */
/* because all other operators in Private DICT clear the stack. */
/* `blend_stack' could be cleared at each operator other than blend. */
/* Blended values are stored as 5-byte fixed point values. */
FT_Byte* blend_stack; /* base of stack allocation */
FT_Byte* blend_top; /* first empty slot */
FT_UInt blend_used; /* number of bytes in use */
FT_UInt blend_alloc; /* number of bytes allocated */
CFF_IndexRec local_subrs_index;
FT_Byte** local_subrs; /* array of pointers */
/* into Local Subrs INDEX data */
} CFF_SubFontRec;
#define CFF_MAX_CID_FONTS 256
typedef struct CFF_FontRec_
{
FT_Library library;
FT_Stream stream;
FT_Memory memory; /* TODO: take this from stream->memory? */
FT_ULong base_offset; /* offset to start of CFF */
FT_UInt num_faces;
FT_UInt num_glyphs;
FT_Byte version_major;
FT_Byte version_minor;
FT_Byte header_size;
FT_UInt top_dict_length; /* cff2 only */
FT_Bool cff2;
CFF_IndexRec name_index;
CFF_IndexRec top_dict_index;
CFF_IndexRec global_subrs_index;
CFF_EncodingRec encoding;
CFF_CharsetRec charset;
CFF_IndexRec charstrings_index;
CFF_IndexRec font_dict_index;
CFF_IndexRec private_index;
CFF_IndexRec local_subrs_index;
FT_String* font_name;
/* array of pointers into Global Subrs INDEX data */
FT_Byte** global_subrs;
/* array of pointers into String INDEX data stored at string_pool */
FT_UInt num_strings;
FT_Byte** strings;
FT_Byte* string_pool;
FT_ULong string_pool_size;
CFF_SubFontRec top_font;
FT_UInt num_subfonts;
CFF_SubFont subfonts[CFF_MAX_CID_FONTS];
CFF_FDSelectRec fd_select;
/* interface to PostScript hinter */
PSHinter_Service pshinter;
/* interface to Postscript Names service */
FT_Service_PsCMaps psnames;
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */
/* since version 2.3.6 */
FT_String* registry;
FT_String* ordering;
/* since version 2.4.12 */
FT_Generic cf2_instance;
CFF_VStoreRec vstore; /* parsed vstore structure */
} CFF_FontRec;
FT_END_HEADER
#endif /* CFFTYPES_H_ */
/* END */