1 /***************************************************************************/
5 /* FreeType incremental loading (specification). */
7 /* Copyright 2002 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
19 #ifndef __FTINCREM_H__
20 #define __FTINCREM_H__
23 #include FT_FREETYPE_H
29 /***************************************************************************
35 * An opaque type describing a user-provided object used to implement
36 * "incremental" glyph loading within FreeType. This is used to support
37 * embedded fonts in certain environments (e.g. Postscript interpreters),
38 * where the glyph data isn't in the font file, or must be overridden by
42 * It is up to client applications to create and implement @FT_Incremental
43 * objects, as long as they provide implementations for the methods
44 * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
45 * and @FT_Incremental_GetGlyphMetricsFunc.
47 * See the description of @FT_Incremental_InterfaceRec to understand how
48 * to use incremental objects with FreeType.
50 typedef struct FT_IncrementalRec_* FT_Incremental;
53 /***************************************************************************
56 * FT_Incremental_Metrics
59 * A small structure used to contain the basic glyph metrics returned
60 * by the @FT_Incremental_GetGlyphMetricsFunc method.
64 * Left bearing, in font units.
67 * Top bearing, in font units.
70 * Glyph advance, in font units.
73 * These correspond to horizontal or vertical metrics depending on the
74 * value of the 'vertical' argument to the function
75 * @FT_Incremental_GetGlyphMetricsFunc.
77 typedef struct FT_Incremental_MetricsRec_
83 } FT_Incremental_MetricsRec, *FT_Incremental_Metrics;
86 /***************************************************************************
89 * FT_Incremental_GetGlyphDataFunc
92 * A function called by FreeType to access a given glyph's data bytes
93 * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
96 * Note that the format of the glyph's data bytes depends on the font
97 * file format. For TrueType, it must correspond to the raw bytes within
98 * the 'glyf' table. For Postscript formats, it must correspond to the
99 * *unencrypted* charstring bytes, without any 'lenIV' header. It is
100 * undefined for any other format.
104 * Handle to an opaque @FT_Incremental handle provided by the client
108 * Index of relevant glyph.
112 * A structure describing the returned glyph data bytes (which will be
113 * accessed as a read-only byte block).
116 * FreeType error code. 0 means success.
119 * If this function returns succesfully the method
120 * @FT_Incremental_FreeGlyphDataFunc will be called later to release
123 * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
127 (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
132 /***************************************************************************
135 * FT_Incremental_FreeGlyphDataFunc
138 * A function used to release the glyph data bytes returned by a
139 * successful call to @FT_Incremental_GetGlyphDataFunc.
143 * A handle to an opaque @FT_Incremental handle provided by the client
147 * A structure describing the glyph data bytes (which will be accessed
148 * as a read-only byte block).
151 (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
155 /***************************************************************************
158 * FT_Incremental_GetGlyphMetricsFunc
161 * A function used to retrieve the basic metrics of a given glyph index
162 * before accessing its data. This is necessary because, in certain
163 * formats like TrueType, the metrics are stored in a different place from
164 * the glyph images proper.
168 * A handle to an opaque @FT_Incremental handle provided by the client
172 * Index of relevant glyph.
175 * If true, return vertical metrics.
178 * This parameter is used for both input and output.
179 * The original glyph metrics, if any, in font units. If metrics are
180 * not available all the values must be set to zero.
184 * The replacement glyph metrics in font units.
188 (*FT_Incremental_GetGlyphMetricsFunc)
189 ( FT_Incremental incremental,
192 FT_Incremental_MetricsRec *ametrics );
195 /**************************************************************************
198 * FT_Incremental_FuncsRec
201 * A table of functions for accessing fonts that load data
202 * incrementally. Used in @FT_Incremental_Interface.
206 * The function to get glyph data. Must not be null.
209 * The function to release glyph data. Must not be null.
211 * get_glyph_metrics ::
212 * The function to get glyph metrics. May be null if the font does
213 * not provide overriding glyph metrics.
215 typedef struct FT_Incremental_FuncsRec_
217 FT_Incremental_GetGlyphDataFunc get_glyph_data;
218 FT_Incremental_FreeGlyphDataFunc free_glyph_data;
219 FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
221 } FT_Incremental_FuncsRec;
224 /***************************************************************************
227 * FT_Incremental_InterfaceRec
230 * A structure to be used with @FT_Open_Face to indicate that the user
231 * wants to support incremental glyph loading. You should use it with
232 * @FT_PARAM_TAG_INCREMENTAL as in the following example:
235 * FT_Incremental_InterfaceRec inc_int;
236 * FT_Parameter parameter;
237 * FT_Open_Args open_args;
240 * // set up incremental descriptor
241 * inc_int.funcs = my_funcs;
242 * inc_int.object = my_object;
244 * // set up optional parameter
245 * parameter.tag = FT_PARAM_TAG_INCREMENTAL;
246 * parameter.data = &inc_int;
248 * // set up FT_Open_Args structure
249 * open_args.flags = (FT_Open_Flags)( FT_OPEN_PATHNAME |
251 * open_args.pathname = my_font_pathname;
252 * open_args.num_params = 1;
253 * open_args.params = ¶meter; // we use one optional argument
256 * error = FT_Open_Face( library, &open_args, index, &face );
260 typedef struct FT_Incremental_InterfaceRec_
262 const FT_Incremental_FuncsRec* funcs;
263 FT_Incremental object;
265 } FT_Incremental_InterfaceRec;
268 /***************************************************************************
271 * FT_PARAM_TAG_INCREMENTAL
274 * A constant used as the tag of @FT_Parameter structures to indicate
275 * an incremental loading object to be used by FreeType.
278 #define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
284 #endif /* __FTINCREM_H__ */