1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* ttobjs.h */ |
3 * ttobjs.h |
4 /* */ |
4 * |
5 /* Objects manager (specification). */ |
5 * Objects manager (specification). |
6 /* */ |
6 * |
7 /* Copyright 1996-2018 by */ |
7 * Copyright (C) 1996-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
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 */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #ifndef TTOBJS_H_ |
19 #ifndef TTOBJS_H_ |
20 #define TTOBJS_H_ |
20 #define TTOBJS_H_ |
21 |
21 |
26 |
26 |
27 |
27 |
28 FT_BEGIN_HEADER |
28 FT_BEGIN_HEADER |
29 |
29 |
30 |
30 |
31 /*************************************************************************/ |
31 /************************************************************************** |
32 /* */ |
32 * |
33 /* <Type> */ |
33 * @Type: |
34 /* TT_Driver */ |
34 * TT_Driver |
35 /* */ |
35 * |
36 /* <Description> */ |
36 * @Description: |
37 /* A handle to a TrueType driver object. */ |
37 * A handle to a TrueType driver object. |
38 /* */ |
38 */ |
39 typedef struct TT_DriverRec_* TT_Driver; |
39 typedef struct TT_DriverRec_* TT_Driver; |
40 |
40 |
41 |
41 |
42 /*************************************************************************/ |
42 /************************************************************************** |
43 /* */ |
43 * |
44 /* <Type> */ |
44 * @Type: |
45 /* TT_GlyphSlot */ |
45 * TT_GlyphSlot |
46 /* */ |
46 * |
47 /* <Description> */ |
47 * @Description: |
48 /* A handle to a TrueType glyph slot object. */ |
48 * A handle to a TrueType glyph slot object. |
49 /* */ |
49 * |
50 /* <Note> */ |
50 * @Note: |
51 /* This is a direct typedef of FT_GlyphSlot, as there is nothing */ |
51 * This is a direct typedef of FT_GlyphSlot, as there is nothing |
52 /* specific about the TrueType glyph slot. */ |
52 * specific about the TrueType glyph slot. |
53 /* */ |
53 */ |
54 typedef FT_GlyphSlot TT_GlyphSlot; |
54 typedef FT_GlyphSlot TT_GlyphSlot; |
55 |
55 |
56 |
56 |
57 /*************************************************************************/ |
57 /************************************************************************** |
58 /* */ |
58 * |
59 /* <Struct> */ |
59 * @Struct: |
60 /* TT_GraphicsState */ |
60 * TT_GraphicsState |
61 /* */ |
61 * |
62 /* <Description> */ |
62 * @Description: |
63 /* The TrueType graphics state used during bytecode interpretation. */ |
63 * The TrueType graphics state used during bytecode interpretation. |
64 /* */ |
64 */ |
65 typedef struct TT_GraphicsState_ |
65 typedef struct TT_GraphicsState_ |
66 { |
66 { |
67 FT_UShort rp0; |
67 FT_UShort rp0; |
68 FT_UShort rp1; |
68 FT_UShort rp1; |
69 FT_UShort rp2; |
69 FT_UShort rp2; |
111 |
111 |
112 #endif /* TT_USE_BYTECODE_INTERPRETER */ |
112 #endif /* TT_USE_BYTECODE_INTERPRETER */ |
113 |
113 |
114 |
114 |
115 |
115 |
116 /*************************************************************************/ |
116 /************************************************************************** |
117 /* */ |
117 * |
118 /* EXECUTION SUBTABLES */ |
118 * EXECUTION SUBTABLES |
119 /* */ |
119 * |
120 /* These sub-tables relate to instruction execution. */ |
120 * These sub-tables relate to instruction execution. |
121 /* */ |
121 * |
122 /*************************************************************************/ |
122 */ |
123 |
123 |
124 |
124 |
125 #define TT_MAX_CODE_RANGES 3 |
125 #define TT_MAX_CODE_RANGES 3 |
126 |
126 |
127 |
127 |
128 /*************************************************************************/ |
128 /************************************************************************** |
129 /* */ |
129 * |
130 /* There can only be 3 active code ranges at once: */ |
130 * There can only be 3 active code ranges at once: |
131 /* - the Font Program */ |
131 * - the Font Program |
132 /* - the CVT Program */ |
132 * - the CVT Program |
133 /* - a glyph's instructions set */ |
133 * - a glyph's instructions set |
134 /* */ |
134 */ |
135 typedef enum TT_CodeRange_Tag_ |
135 typedef enum TT_CodeRange_Tag_ |
136 { |
136 { |
137 tt_coderange_none = 0, |
137 tt_coderange_none = 0, |
138 tt_coderange_font, |
138 tt_coderange_font, |
139 tt_coderange_cvt, |
139 tt_coderange_cvt, |
167 FT_ULong sph_fdef_flags; /* flags to identify special functions */ |
167 FT_ULong sph_fdef_flags; /* flags to identify special functions */ |
168 |
168 |
169 } TT_DefRecord, *TT_DefArray; |
169 } TT_DefRecord, *TT_DefArray; |
170 |
170 |
171 |
171 |
172 /*************************************************************************/ |
172 /************************************************************************** |
173 /* */ |
173 * |
174 /* Subglyph transformation record. */ |
174 * Subglyph transformation record. |
175 /* */ |
175 */ |
176 typedef struct TT_Transform_ |
176 typedef struct TT_Transform_ |
177 { |
177 { |
178 FT_Fixed xx, xy; /* transformation matrix coefficients */ |
178 FT_Fixed xx, xy; /* transformation matrix coefficients */ |
179 FT_Fixed yx, yy; |
179 FT_Fixed yx, yy; |
180 FT_F26Dot6 ox, oy; /* offsets */ |
180 FT_F26Dot6 ox, oy; /* offsets */ |
181 |
181 |
182 } TT_Transform; |
182 } TT_Transform; |
183 |
183 |
184 |
184 |
185 /*************************************************************************/ |
185 /************************************************************************** |
186 /* */ |
186 * |
187 /* A note regarding non-squared pixels: */ |
187 * A note regarding non-squared pixels: |
188 /* */ |
188 * |
189 /* (This text will probably go into some docs at some time; for now, it */ |
189 * (This text will probably go into some docs at some time; for now, it |
190 /* is kept here to explain some definitions in the TT_Size_Metrics */ |
190 * is kept here to explain some definitions in the TT_Size_Metrics |
191 /* record). */ |
191 * record). |
192 /* */ |
192 * |
193 /* The CVT is a one-dimensional array containing values that control */ |
193 * The CVT is a one-dimensional array containing values that control |
194 /* certain important characteristics in a font, like the height of all */ |
194 * certain important characteristics in a font, like the height of all |
195 /* capitals, all lowercase letter, default spacing or stem width/height. */ |
195 * capitals, all lowercase letter, default spacing or stem width/height. |
196 /* */ |
196 * |
197 /* These values are found in FUnits in the font file, and must be scaled */ |
197 * These values are found in FUnits in the font file, and must be scaled |
198 /* to pixel coordinates before being used by the CVT and glyph programs. */ |
198 * to pixel coordinates before being used by the CVT and glyph programs. |
199 /* Unfortunately, when using distinct x and y resolutions (or distinct x */ |
199 * Unfortunately, when using distinct x and y resolutions (or distinct x |
200 /* and y pointsizes), there are two possible scalings. */ |
200 * and y pointsizes), there are two possible scalings. |
201 /* */ |
201 * |
202 /* A first try was to implement a `lazy' scheme where all values were */ |
202 * A first try was to implement a `lazy' scheme where all values were |
203 /* scaled when first used. However, while some values are always used */ |
203 * scaled when first used. However, while some values are always used |
204 /* in the same direction, some others are used under many different */ |
204 * in the same direction, some others are used under many different |
205 /* circumstances and orientations. */ |
205 * circumstances and orientations. |
206 /* */ |
206 * |
207 /* I have found a simpler way to do the same, and it even seems to work */ |
207 * I have found a simpler way to do the same, and it even seems to work |
208 /* in most of the cases: */ |
208 * in most of the cases: |
209 /* */ |
209 * |
210 /* - All CVT values are scaled to the maximum ppem size. */ |
210 * - All CVT values are scaled to the maximum ppem size. |
211 /* */ |
211 * |
212 /* - When performing a read or write in the CVT, a ratio factor is used */ |
212 * - When performing a read or write in the CVT, a ratio factor is used |
213 /* to perform adequate scaling. Example: */ |
213 * to perform adequate scaling. Example: |
214 /* */ |
214 * |
215 /* x_ppem = 14 */ |
215 * x_ppem = 14 |
216 /* y_ppem = 10 */ |
216 * y_ppem = 10 |
217 /* */ |
217 * |
218 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */ |
218 * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt |
219 /* entries are scaled to it. */ |
219 * entries are scaled to it. |
220 /* */ |
220 * |
221 /* x_ratio = 1.0 */ |
221 * x_ratio = 1.0 |
222 /* y_ratio = y_ppem/ppem (< 1.0) */ |
222 * y_ratio = y_ppem/ppem (< 1.0) |
223 /* */ |
223 * |
224 /* We compute the current ratio like: */ |
224 * We compute the current ratio like: |
225 /* */ |
225 * |
226 /* - If projVector is horizontal, */ |
226 * - If projVector is horizontal, |
227 /* ratio = x_ratio = 1.0 */ |
227 * ratio = x_ratio = 1.0 |
228 /* */ |
228 * |
229 /* - if projVector is vertical, */ |
229 * - if projVector is vertical, |
230 /* ratio = y_ratio */ |
230 * ratio = y_ratio |
231 /* */ |
231 * |
232 /* - else, */ |
232 * - else, |
233 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */ |
233 * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) |
234 /* */ |
234 * |
235 /* Reading a cvt value returns */ |
235 * Reading a cvt value returns |
236 /* ratio * cvt[index] */ |
236 * ratio * cvt[index] |
237 /* */ |
237 * |
238 /* Writing a cvt value in pixels: */ |
238 * Writing a cvt value in pixels: |
239 /* cvt[index] / ratio */ |
239 * cvt[index] / ratio |
240 /* */ |
240 * |
241 /* The current ppem is simply */ |
241 * The current ppem is simply |
242 /* ratio * ppem */ |
242 * ratio * ppem |
243 /* */ |
243 * |
244 /*************************************************************************/ |
244 */ |
245 |
245 |
246 |
246 |
247 /*************************************************************************/ |
247 /************************************************************************** |
248 /* */ |
248 * |
249 /* Metrics used by the TrueType size and context objects. */ |
249 * Metrics used by the TrueType size and context objects. |
250 /* */ |
250 */ |
251 typedef struct TT_Size_Metrics_ |
251 typedef struct TT_Size_Metrics_ |
252 { |
252 { |
253 /* for non-square pixels */ |
253 /* for non-square pixels */ |
254 FT_Long x_ratio; |
254 FT_Long x_ratio; |
255 FT_Long y_ratio; |
255 FT_Long y_ratio; |