1 /***************************************************************************/
5 /* FreeType Cache subsystem. */
7 /* Copyright 1996-2001 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 /*************************************************************************/
20 /*************************************************************************/
21 /*************************************************************************/
22 /*************************************************************************/
23 /*************************************************************************/
25 /********* WARNING, THIS IS BETA CODE. *********/
27 /*************************************************************************/
28 /*************************************************************************/
29 /*************************************************************************/
30 /*************************************************************************/
31 /*************************************************************************/
45 /*************************************************************************/
51 /* Cache Sub-System */
54 /* How to cache face, size, and glyph data with FreeType 2. */
57 /* This section describes the FreeType 2 cache sub-system which is */
60 /*************************************************************************/
63 /*************************************************************************/
64 /*************************************************************************/
65 /*************************************************************************/
67 /***** BASIC TYPE DEFINITIONS *****/
69 /*************************************************************************/
70 /*************************************************************************/
71 /*************************************************************************/
74 /*************************************************************************/
80 /* A generic pointer type that is used to identity face objects. The */
81 /* contents of such objects is application-dependent. */
83 typedef FT_Pointer FTC_FaceID;
86 /*************************************************************************/
89 /* FTC_Face_Requester */
92 /* A callback function provided by client applications. It is used */
93 /* to translate a given FTC_FaceID into a new valid FT_Face object. */
96 /* face_id :: The face ID to resolve. */
98 /* library :: A handle to a FreeType library object. */
100 /* data :: Application-provided request data. */
103 /* aface :: A new FT_Face handle. */
106 /* FreeType error code. 0 means success. */
109 /* The face requester should not perform funny things on the returned */
110 /* face object, like creating a new FT_Size for it, or setting a */
111 /* transformation through FT_Set_Transform()! */
114 (*FTC_Face_Requester)( FTC_FaceID face_id,
116 FT_Pointer request_data,
120 /*************************************************************************/
126 /* A simple structure used to describe a given `font' to the cache */
127 /* manager. Note that a `font' is the combination of a given face */
128 /* with a given character size. */
131 /* face_id :: The ID of the face to use. */
133 /* pix_width :: The character width in integer pixels. */
135 /* pix_height :: The character height in integer pixels. */
137 typedef struct FTC_FontRec_
141 FT_UShort pix_height;
146 /*************************************************************************/
152 /* A simple handle to a FTC_FontRec structure. */
154 typedef FTC_FontRec* FTC_Font;
157 /*************************************************************************/
158 /*************************************************************************/
159 /*************************************************************************/
161 /***** CACHE MANAGER OBJECT *****/
163 /*************************************************************************/
164 /*************************************************************************/
165 /*************************************************************************/
168 /*************************************************************************/
174 /* This object is used to cache one or more FT_Face objects, along */
175 /* with corresponding FT_Size objects. */
177 typedef struct FTC_ManagerRec_* FTC_Manager;
180 /*************************************************************************/
183 /* FTC_Manager_New */
186 /* Creates a new cache manager. */
189 /* library :: The parent FreeType library handle to use. */
191 /* max_faces :: Maximum number of faces to keep alive in manager. */
192 /* Use 0 for defaults. */
194 /* max_sizes :: Maximum number of sizes to keep alive in manager. */
195 /* Use 0 for defaults. */
197 /* max_bytes :: Maximum number of bytes to use for cached data. */
198 /* Use 0 for defaults. */
200 /* requester :: An application-provided callback used to translate */
201 /* face IDs into real FT_Face objects. */
203 /* req_data :: A generic pointer that is passed to the requester */
204 /* each time it is called (see FTC_Face_Requester) */
207 /* amanager :: A handle to a new manager object. 0 in case of */
211 /* FreeType error code. 0 means success. */
213 FT_EXPORT( FT_Error )
214 FTC_Manager_New( FT_Library library,
218 FTC_Face_Requester requester,
220 FTC_Manager *amanager );
223 /*************************************************************************/
226 /* FTC_Manager_Reset */
229 /* Empties a given cache manager. This simply gets rid of all the */
230 /* currently cached FT_Face & FT_Size objects within the manager. */
233 /* manager :: A handle to the manager. */
236 FTC_Manager_Reset( FTC_Manager manager );
239 /*************************************************************************/
242 /* FTC_Manager_Done */
245 /* Destroys a given manager after emptying it. */
248 /* manager :: A handle to the target cache manager object. */
251 FTC_Manager_Done( FTC_Manager manager );
254 /*************************************************************************/
257 /* FTC_Manager_Lookup_Face */
260 /* Retrieves the FT_Face object that corresponds to a given face ID */
261 /* through a cache manager. */
264 /* manager :: A handle to the cache manager. */
266 /* face_id :: The ID of the face object. */
269 /* aface :: A handle to the face object. */
272 /* FreeType error code. 0 means success. */
275 /* The returned FT_Face object is always owned by the manager. You */
276 /* should never try to discard it yourself. */
278 /* The FT_Face object doesn't necessarily have a current size object */
279 /* (i.e., face->size can be 0). If you need a specific `font size', */
280 /* use FTC_Manager_Lookup_Size() instead. */
282 /* Never change the face's transformation matrix (i.e., never call */
283 /* the FT_Set_Transform() function) on a returned face! If you need */
284 /* to transform glyphs, do it yourself after glyph loading. */
286 FT_EXPORT( FT_Error )
287 FTC_Manager_Lookup_Face( FTC_Manager manager,
292 /*************************************************************************/
295 /* FTC_Manager_Lookup_Size */
298 /* Retrieves the FT_Face & FT_Size objects that correspond to a given */
302 /* manager :: A handle to the cache manager. */
304 /* size_id :: The ID of the `font size' to use. */
307 /* aface :: A pointer to the handle of the face object. Set it to */
308 /* zero if you don't need it. */
310 /* asize :: A pointer to the handle of the size object. Set it to */
311 /* zero if you don't need it. */
314 /* FreeType error code. 0 means success. */
317 /* The returned FT_Face object is always owned by the manager. You */
318 /* should never try to discard it yourself. */
320 /* Never change the face's transformation matrix (i.e., never call */
321 /* the FT_Set_Transform() function) on a returned face! If you need */
322 /* to transform glyphs, do it yourself after glyph loading. */
324 /* Similarly, the returned FT_Size object is always owned by the */
325 /* manager. You should never try to discard it, and never change its */
326 /* settings with FT_Set_Pixel_Sizes() or FT_Set_Char_Size()! */
328 /* The returned size object is the face's current size, which means */
329 /* that you can call FT_Load_Glyph() with the face if you need to. */
331 FT_EXPORT( FT_Error )
332 FTC_Manager_Lookup_Size( FTC_Manager manager,
338 /* a cache class is used to describe a unique cache type to the manager */
339 typedef struct FTC_Cache_Class_ FTC_Cache_Class;
340 typedef struct FTC_CacheRec_* FTC_Cache;
343 /* this must be used internally for the moment */
344 FT_EXPORT( FT_Error )
345 FTC_Manager_Register_Cache( FTC_Manager manager,
346 FTC_Cache_Class* clazz,
355 #endif /* __FTCACHE_H__ */