1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
/***************************************************************************/
/* */
/* ftcache.h */
/* */
/* FreeType Cache subsystem. */
/* */
/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/********* *********/
/********* WARNING, THIS IS ALPHA CODE, THIS API *********/
/********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
/********* FREETYPE DEVELOPMENT TEAM *********/
/********* *********/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifndef FTCACHE_H
#define FTCACHE_H
#include <freetype/ftglyph.h>
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** BASIC TYPE DEFINITIONS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Type> */
/* FTC_FaceID */
/* */
/* <Description> */
/* A generic pointer type that is used to identity face objects. The */
/* contents of such objects is application-dependent. */
/* */
typedef FT_Pointer FTC_FaceID;
/*************************************************************************/
/* */
/* <FuncType> */
/* FTC_Face_Requester */
/* */
/* <Description> */
/* A callback function provided by client applications. It is used */
/* to translate a given FTC_FaceID into a new valid FT_Face object. */
/* */
/* <Input> */
/* face_id :: The face ID to resolve. */
/* */
/* library :: A handle to a FreeType library object. */
/* */
/* data :: Application-provided request data. */
/* */
/* <Output> */
/* aface :: A new FT_Face handle. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id,
FT_Library library,
FT_Pointer request_data,
FT_Face* aface );
/*************************************************************************/
/* */
/* <Struct> */
/* FTC_FontRec */
/* */
/* <Description> */
/* A simple structure used to describe a given `font' to the cache */
/* manager. Note that a `font' is the combination of a given face */
/* with a given character size. */
/* */
/* <Fields> */
/* face_id :: The ID of the face to use. */
/* */
/* pix_width :: The character width in integer pixels. */
/* */
/* pix_height :: The character height in integer pixels. */
/* */
typedef struct FTC_FontRec_
{
FTC_FaceID face_id;
FT_UShort pix_width;
FT_UShort pix_height;
} FTC_FontRec;
/*************************************************************************/
/* */
/* <Type> */
/* FTC_Font */
/* */
/* <Description> */
/* A simple handle to a FTC_FontRec structure. */
/* */
typedef FTC_FontRec* FTC_Font;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** CACHE MANAGER OBJECT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Type> */
/* FTC_Manager */
/* */
/* <Description> */
/* This object is used to cache one or more FT_Face objects, along */
/* with corresponding FT_Size objects. */
/* */
typedef struct FTC_ManagerRec_* FTC_Manager;
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Manager_New */
/* */
/* <Description> */
/* Creates a new cache manager. */
/* */
/* <Input> */
/* library :: The parent FreeType library handle to use. */
/* */
/* max_faces :: Maximum number of faces to keep alive in manager. */
/* Use 0 for defaults. */
/* */
/* max_sizes :: Maximum number of sizes to keep alive in manager. */
/* Use 0 for defaults. */
/* */
/* max_bytes :: Maximum number of bytes to use for cached data. */
/* Use 0 for defaults. */
/* */
/* requester :: An application-provided callback used to translate */
/* face IDs into real FT_Face objects. */
/* */
/* req_data :: A generic pointer that is passed to the requester */
/* each time it is called (see FTC_Face_Requester) */
/* */
/* <Output> */
/* amanager :: A handle to a new manager object. 0 in case of */
/* failure. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_New( FT_Library library,
FT_UInt max_faces,
FT_UInt max_sizes,
FT_ULong max_bytes,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager* amanager );
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Manager_Reset */
/* */
/* <Description> */
/* Empties a given cache manager. This simply gets rid of all the */
/* currently cached FT_Face & FT_Size objects within the manager. */
/* */
/* <Input> */
/* manager :: A handle to the manager. */
/* */
FT_EXPORT_DEF( void ) FTC_Manager_Reset( FTC_Manager manager );
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Manager_Done */
/* */
/* <Description> */
/* Destroys a given manager after emptying it. */
/* */
/* <Input> */
/* manager :: A handle to the target cache manager object. */
/* */
FT_EXPORT_DEF( void ) FTC_Manager_Done( FTC_Manager manager );
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Manager_Lookup_Face */
/* */
/* <Description> */
/* Retrieves the FT_Face object that corresponds to a given face ID */
/* through a cache manager. */
/* */
/* <Input> */
/* manager :: A handle to the cache manager. */
/* */
/* face_id :: The ID of the face object. */
/* */
/* <Output> */
/* aface :: A handle to the face object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The returned FT_Face object is always owned by the manager. You */
/* should never try to discard it yourself. */
/* */
/* The FT_Face object doesn't necessarily have a current size object */
/* (i.e., face->size can be 0). If you need a specific `font size', */
/* use FTC_Manager_Lookup_Size() instead. */
/* */
/* Never change the face's transformation matrix (i.e., never call */
/* the FT_Set_Transform() function) on a returned face! If you need */
/* to transform glyphs, do it yourself after glyph loading. */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Face( FTC_Manager manager,
FTC_FaceID face_id,
FT_Face* aface );
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Manager_Lookup_Size */
/* */
/* <Description> */
/* Retrieves the FT_Face & FT_Size objects that correspond to a given */
/* FTC_SizeID. */
/* */
/* <Input> */
/* manager :: A handle to the cache manager. */
/* */
/* size_id :: The ID of the `font size' to use. */
/* */
/* <InOut> */
/* aface :: A pointer to the handle of the face object. Set it to */
/* zero if you don't need it. */
/* */
/* asize :: A pointer to the handle of the size object. Set it to */
/* zero if you don't need it. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The returned FT_Face object is always owned by the manager. You */
/* should never try to discard it yourself. */
/* */
/* Never change the face's transformation matrix (i.e., never call */
/* the FT_Set_Transform() function) on a returned face! If you need */
/* to transform glyphs, do it yourself after glyph loading. */
/* */
/* Similarly, the returned FT_Size object is always owned by the */
/* manager. You should never try to discard it, and never change its */
/* settings with FT_Set_Pixel_Sizes() or FT_Set_Char_Size()! */
/* */
/* The returned size object is the face's current size, which means */
/* that you can call FT_Load_Glyph() with the face if you need to. */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Lookup_Size( FTC_Manager manager,
FTC_Font font,
FT_Face* aface,
FT_Size* asize );
/* a cache class is used to describe a unique cache type to the manager */
typedef struct FTC_Cache_Class_ FTC_Cache_Class;
typedef struct FTC_CacheRec_* FTC_Cache;
/* this must be used internally for the moment */
FT_EXPORT_DEF( FT_Error ) FTC_Manager_Register_Cache(
FTC_Manager manager,
FTC_Cache_Class* clazz,
FTC_Cache* acache );
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** IMAGE CACHE OBJECT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 )
/*************************************************************************/
/* */
/* <Enum> */
/* FTC_Image_Type */
/* */
/* <Description> */
/* An enumeration used to list the types of glyph images found in a */
/* glyph image cache. */
/* */
/* <Fields> */
/* ftc_image_mono :: Monochrome bitmap glyphs. */
/* */
/* ftc_image_grays :: Anti-aliased bitmap glyphs. */
/* */
/* ftc_image_outline :: Scaled (and hinted) outline glyphs. */
/* */
/* ftc_master_outline :: Unscaled original outline glyphs. */
/* */
/* <Note> */
/* Other types may be defined in the future. */
/* */
typedef enum FTC_Image_Type_
{
ftc_image_format_bitmap = 0,
ftc_image_format_outline = 1,
ftc_image_flag_monochrome = 16,
ftc_image_flag_unhinted = 32,
ftc_image_flag_autohinted = 64,
ftc_image_flag_unscaled = 128,
ftc_image_flag_no_sbits = 256,
ftc_image_mono = ftc_image_format_bitmap |
ftc_image_flag_monochrome, /* monochrome bitmap */
ftc_image_grays = ftc_image_format_bitmap, /* anti-aliased bitmap */
ftc_image_outline = ftc_image_format_outline /* scaled outline */
} FTC_Image_Type;
/*************************************************************************/
/* */
/* <Struct> */
/* FTC_Image_Desc */
/* */
/* <Description> */
/* A simple structure used to describe a given glyph image category. */
/* */
/* <Fields> */
/* size :: An FTC_SizeRec used to describe the glyph's face & */
/* size. */
/* */
/* image_type :: The glyph image's type. */
/* */
typedef struct FTC_Image_Desc_
{
FTC_FontRec font;
FT_UInt image_type;
} FTC_Image_Desc;
/*************************************************************************/
/* */
/* <Type> */
/* FTC_Image_Cache */
/* */
/* <Description> */
/* A handle to an glyph image cache object. They are designed to */
/* hold many distinct glyph images, while not exceeding a certain */
/* memory threshold. */
/* */
typedef struct FTC_Image_CacheRec_* FTC_Image_Cache;
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Image_Cache_New */
/* */
/* <Description> */
/* Creates a new glyph image cache. */
/* */
/* <Input> */
/* manager :: The parent manager for the image cache. */
/* */
/* <Output> */
/* acache :: A handle to the new glyph image cache object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager,
FTC_Image_Cache* acache );
/*************************************************************************/
/* */
/* <Function> */
/* FTC_Image_Cache_Lookup */
/* */
/* <Description> */
/* Retrieves a given glyph image from a glyph image cache. */
/* */
/* <Input> */
/* cache :: A handle to the source glyph image cache. */
/* */
/* desc :: A pointer to a glyph image descriptor. */
/* */
/* gindex :: The glyph index to retrieve. */
/* */
/* <Output> */
/* aglyph :: The corresponding FT_Glyph object. 0 in case of */
/* failure. */
/* */
/* <Return> */
/* FreType error code. 0 means success. */
/* */
/* <Note> */
/* the returned glyph is owned and manager by the glyph image cache. */
/* Never try to transform or discard it manually! You can however */
/* create a copy with FT_Glyph_Copy() and modify the new one. */
/* */
/* Because the glyph image cache limits the total amount of memory */
/* taken by the glyphs it holds, the returned glyph might disappear */
/* on a later invocation of this function! It's a cache after all... */
/* */
FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup(
FTC_Image_Cache cache,
FTC_Image_Desc* desc,
FT_UInt gindex,
FT_Glyph* aglyph );
#ifdef __cplusplus
}
#endif
#endif /* FTCACHE_H */
/* END */