1 /***************************************************************************/
5 /* Basic Type 1/Type 2 tables definitions and interface (specification */
8 /* Copyright 1996-2004, 2006, 2008, 2009, 2011, 2014 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. */
63 /* FT_Has_PS_Glyph_Names */
64 /* FT_Get_PS_Font_Info */
65 /* FT_Get_PS_Font_Private */
66 /* FT_Get_PS_Font_Value */
72 /*************************************************************************/
75 /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
76 /* structures in order to support Multiple Master fonts. */
79 /*************************************************************************/
85 /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */
86 /* Note that for Multiple Master fonts, each instance has its own */
87 /* FontInfo dictionary. */
89 typedef struct PS_FontInfoRec_
94 FT_String* family_name;
97 FT_Bool is_fixed_pitch;
98 FT_Short underline_position;
99 FT_UShort underline_thickness;
104 /*************************************************************************/
110 /* A handle to a @PS_FontInfoRec structure. */
112 typedef struct PS_FontInfoRec_* PS_FontInfo;
115 /*************************************************************************/
121 /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */
122 /* kept to maintain source compatibility between various versions of */
125 typedef PS_FontInfoRec T1_FontInfo;
128 /*************************************************************************/
134 /* A structure used to model a Type~1 or Type~2 private dictionary. */
135 /* Note that for Multiple Master fonts, each instance has its own */
136 /* Private dictionary. */
138 typedef struct PS_PrivateRec_
143 FT_Byte num_blue_values;
144 FT_Byte num_other_blues;
145 FT_Byte num_family_blues;
146 FT_Byte num_family_other_blues;
148 FT_Short blue_values[14];
149 FT_Short other_blues[10];
151 FT_Short family_blues [14];
152 FT_Short family_other_blues[10];
158 FT_UShort standard_width[1];
159 FT_UShort standard_height[1];
161 FT_Byte num_snap_widths;
162 FT_Byte num_snap_heights;
164 FT_Bool round_stem_up;
166 FT_Short snap_widths [13]; /* including std width */
167 FT_Short snap_heights[13]; /* including std height */
169 FT_Fixed expansion_factor;
171 FT_Long language_group;
174 FT_Short min_feature[2];
179 /*************************************************************************/
185 /* A handle to a @PS_PrivateRec structure. */
187 typedef struct PS_PrivateRec_* PS_Private;
190 /*************************************************************************/
196 /* This type is equivalent to @PS_PrivateRec. It is deprecated but */
197 /* kept to maintain source compatibility between various versions of */
200 typedef PS_PrivateRec T1_Private;
203 /*************************************************************************/
209 /* A set of flags used to indicate which fields are present in a */
210 /* given blend dictionary (font info or private). Used to support */
211 /* Multiple Masters fonts. */
214 /* T1_BLEND_UNDERLINE_POSITION :: */
215 /* T1_BLEND_UNDERLINE_THICKNESS :: */
216 /* T1_BLEND_ITALIC_ANGLE :: */
217 /* T1_BLEND_BLUE_VALUES :: */
218 /* T1_BLEND_OTHER_BLUES :: */
219 /* T1_BLEND_STANDARD_WIDTH :: */
220 /* T1_BLEND_STANDARD_HEIGHT :: */
221 /* T1_BLEND_STEM_SNAP_WIDTHS :: */
222 /* T1_BLEND_STEM_SNAP_HEIGHTS :: */
223 /* T1_BLEND_BLUE_SCALE :: */
224 /* T1_BLEND_BLUE_SHIFT :: */
225 /* T1_BLEND_FAMILY_BLUES :: */
226 /* T1_BLEND_FAMILY_OTHER_BLUES :: */
227 /* T1_BLEND_FORCE_BOLD :: */
229 typedef enum T1_Blend_Flags_
231 /* required fields in a FontInfo blend dictionary */
232 T1_BLEND_UNDERLINE_POSITION = 0,
233 T1_BLEND_UNDERLINE_THICKNESS,
234 T1_BLEND_ITALIC_ANGLE,
236 /* required fields in a Private blend dictionary */
237 T1_BLEND_BLUE_VALUES,
238 T1_BLEND_OTHER_BLUES,
239 T1_BLEND_STANDARD_WIDTH,
240 T1_BLEND_STANDARD_HEIGHT,
241 T1_BLEND_STEM_SNAP_WIDTHS,
242 T1_BLEND_STEM_SNAP_HEIGHTS,
245 T1_BLEND_FAMILY_BLUES,
246 T1_BLEND_FAMILY_OTHER_BLUES,
249 T1_BLEND_MAX /* do not remove */
254 /* these constants are deprecated; use the corresponding */
255 /* `T1_Blend_Flags' values instead */
256 #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
257 #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
258 #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
259 #define t1_blend_blue_values T1_BLEND_BLUE_VALUES
260 #define t1_blend_other_blues T1_BLEND_OTHER_BLUES
261 #define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
262 #define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
263 #define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
264 #define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
265 #define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
266 #define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
267 #define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
268 #define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
269 #define t1_blend_force_bold T1_BLEND_FORCE_BOLD
270 #define t1_blend_max T1_BLEND_MAX
275 /* maximum number of Multiple Masters designs, as defined in the spec */
276 #define T1_MAX_MM_DESIGNS 16
278 /* maximum number of Multiple Masters axes, as defined in the spec */
279 #define T1_MAX_MM_AXIS 4
281 /* maximum number of elements in a design map */
282 #define T1_MAX_MM_MAP_POINTS 20
285 /* this structure is used to store the BlendDesignMap entry for an axis */
286 typedef struct PS_DesignMap_
289 FT_Long* design_points;
290 FT_Fixed* blend_points;
292 } PS_DesignMapRec, *PS_DesignMap;
294 /* backwards-compatible definition */
295 typedef PS_DesignMapRec T1_DesignMap;
298 typedef struct PS_BlendRec_
303 FT_String* axis_names[T1_MAX_MM_AXIS];
304 FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
305 PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
307 FT_Fixed* weight_vector;
308 FT_Fixed* default_weight_vector;
310 PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
311 PS_Private privates [T1_MAX_MM_DESIGNS + 1];
313 FT_ULong blend_bitflags;
315 FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
319 /* undocumented, optional: the default design instance; */
320 /* corresponds to default_weight_vector -- */
321 /* num_default_design_vector == 0 means it is not present */
322 /* in the font and associated metrics files */
323 FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
324 FT_UInt num_default_design_vector;
326 } PS_BlendRec, *PS_Blend;
329 /* backwards-compatible definition */
330 typedef PS_BlendRec T1_Blend;
333 /*************************************************************************/
336 /* CID_FaceDictRec */
339 /* A structure used to represent data in a CID top-level dictionary. */
341 typedef struct CID_FaceDictRec_
343 PS_PrivateRec private_dict;
345 FT_UInt len_buildchar;
346 FT_Fixed forcebold_threshold;
348 FT_Fixed expansion_factor;
352 FT_Matrix font_matrix;
353 FT_Vector font_offset;
356 FT_ULong subrmap_offset;
362 /*************************************************************************/
368 /* A handle to a @CID_FaceDictRec structure. */
370 typedef struct CID_FaceDictRec_* CID_FaceDict;
373 /*************************************************************************/
379 /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */
380 /* kept to maintain source compatibility between various versions of */
383 typedef CID_FaceDictRec CID_FontDict;
386 /*************************************************************************/
389 /* CID_FaceInfoRec */
392 /* A structure used to represent CID Face information. */
394 typedef struct CID_FaceInfoRec_
396 FT_String* cid_font_name;
397 FT_Fixed cid_version;
398 FT_Int cid_font_type;
404 PS_FontInfoRec font_info;
411 FT_ULong cidmap_offset;
417 CID_FaceDict font_dicts;
419 FT_ULong data_offset;
424 /*************************************************************************/
430 /* A handle to a @CID_FaceInfoRec structure. */
432 typedef struct CID_FaceInfoRec_* CID_FaceInfo;
435 /*************************************************************************/
441 /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */
442 /* kept to maintain source compatibility between various versions of */
445 typedef CID_FaceInfoRec CID_Info;
448 /************************************************************************
451 * FT_Has_PS_Glyph_Names
454 * Return true if a given face provides reliable PostScript glyph
455 * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
456 * except that certain fonts (mostly TrueType) contain incorrect
459 * When this function returns true, the caller is sure that the glyph
460 * names returned by @FT_Get_Glyph_Name are reliable.
467 * Boolean. True if glyph names are reliable.
471 FT_Has_PS_Glyph_Names( FT_Face face );
474 /************************************************************************
477 * FT_Get_PS_Font_Info
480 * Retrieve the @PS_FontInfoRec structure corresponding to a given
485 * PostScript face handle.
489 * Output font info structure pointer.
492 * FreeType error code. 0~means success.
495 * The string pointers within the font info structure are owned by
496 * the face and don't need to be freed by the caller.
498 * If the font's format is not PostScript-based, this function will
499 * return the `FT_Err_Invalid_Argument' error code.
502 FT_EXPORT( FT_Error )
503 FT_Get_PS_Font_Info( FT_Face face,
504 PS_FontInfo afont_info );
507 /************************************************************************
510 * FT_Get_PS_Font_Private
513 * Retrieve the @PS_PrivateRec structure corresponding to a given
518 * PostScript face handle.
522 * Output private dictionary structure pointer.
525 * FreeType error code. 0~means success.
528 * The string pointers within the @PS_PrivateRec structure are owned by
529 * the face and don't need to be freed by the caller.
531 * If the font's format is not PostScript-based, this function returns
532 * the `FT_Err_Invalid_Argument' error code.
535 FT_EXPORT( FT_Error )
536 FT_Get_PS_Font_Private( FT_Face face,
537 PS_Private afont_private );
540 /*************************************************************************/
543 /* T1_EncodingType */
546 /* An enumeration describing the `Encoding' entry in a Type 1 */
550 /* T1_ENCODING_TYPE_NONE :: */
551 /* T1_ENCODING_TYPE_ARRAY :: */
552 /* T1_ENCODING_TYPE_STANDARD :: */
553 /* T1_ENCODING_TYPE_ISOLATIN1 :: */
554 /* T1_ENCODING_TYPE_EXPERT :: */
556 typedef enum T1_EncodingType_
558 T1_ENCODING_TYPE_NONE = 0,
559 T1_ENCODING_TYPE_ARRAY,
560 T1_ENCODING_TYPE_STANDARD,
561 T1_ENCODING_TYPE_ISOLATIN1,
562 T1_ENCODING_TYPE_EXPERT
567 /*************************************************************************/
573 /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */
574 /* the Type~1 dictionary entry to retrieve. */
577 /* PS_DICT_FONT_TYPE :: */
578 /* PS_DICT_FONT_MATRIX :: */
579 /* PS_DICT_FONT_BBOX :: */
580 /* PS_DICT_PAINT_TYPE :: */
581 /* PS_DICT_FONT_NAME :: */
582 /* PS_DICT_UNIQUE_ID :: */
583 /* PS_DICT_NUM_CHAR_STRINGS :: */
584 /* PS_DICT_CHAR_STRING_KEY :: */
585 /* PS_DICT_CHAR_STRING :: */
586 /* PS_DICT_ENCODING_TYPE :: */
587 /* PS_DICT_ENCODING_ENTRY :: */
588 /* PS_DICT_NUM_SUBRS :: */
589 /* PS_DICT_SUBR :: */
590 /* PS_DICT_STD_HW :: */
591 /* PS_DICT_STD_VW :: */
592 /* PS_DICT_NUM_BLUE_VALUES :: */
593 /* PS_DICT_BLUE_VALUE :: */
594 /* PS_DICT_BLUE_FUZZ :: */
595 /* PS_DICT_NUM_OTHER_BLUES :: */
596 /* PS_DICT_OTHER_BLUE :: */
597 /* PS_DICT_NUM_FAMILY_BLUES :: */
598 /* PS_DICT_FAMILY_BLUE :: */
599 /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */
600 /* PS_DICT_FAMILY_OTHER_BLUE :: */
601 /* PS_DICT_BLUE_SCALE :: */
602 /* PS_DICT_BLUE_SHIFT :: */
603 /* PS_DICT_NUM_STEM_SNAP_H :: */
604 /* PS_DICT_STEM_SNAP_H :: */
605 /* PS_DICT_NUM_STEM_SNAP_V :: */
606 /* PS_DICT_STEM_SNAP_V :: */
607 /* PS_DICT_FORCE_BOLD :: */
608 /* PS_DICT_RND_STEM_UP :: */
609 /* PS_DICT_MIN_FEATURE :: */
610 /* PS_DICT_LEN_IV :: */
611 /* PS_DICT_PASSWORD :: */
612 /* PS_DICT_LANGUAGE_GROUP :: */
613 /* PS_DICT_VERSION :: */
614 /* PS_DICT_NOTICE :: */
615 /* PS_DICT_FULL_NAME :: */
616 /* PS_DICT_FAMILY_NAME :: */
617 /* PS_DICT_WEIGHT :: */
618 /* PS_DICT_IS_FIXED_PITCH :: */
619 /* PS_DICT_UNDERLINE_POSITION :: */
620 /* PS_DICT_UNDERLINE_THICKNESS :: */
621 /* PS_DICT_FS_TYPE :: */
622 /* PS_DICT_ITALIC_ANGLE :: */
624 typedef enum PS_Dict_Keys_
626 /* conventionally in the font dictionary */
627 PS_DICT_FONT_TYPE, /* FT_Byte */
628 PS_DICT_FONT_MATRIX, /* FT_Fixed */
629 PS_DICT_FONT_BBOX, /* FT_Fixed */
630 PS_DICT_PAINT_TYPE, /* FT_Byte */
631 PS_DICT_FONT_NAME, /* FT_String* */
632 PS_DICT_UNIQUE_ID, /* FT_Int */
633 PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
634 PS_DICT_CHAR_STRING_KEY, /* FT_String* */
635 PS_DICT_CHAR_STRING, /* FT_String* */
636 PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
637 PS_DICT_ENCODING_ENTRY, /* FT_String* */
639 /* conventionally in the font Private dictionary */
640 PS_DICT_NUM_SUBRS, /* FT_Int */
641 PS_DICT_SUBR, /* FT_String* */
642 PS_DICT_STD_HW, /* FT_UShort */
643 PS_DICT_STD_VW, /* FT_UShort */
644 PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
645 PS_DICT_BLUE_VALUE, /* FT_Short */
646 PS_DICT_BLUE_FUZZ, /* FT_Int */
647 PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
648 PS_DICT_OTHER_BLUE, /* FT_Short */
649 PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
650 PS_DICT_FAMILY_BLUE, /* FT_Short */
651 PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
652 PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
653 PS_DICT_BLUE_SCALE, /* FT_Fixed */
654 PS_DICT_BLUE_SHIFT, /* FT_Int */
655 PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
656 PS_DICT_STEM_SNAP_H, /* FT_Short */
657 PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
658 PS_DICT_STEM_SNAP_V, /* FT_Short */
659 PS_DICT_FORCE_BOLD, /* FT_Bool */
660 PS_DICT_RND_STEM_UP, /* FT_Bool */
661 PS_DICT_MIN_FEATURE, /* FT_Short */
662 PS_DICT_LEN_IV, /* FT_Int */
663 PS_DICT_PASSWORD, /* FT_Long */
664 PS_DICT_LANGUAGE_GROUP, /* FT_Long */
666 /* conventionally in the font FontInfo dictionary */
667 PS_DICT_VERSION, /* FT_String* */
668 PS_DICT_NOTICE, /* FT_String* */
669 PS_DICT_FULL_NAME, /* FT_String* */
670 PS_DICT_FAMILY_NAME, /* FT_String* */
671 PS_DICT_WEIGHT, /* FT_String* */
672 PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
673 PS_DICT_UNDERLINE_POSITION, /* FT_Short */
674 PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
675 PS_DICT_FS_TYPE, /* FT_UShort */
676 PS_DICT_ITALIC_ANGLE, /* FT_Long */
678 PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
683 /************************************************************************
686 * FT_Get_PS_Font_Value
689 * Retrieve the value for the supplied key from a PostScript font.
693 * PostScript face handle.
696 * An enumeration value representing the dictionary key to retrieve.
699 * For array values, this specifies the index to be returned.
702 * A pointer to memory into which to write the value.
705 * The size, in bytes, of the memory supplied for the value.
709 * The value matching the above key, if it exists.
712 * The amount of memory (in bytes) required to hold the requested
713 * value (if it exists, -1 otherwise).
716 * The values returned are not pointers into the internal structures of
717 * the face, but are `fresh' copies, so that the memory containing them
718 * belongs to the calling application. This also enforces the
719 * `read-only' nature of these values, i.e., this function cannot be
720 * used to manipulate the face.
722 * `value' is a void pointer because the values returned can be of
725 * If either `value' is NULL or `value_len' is too small, just the
726 * required memory size for the requested entry is returned.
728 * The `idx' parameter is used, not only to retrieve elements of, for
729 * example, the FontMatrix or FontBBox, but also to retrieve name keys
730 * from the CharStrings dictionary, and the charstrings themselves. It
731 * is ignored for atomic values.
733 * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To
734 * get the value as in the font stream, you need to divide by
735 * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale).
737 * IMPORTANT: Only key/value pairs read by the FreeType interpreter can
738 * be retrieved. So, for example, PostScript procedures such as NP,
739 * ND, and RD are not available. Arbitrary keys are, obviously, not be
742 * If the font's format is not PostScript-based, this function returns
743 * the `FT_Err_Invalid_Argument' error code.
747 FT_Get_PS_Font_Value( FT_Face face,
757 #endif /* __T1TABLES_H__ */