1 /***************************************************************************/
5 /* Basic Type 1/Type 2 tables definitions and interface (specification */
8 /* Copyright 1996-2004, 2006, 2008, 2009, 2011 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
11 /* This file is part of the FreeType project, and may only be used, */
12 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */
17 /***************************************************************************/
20 #ifndef __T1TABLES_H__
21 #define __T1TABLES_H__
25 #include FT_FREETYPE_H
28 #error "freetype.h of FreeType 1 has been loaded!"
29 #error "Please fix the directory search order for header files"
30 #error "so that freetype.h of FreeType 2 is found first."
37 /*************************************************************************/
46 /* Type~1 (PostScript) specific font tables. */
49 /* This section contains the definition of Type 1-specific tables, */
50 /* including structures related to other PostScript font formats. */
52 /*************************************************************************/
55 /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
56 /* structures in order to support Multiple Master fonts. */
59 /*************************************************************************/
65 /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */
66 /* Note that for Multiple Master fonts, each instance has its own */
67 /* FontInfo dictionary. */
69 typedef struct PS_FontInfoRec_
74 FT_String* family_name;
77 FT_Bool is_fixed_pitch;
78 FT_Short underline_position;
79 FT_UShort underline_thickness;
84 /*************************************************************************/
90 /* A handle to a @PS_FontInfoRec structure. */
92 typedef struct PS_FontInfoRec_* PS_FontInfo;
95 /*************************************************************************/
101 /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */
102 /* kept to maintain source compatibility between various versions of */
105 typedef PS_FontInfoRec T1_FontInfo;
108 /*************************************************************************/
114 /* A structure used to model a Type~1 or Type~2 private dictionary. */
115 /* Note that for Multiple Master fonts, each instance has its own */
116 /* Private dictionary. */
118 typedef struct PS_PrivateRec_
123 FT_Byte num_blue_values;
124 FT_Byte num_other_blues;
125 FT_Byte num_family_blues;
126 FT_Byte num_family_other_blues;
128 FT_Short blue_values[14];
129 FT_Short other_blues[10];
131 FT_Short family_blues [14];
132 FT_Short family_other_blues[10];
138 FT_UShort standard_width[1];
139 FT_UShort standard_height[1];
141 FT_Byte num_snap_widths;
142 FT_Byte num_snap_heights;
144 FT_Bool round_stem_up;
146 FT_Short snap_widths [13]; /* including std width */
147 FT_Short snap_heights[13]; /* including std height */
149 FT_Fixed expansion_factor;
151 FT_Long language_group;
154 FT_Short min_feature[2];
159 /*************************************************************************/
165 /* A handle to a @PS_PrivateRec structure. */
167 typedef struct PS_PrivateRec_* PS_Private;
170 /*************************************************************************/
176 /* This type is equivalent to @PS_PrivateRec. It is deprecated but */
177 /* kept to maintain source compatibility between various versions of */
180 typedef PS_PrivateRec T1_Private;
183 /*************************************************************************/
189 /* A set of flags used to indicate which fields are present in a */
190 /* given blend dictionary (font info or private). Used to support */
191 /* Multiple Masters fonts. */
193 typedef enum T1_Blend_Flags_
195 /*# required fields in a FontInfo blend dictionary */
196 T1_BLEND_UNDERLINE_POSITION = 0,
197 T1_BLEND_UNDERLINE_THICKNESS,
198 T1_BLEND_ITALIC_ANGLE,
200 /*# required fields in a Private blend dictionary */
201 T1_BLEND_BLUE_VALUES,
202 T1_BLEND_OTHER_BLUES,
203 T1_BLEND_STANDARD_WIDTH,
204 T1_BLEND_STANDARD_HEIGHT,
205 T1_BLEND_STEM_SNAP_WIDTHS,
206 T1_BLEND_STEM_SNAP_HEIGHTS,
209 T1_BLEND_FAMILY_BLUES,
210 T1_BLEND_FAMILY_OTHER_BLUES,
221 /*# backwards compatible definitions */
222 #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
223 #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
224 #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
225 #define t1_blend_blue_values T1_BLEND_BLUE_VALUES
226 #define t1_blend_other_blues T1_BLEND_OTHER_BLUES
227 #define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
228 #define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
229 #define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
230 #define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
231 #define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
232 #define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
233 #define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
234 #define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
235 #define t1_blend_force_bold T1_BLEND_FORCE_BOLD
236 #define t1_blend_max T1_BLEND_MAX
239 /* maximum number of Multiple Masters designs, as defined in the spec */
240 #define T1_MAX_MM_DESIGNS 16
242 /* maximum number of Multiple Masters axes, as defined in the spec */
243 #define T1_MAX_MM_AXIS 4
245 /* maximum number of elements in a design map */
246 #define T1_MAX_MM_MAP_POINTS 20
249 /* this structure is used to store the BlendDesignMap entry for an axis */
250 typedef struct PS_DesignMap_
253 FT_Long* design_points;
254 FT_Fixed* blend_points;
256 } PS_DesignMapRec, *PS_DesignMap;
258 /* backwards-compatible definition */
259 typedef PS_DesignMapRec T1_DesignMap;
262 typedef struct PS_BlendRec_
267 FT_String* axis_names[T1_MAX_MM_AXIS];
268 FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
269 PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
271 FT_Fixed* weight_vector;
272 FT_Fixed* default_weight_vector;
274 PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
275 PS_Private privates [T1_MAX_MM_DESIGNS + 1];
277 FT_ULong blend_bitflags;
279 FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
283 /* undocumented, optional: the default design instance; */
284 /* corresponds to default_weight_vector -- */
285 /* num_default_design_vector == 0 means it is not present */
286 /* in the font and associated metrics files */
287 FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
288 FT_UInt num_default_design_vector;
290 } PS_BlendRec, *PS_Blend;
293 /* backwards-compatible definition */
294 typedef PS_BlendRec T1_Blend;
297 /*************************************************************************/
300 /* CID_FaceDictRec */
303 /* A structure used to represent data in a CID top-level dictionary. */
305 typedef struct CID_FaceDictRec_
307 PS_PrivateRec private_dict;
309 FT_UInt len_buildchar;
310 FT_Fixed forcebold_threshold;
312 FT_Fixed expansion_factor;
316 FT_Matrix font_matrix;
317 FT_Vector font_offset;
320 FT_ULong subrmap_offset;
326 /*************************************************************************/
332 /* A handle to a @CID_FaceDictRec structure. */
334 typedef struct CID_FaceDictRec_* CID_FaceDict;
339 /* backwards-compatible definition */
340 typedef CID_FaceDictRec CID_FontDict;
343 /*************************************************************************/
346 /* CID_FaceInfoRec */
349 /* A structure used to represent CID Face information. */
351 typedef struct CID_FaceInfoRec_
353 FT_String* cid_font_name;
354 FT_Fixed cid_version;
355 FT_Int cid_font_type;
361 PS_FontInfoRec font_info;
368 FT_ULong cidmap_offset;
374 CID_FaceDict font_dicts;
376 FT_ULong data_offset;
381 /*************************************************************************/
387 /* A handle to a @CID_FaceInfoRec structure. */
389 typedef struct CID_FaceInfoRec_* CID_FaceInfo;
392 /*************************************************************************/
398 /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */
399 /* kept to maintain source compatibility between various versions of */
402 typedef CID_FaceInfoRec CID_Info;
405 /************************************************************************
408 * FT_Has_PS_Glyph_Names
411 * Return true if a given face provides reliable PostScript glyph
412 * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
413 * except that certain fonts (mostly TrueType) contain incorrect
416 * When this function returns true, the caller is sure that the glyph
417 * names returned by @FT_Get_Glyph_Name are reliable.
424 * Boolean. True if glyph names are reliable.
428 FT_Has_PS_Glyph_Names( FT_Face face );
431 /************************************************************************
434 * FT_Get_PS_Font_Info
437 * Retrieve the @PS_FontInfoRec structure corresponding to a given
442 * PostScript face handle.
446 * Output font info structure pointer.
449 * FreeType error code. 0~means success.
452 * The string pointers within the font info structure are owned by
453 * the face and don't need to be freed by the caller.
455 * If the font's format is not PostScript-based, this function will
456 * return the `FT_Err_Invalid_Argument' error code.
459 FT_EXPORT( FT_Error )
460 FT_Get_PS_Font_Info( FT_Face face,
461 PS_FontInfo afont_info );
464 /************************************************************************
467 * FT_Get_PS_Font_Private
470 * Retrieve the @PS_PrivateRec structure corresponding to a given
475 * PostScript face handle.
479 * Output private dictionary structure pointer.
482 * FreeType error code. 0~means success.
485 * The string pointers within the @PS_PrivateRec structure are owned by
486 * the face and don't need to be freed by the caller.
488 * If the font's format is not PostScript-based, this function returns
489 * the `FT_Err_Invalid_Argument' error code.
492 FT_EXPORT( FT_Error )
493 FT_Get_PS_Font_Private( FT_Face face,
494 PS_Private afont_private );
497 /*************************************************************************/
500 /* T1_EncodingType */
503 /* An enumeration describing the `Encoding' entry in a Type 1 */
506 typedef enum T1_EncodingType_
508 T1_ENCODING_TYPE_NONE = 0,
509 T1_ENCODING_TYPE_ARRAY,
510 T1_ENCODING_TYPE_STANDARD,
511 T1_ENCODING_TYPE_ISOLATIN1,
512 T1_ENCODING_TYPE_EXPERT
517 /*************************************************************************/
523 /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */
524 /* the Type~1 dictionary entry to retrieve. */
526 typedef enum PS_Dict_Keys_
528 /* conventionally in the font dictionary */
529 PS_DICT_FONT_TYPE, /* FT_Byte */
530 PS_DICT_FONT_MATRIX, /* FT_Fixed */
531 PS_DICT_FONT_BBOX, /* FT_Fixed */
532 PS_DICT_PAINT_TYPE, /* FT_Byte */
533 PS_DICT_FONT_NAME, /* FT_String* */
534 PS_DICT_UNIQUE_ID, /* FT_Int */
535 PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
536 PS_DICT_CHAR_STRING_KEY, /* FT_String* */
537 PS_DICT_CHAR_STRING, /* FT_String* */
538 PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
539 PS_DICT_ENCODING_ENTRY, /* FT_String* */
541 /* conventionally in the font Private dictionary */
542 PS_DICT_NUM_SUBRS, /* FT_Int */
543 PS_DICT_SUBR, /* FT_String* */
544 PS_DICT_STD_HW, /* FT_UShort */
545 PS_DICT_STD_VW, /* FT_UShort */
546 PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
547 PS_DICT_BLUE_VALUE, /* FT_Short */
548 PS_DICT_BLUE_FUZZ, /* FT_Int */
549 PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
550 PS_DICT_OTHER_BLUE, /* FT_Short */
551 PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
552 PS_DICT_FAMILY_BLUE, /* FT_Short */
553 PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
554 PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
555 PS_DICT_BLUE_SCALE, /* FT_Fixed */
556 PS_DICT_BLUE_SHIFT, /* FT_Int */
557 PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
558 PS_DICT_STEM_SNAP_H, /* FT_Short */
559 PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
560 PS_DICT_STEM_SNAP_V, /* FT_Short */
561 PS_DICT_FORCE_BOLD, /* FT_Bool */
562 PS_DICT_RND_STEM_UP, /* FT_Bool */
563 PS_DICT_MIN_FEATURE, /* FT_Short */
564 PS_DICT_LEN_IV, /* FT_Int */
565 PS_DICT_PASSWORD, /* FT_Long */
566 PS_DICT_LANGUAGE_GROUP, /* FT_Long */
568 /* conventionally in the font FontInfo dictionary */
569 PS_DICT_VERSION, /* FT_String* */
570 PS_DICT_NOTICE, /* FT_String* */
571 PS_DICT_FULL_NAME, /* FT_String* */
572 PS_DICT_FAMILY_NAME, /* FT_String* */
573 PS_DICT_WEIGHT, /* FT_String* */
574 PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
575 PS_DICT_UNDERLINE_POSITION, /* FT_Short */
576 PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
577 PS_DICT_FS_TYPE, /* FT_UShort */
578 PS_DICT_ITALIC_ANGLE, /* FT_Long */
580 PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
585 /************************************************************************
588 * FT_Get_PS_Font_Value
591 * Retrieve the value for the supplied key from a PostScript font.
595 * PostScript face handle.
598 * An enumeration value representing the dictionary key to retrieve.
601 * For array values, this specifies the index to be returned.
604 * A pointer to memory into which to write the value.
607 * The size, in bytes, of the memory supplied for the value.
611 * The value matching the above key, if it exists.
614 * The amount of memory (in bytes) required to hold the requested
615 * value (if it exists, -1 otherwise).
618 * The values returned are not pointers into the internal structures of
619 * the face, but are `fresh' copies, so that the memory containing them
620 * belongs to the calling application. This also enforces the
621 * `read-only' nature of these values, i.e., this function cannot be
622 * used to manipulate the face.
624 * `value' is a void pointer because the values returned can be of
627 * If either `value' is NULL or `value_len' is too small, just the
628 * required memory size for the requested entry is returned.
630 * The `idx' parameter is used, not only to retrieve elements of, for
631 * example, the FontMatrix or FontBBox, but also to retrieve name keys
632 * from the CharStrings dictionary, and the charstrings themselves. It
633 * is ignored for atomic values.
635 * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To
636 * get the value as in the font stream, you need to divide by
637 * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale).
639 * IMPORTANT: Only key/value pairs read by the FreeType interpreter can
640 * be retrieved. So, for example, PostScript procedures such as NP,
641 * ND, and RD are not available. Arbitrary keys are, obviously, not be
644 * If the font's format is not PostScript-based, this function returns
645 * the `FT_Err_Invalid_Argument' error code.
649 FT_Get_PS_Font_Value( FT_Face face,
659 #endif /* __T1TABLES_H__ */