blob: 9ddc663dea68d33ca82d27ffed5bd3758db9cf10 [file] [log] [blame]
David Turner170c0d42000-12-13 19:55:11 +00001/***************************************************************************/
2/* */
3/* cfftypes.h */
4/* */
5/* Basic OpenType/CFF type definitions and interface (specification */
6/* only). */
7/* */
Werner Lemberg65ba7242003-05-30 09:12:50 +00008/* Copyright 1996-2001, 2002, 2003 by */
David Turner170c0d42000-12-13 19:55:11 +00009/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10/* */
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. */
16/* */
17/***************************************************************************/
18
19
20#ifndef __CFFTYPES_H__
21#define __CFFTYPES_H__
22
Werner Lemberg63408a12000-12-13 23:44:37 +000023
24#include <ft2build.h>
25#include FT_FREETYPE_H
26
David Turner170c0d42000-12-13 19:55:11 +000027
28FT_BEGIN_HEADER
29
30
31 /*************************************************************************/
32 /* */
33 /* <Struct> */
Werner Lemberg78e004e2002-03-29 23:23:28 +000034 /* CFF_IndexRec */
David Turner170c0d42000-12-13 19:55:11 +000035 /* */
36 /* <Description> */
37 /* A structure used to model a CFF Index table. */
38 /* */
39 /* <Fields> */
Tom Kacvinsky0f27de12001-01-03 00:27:46 +000040 /* stream :: The source input stream. */
David Turner170c0d42000-12-13 19:55:11 +000041 /* */
42 /* count :: The number of elements in the index. */
43 /* */
44 /* off_size :: The size in bytes of object offsets in index. */
45 /* */
46 /* data_offset :: The position of first data byte in the index's */
47 /* bytes. */
48 /* */
Tom Kacvinsky0f27de12001-01-03 00:27:46 +000049 /* offsets :: A table of element offsets in the index. */
David Turner170c0d42000-12-13 19:55:11 +000050 /* */
51 /* bytes :: If the index is loaded in memory, its bytes. */
52 /* */
David Turner29644172002-02-28 18:59:37 +000053 typedef struct CFF_IndexRec_
David Turner170c0d42000-12-13 19:55:11 +000054 {
55 FT_Stream stream;
56 FT_UInt count;
57 FT_Byte off_size;
58 FT_ULong data_offset;
59
60 FT_ULong* offsets;
61 FT_Byte* bytes;
62
David Turner29644172002-02-28 18:59:37 +000063 } CFF_IndexRec, *CFF_Index;
David Turner170c0d42000-12-13 19:55:11 +000064
65
David Turner29644172002-02-28 18:59:37 +000066 typedef struct CFF_EncodingRec_
Tom Kacvinsky0f27de12001-01-03 00:27:46 +000067 {
68 FT_UInt format;
69 FT_ULong offset;
Werner Lemberg415235d2001-06-28 17:49:10 +000070
David Turnerb9b2cac2002-07-10 16:52:06 +000071 FT_UInt count;
72 FT_UShort sids [256]; /* avoid dynamic allocations */
73 FT_UShort codes[256];
Werner Lemberg415235d2001-06-28 17:49:10 +000074
David Turner29644172002-02-28 18:59:37 +000075 } CFF_EncodingRec, *CFF_Encoding;
Tom Kacvinsky0f27de12001-01-03 00:27:46 +000076
77
David Turnerab4fc4d2002-03-14 08:57:10 +000078 typedef struct CFF_CharsetRec_
David Turner170c0d42000-12-13 19:55:11 +000079 {
Werner Lemberg415235d2001-06-28 17:49:10 +000080
Tom Kacvinsky97550fc2000-12-30 01:13:07 +000081 FT_UInt format;
82 FT_ULong offset;
83
84 FT_UShort* sids;
Werner Lembergb36d4a52003-12-12 15:38:39 +000085 FT_UShort* cids; /* the inverse mapping of `sids'; only needed */
86 /* for CID-keyed fonts */
David Turnerab4fc4d2002-03-14 08:57:10 +000087 } CFF_CharsetRec, *CFF_Charset;
David Turner170c0d42000-12-13 19:55:11 +000088
Tom Kacvinsky97550fc2000-12-30 01:13:07 +000089
David Turnerab4fc4d2002-03-14 08:57:10 +000090 typedef struct CFF_FontRecDictRec_
David Turner170c0d42000-12-13 19:55:11 +000091 {
92 FT_UInt version;
93 FT_UInt notice;
94 FT_UInt copyright;
95 FT_UInt full_name;
96 FT_UInt family_name;
97 FT_UInt weight;
98 FT_Bool is_fixed_pitch;
99 FT_Fixed italic_angle;
Werner Lemberg65ba7242003-05-30 09:12:50 +0000100 FT_Fixed underline_position;
101 FT_Fixed underline_thickness;
David Turner170c0d42000-12-13 19:55:11 +0000102 FT_Int paint_type;
103 FT_Int charstring_type;
104 FT_Matrix font_matrix;
Tom Kacvinskyd30bcd22001-02-07 01:13:21 +0000105 FT_UShort units_per_em;
David Turner170c0d42000-12-13 19:55:11 +0000106 FT_Vector font_offset;
107 FT_ULong unique_id;
108 FT_BBox font_bbox;
109 FT_Pos stroke_width;
110 FT_ULong charset_offset;
111 FT_ULong encoding_offset;
112 FT_ULong charstrings_offset;
113 FT_ULong private_offset;
114 FT_ULong private_size;
115 FT_Long synthetic_base;
116 FT_UInt embedded_postscript;
David Turner170c0d42000-12-13 19:55:11 +0000117
David Turner170c0d42000-12-13 19:55:11 +0000118 /* these should only be used for the top-level font dictionary */
119 FT_UInt cid_registry;
120 FT_UInt cid_ordering;
121 FT_ULong cid_supplement;
122
123 FT_Long cid_font_version;
124 FT_Long cid_font_revision;
125 FT_Long cid_font_type;
Werner Lemberga9cd8562003-12-18 08:18:37 +0000126 FT_ULong cid_count;
David Turner170c0d42000-12-13 19:55:11 +0000127 FT_ULong cid_uid_base;
128 FT_ULong cid_fd_array_offset;
129 FT_ULong cid_fd_select_offset;
130 FT_UInt cid_font_name;
131
David Turnerab4fc4d2002-03-14 08:57:10 +0000132 } CFF_FontRecDictRec, *CFF_FontRecDict;
David Turner170c0d42000-12-13 19:55:11 +0000133
134
David Turner29644172002-02-28 18:59:37 +0000135 typedef struct CFF_PrivateRec_
David Turner170c0d42000-12-13 19:55:11 +0000136 {
137 FT_Byte num_blue_values;
138 FT_Byte num_other_blues;
139 FT_Byte num_family_blues;
140 FT_Byte num_family_other_blues;
141
142 FT_Pos blue_values[14];
143 FT_Pos other_blues[10];
144 FT_Pos family_blues[14];
145 FT_Pos family_other_blues[10];
146
147 FT_Fixed blue_scale;
148 FT_Pos blue_shift;
149 FT_Pos blue_fuzz;
150 FT_Pos standard_width;
151 FT_Pos standard_height;
152
153 FT_Byte num_snap_widths;
154 FT_Byte num_snap_heights;
155 FT_Pos snap_widths[13];
156 FT_Pos snap_heights[13];
157 FT_Bool force_bold;
158 FT_Fixed force_bold_threshold;
159 FT_Int lenIV;
160 FT_Int language_group;
161 FT_Fixed expansion_factor;
162 FT_Long initial_random_seed;
163 FT_ULong local_subrs_offset;
164 FT_Pos default_width;
165 FT_Pos nominal_width;
166
David Turner29644172002-02-28 18:59:37 +0000167 } CFF_PrivateRec, *CFF_Private;
David Turner170c0d42000-12-13 19:55:11 +0000168
169
David Turnerab4fc4d2002-03-14 08:57:10 +0000170 typedef struct CFF_FDSelectRec_
David Turner170c0d42000-12-13 19:55:11 +0000171 {
172 FT_Byte format;
173 FT_UInt range_count;
174
175 /* that's the table, taken from the file `as is' */
176 FT_Byte* data;
177 FT_UInt data_size;
178
179 /* small cache for format 3 only */
180 FT_UInt cache_first;
181 FT_UInt cache_count;
182 FT_Byte cache_fd;
183
David Turnerab4fc4d2002-03-14 08:57:10 +0000184 } CFF_FDSelectRec, *CFF_FDSelect;
David Turner170c0d42000-12-13 19:55:11 +0000185
186
Werner Lemberg78e004e2002-03-29 23:23:28 +0000187 /* A SubFont packs a font dict and a private dict together. They are */
188 /* needed to support CID-keyed CFF fonts. */
David Turnerab4fc4d2002-03-14 08:57:10 +0000189 typedef struct CFF_SubFontRec_
David Turner170c0d42000-12-13 19:55:11 +0000190 {
David Turnerab4fc4d2002-03-14 08:57:10 +0000191 CFF_FontRecDictRec font_dict;
Werner Lemberg78e004e2002-03-29 23:23:28 +0000192 CFF_PrivateRec private_dict;
David Turner170c0d42000-12-13 19:55:11 +0000193
Werner Lemberg78e004e2002-03-29 23:23:28 +0000194 CFF_IndexRec local_subrs_index;
195 FT_UInt num_local_subrs;
196 FT_Byte** local_subrs;
David Turner170c0d42000-12-13 19:55:11 +0000197
David Turnerab4fc4d2002-03-14 08:57:10 +0000198 } CFF_SubFontRec, *CFF_SubFont;
David Turner170c0d42000-12-13 19:55:11 +0000199
200
201 /* maximum number of sub-fonts in a CID-keyed file */
Werner Lemberg83da52b2003-12-20 07:30:05 +0000202#define CFF_MAX_CID_FONTS 32
David Turner170c0d42000-12-13 19:55:11 +0000203
204
David Turnerab4fc4d2002-03-14 08:57:10 +0000205 typedef struct CFF_FontRec_
David Turner170c0d42000-12-13 19:55:11 +0000206 {
David Turnerab4fc4d2002-03-14 08:57:10 +0000207 FT_Stream stream;
208 FT_Memory memory;
209 FT_UInt num_faces;
210 FT_UInt num_glyphs;
David Turner170c0d42000-12-13 19:55:11 +0000211
David Turnerab4fc4d2002-03-14 08:57:10 +0000212 FT_Byte version_major;
213 FT_Byte version_minor;
214 FT_Byte header_size;
215 FT_Byte absolute_offsize;
David Turner170c0d42000-12-13 19:55:11 +0000216
217
David Turnerab4fc4d2002-03-14 08:57:10 +0000218 CFF_IndexRec name_index;
219 CFF_IndexRec top_dict_index;
220 CFF_IndexRec string_index;
221 CFF_IndexRec global_subrs_index;
David Turner170c0d42000-12-13 19:55:11 +0000222
David Turnerab4fc4d2002-03-14 08:57:10 +0000223 CFF_EncodingRec encoding;
224 CFF_CharsetRec charset;
Werner Lemberg415235d2001-06-28 17:49:10 +0000225
David Turnerab4fc4d2002-03-14 08:57:10 +0000226 CFF_IndexRec charstrings_index;
227 CFF_IndexRec font_dict_index;
228 CFF_IndexRec private_index;
229 CFF_IndexRec local_subrs_index;
David Turner170c0d42000-12-13 19:55:11 +0000230
David Turnerab4fc4d2002-03-14 08:57:10 +0000231 FT_String* font_name;
232 FT_UInt num_global_subrs;
233 FT_Byte** global_subrs;
David Turner170c0d42000-12-13 19:55:11 +0000234
David Turnerab4fc4d2002-03-14 08:57:10 +0000235 CFF_SubFontRec top_font;
236 FT_UInt num_subfonts;
237 CFF_SubFont subfonts[CFF_MAX_CID_FONTS];
David Turner170c0d42000-12-13 19:55:11 +0000238
David Turnerab4fc4d2002-03-14 08:57:10 +0000239 CFF_FDSelectRec fd_select;
David Turner170c0d42000-12-13 19:55:11 +0000240
David Turnerc8087482001-12-20 13:14:18 +0000241 /* interface to PostScript hinter */
David Turnerab4fc4d2002-03-14 08:57:10 +0000242 void* pshinter;
David Turnerc8087482001-12-20 13:14:18 +0000243
David Turnerb9b2cac2002-07-10 16:52:06 +0000244 /* interface to Postscript Names service */
245 void* psnames;
246
David Turnerab4fc4d2002-03-14 08:57:10 +0000247 } CFF_FontRec, *CFF_Font;
David Turner170c0d42000-12-13 19:55:11 +0000248
249
250FT_END_HEADER
251
252#endif /* __CFFTYPES_H__ */
253
254
255/* END */