sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftincrem.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftincrem.h
4 *
5 * FreeType incremental loading (specification).
6 *
7 * Copyright (C) 2002-2025 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
9 *
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
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
15 *
16 */
17
18
23#ifndef FTINCREM_H_
24#define FTINCREM_H_
25
26#include <freetype/freetype.h>
27#include <freetype/ftparams.h>
28
29#ifdef FREETYPE_H
30#error "freetype.h of FreeType 1 has been loaded!"
31#error "Please fix the directory search order for header files"
32#error "so that freetype.h of FreeType 2 is found first."
33#endif
34
35
36FT_BEGIN_HEADER
37
38 /**************************************************************************
39 *
40 * @section:
41 * incremental
42 *
43 * @title:
44 * Incremental Loading
45 *
46 * @abstract:
47 * Custom Glyph Loading.
48 *
49 * @description:
50 * This section contains various functions used to perform so-called
51 * 'incremental' glyph loading. This is a mode where all glyphs loaded
52 * from a given @FT_Face are provided by the client application.
53 *
54 * Apart from that, all other tables are loaded normally from the font
55 * file. This mode is useful when FreeType is used within another
56 * engine, e.g., a PostScript Imaging Processor.
57 *
58 * To enable this mode, you must use @FT_Open_Face, passing an
59 * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
60 * @FT_Incremental_Interface value. See the comments for
61 * @FT_Incremental_InterfaceRec for an example.
62 *
63 */
64
65
66 /**************************************************************************
67 *
68 * @type:
69 * FT_Incremental
70 *
71 * @description:
72 * An opaque type describing a user-provided object used to implement
73 * 'incremental' glyph loading within FreeType. This is used to support
74 * embedded fonts in certain environments (e.g., PostScript
75 * interpreters), where the glyph data isn't in the font file, or must be
76 * overridden by different values.
77 *
78 * @note:
79 * It is up to client applications to create and implement
80 * @FT_Incremental objects, as long as they provide implementations for
81 * the methods @FT_Incremental_GetGlyphDataFunc,
82 * @FT_Incremental_FreeGlyphDataFunc and
83 * @FT_Incremental_GetGlyphMetricsFunc.
84 *
85 * See the description of @FT_Incremental_InterfaceRec to understand how
86 * to use incremental objects with FreeType.
87 *
88 */
89 typedef struct FT_IncrementalRec_* FT_Incremental;
90
91
92 /**************************************************************************
93 *
94 * @struct:
95 * FT_Incremental_MetricsRec
96 *
97 * @description:
98 * A small structure used to contain the basic glyph metrics returned by
99 * the @FT_Incremental_GetGlyphMetricsFunc method.
100 *
101 * @fields:
102 * bearing_x ::
103 * Left bearing, in font units.
104 *
105 * bearing_y ::
106 * Top bearing, in font units.
107 *
108 * advance ::
109 * Horizontal component of glyph advance, in font units.
110 *
111 * advance_v ::
112 * Vertical component of glyph advance, in font units.
113 *
114 * @note:
115 * These correspond to horizontal or vertical metrics depending on the
116 * value of the `vertical` argument to the function
117 * @FT_Incremental_GetGlyphMetricsFunc.
118 *
119 */
121 {
122 FT_Long bearing_x;
123 FT_Long bearing_y;
124 FT_Long advance;
125 FT_Long advance_v; /* since 2.3.12 */
126
127 } FT_Incremental_MetricsRec;
128
129
130 /**************************************************************************
131 *
132 * @struct:
133 * FT_Incremental_Metrics
134 *
135 * @description:
136 * A handle to an @FT_Incremental_MetricsRec structure.
137 *
138 */
139 typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics;
140
141
142 /**************************************************************************
143 *
144 * @type:
145 * FT_Incremental_GetGlyphDataFunc
146 *
147 * @description:
148 * A function called by FreeType to access a given glyph's data bytes
149 * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
150 * enabled.
151 *
152 * Note that the format of the glyph's data bytes depends on the font
153 * file format. For TrueType, it must correspond to the raw bytes within
154 * the 'glyf' table. For PostScript formats, it must correspond to the
155 * **unencrypted** charstring bytes, without any `lenIV` header. It is
156 * undefined for any other format.
157 *
158 * @input:
159 * incremental ::
160 * Handle to an opaque @FT_Incremental handle provided by the client
161 * application.
162 *
163 * glyph_index ::
164 * Index of relevant glyph.
165 *
166 * @output:
167 * adata ::
168 * A structure describing the returned glyph data bytes (which will be
169 * accessed as a read-only byte block).
170 *
171 * @return:
172 * FreeType error code. 0~means success.
173 *
174 * @note:
175 * If this function returns successfully the method
176 * @FT_Incremental_FreeGlyphDataFunc will be called later to release the
177 * data bytes.
178 *
179 * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
180 * compound glyphs.
181 *
182 */
183 typedef FT_Error
184 (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
185 FT_UInt glyph_index,
186 FT_Data* adata );
187
188
189 /**************************************************************************
190 *
191 * @type:
192 * FT_Incremental_FreeGlyphDataFunc
193 *
194 * @description:
195 * A function used to release the glyph data bytes returned by a
196 * successful call to @FT_Incremental_GetGlyphDataFunc.
197 *
198 * @input:
199 * incremental ::
200 * A handle to an opaque @FT_Incremental handle provided by the client
201 * application.
202 *
203 * data ::
204 * A structure describing the glyph data bytes (which will be accessed
205 * as a read-only byte block).
206 *
207 */
208 typedef void
209 (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
210 FT_Data* data );
211
212
213 /**************************************************************************
214 *
215 * @type:
216 * FT_Incremental_GetGlyphMetricsFunc
217 *
218 * @description:
219 * A function used to retrieve the basic metrics of a given glyph index
220 * before accessing its data. This allows for handling font types such
221 * as PCL~XL Format~1, Class~2 downloaded TrueType fonts, where the glyph
222 * metrics (`hmtx` and `vmtx` tables) are permitted to be omitted from
223 * the font, and the relevant metrics included in the header of the glyph
224 * outline data. Importantly, this is not intended to allow custom glyph
225 * metrics (for example, Postscript Metrics dictionaries), because that
226 * conflicts with the requirements of outline hinting. Such custom
227 * metrics must be handled separately, by the calling application.
228 *
229 * @input:
230 * incremental ::
231 * A handle to an opaque @FT_Incremental handle provided by the client
232 * application.
233 *
234 * glyph_index ::
235 * Index of relevant glyph.
236 *
237 * vertical ::
238 * If true, return vertical metrics.
239 *
240 * ametrics ::
241 * This parameter is used for both input and output. The original
242 * glyph metrics, if any, in font units. If metrics are not available
243 * all the values must be set to zero.
244 *
245 * @output:
246 * ametrics ::
247 * The glyph metrics in font units.
248 *
249 */
250 typedef FT_Error
251 (*FT_Incremental_GetGlyphMetricsFunc)
252 ( FT_Incremental incremental,
253 FT_UInt glyph_index,
254 FT_Bool vertical,
255 FT_Incremental_MetricsRec *ametrics );
256
257
258 /**************************************************************************
259 *
260 * @struct:
261 * FT_Incremental_FuncsRec
262 *
263 * @description:
264 * A table of functions for accessing fonts that load data incrementally.
265 * Used in @FT_Incremental_InterfaceRec.
266 *
267 * @fields:
268 * get_glyph_data ::
269 * The function to get glyph data. Must not be null.
270 *
271 * free_glyph_data ::
272 * The function to release glyph data. Must not be null.
273 *
274 * get_glyph_metrics ::
275 * The function to get glyph metrics. May be null if the font does not
276 * require it.
277 *
278 */
280 {
281 FT_Incremental_GetGlyphDataFunc get_glyph_data;
282 FT_Incremental_FreeGlyphDataFunc free_glyph_data;
283 FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
284
285 } FT_Incremental_FuncsRec;
286
287
288 /**************************************************************************
289 *
290 * @struct:
291 * FT_Incremental_InterfaceRec
292 *
293 * @description:
294 * A structure to be used with @FT_Open_Face to indicate that the user
295 * wants to support incremental glyph loading. You should use it with
296 * @FT_PARAM_TAG_INCREMENTAL as in the following example:
297 *
298 * ```
299 * FT_Incremental_InterfaceRec inc_int;
300 * FT_Parameter parameter;
301 * FT_Open_Args open_args;
302 *
303 *
304 * // set up incremental descriptor
305 * inc_int.funcs = my_funcs;
306 * inc_int.object = my_object;
307 *
308 * // set up optional parameter
309 * parameter.tag = FT_PARAM_TAG_INCREMENTAL;
310 * parameter.data = &inc_int;
311 *
312 * // set up FT_Open_Args structure
313 * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
314 * open_args.pathname = my_font_pathname;
315 * open_args.num_params = 1;
316 * open_args.params = &parameter; // we use one optional argument
317 *
318 * // open the font
319 * error = FT_Open_Face( library, &open_args, index, &face );
320 * ...
321 * ```
322 *
323 */
325 {
326 const FT_Incremental_FuncsRec* funcs;
327 FT_Incremental object;
328
329 } FT_Incremental_InterfaceRec;
330
331
332 /**************************************************************************
333 *
334 * @type:
335 * FT_Incremental_Interface
336 *
337 * @description:
338 * A pointer to an @FT_Incremental_InterfaceRec structure.
339 *
340 */
341 typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
342
343
344 /* */
345
346
347FT_END_HEADER
348
349#endif /* FTINCREM_H_ */
350
351
352/* END */