|
|
|||
Warning, file /include/freetype2/freetype/ftcache.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /**************************************************************************** 0002 * 0003 * ftcache.h 0004 * 0005 * FreeType Cache subsystem (specification). 0006 * 0007 * Copyright (C) 1996-2023 by 0008 * David Turner, Robert Wilhelm, and Werner Lemberg. 0009 * 0010 * This file is part of the FreeType project, and may only be used, 0011 * modified, and distributed under the terms of the FreeType project 0012 * license, LICENSE.TXT. By continuing to use, modify, or distribute 0013 * this file you indicate that you have read the license and 0014 * understand and accept it fully. 0015 * 0016 */ 0017 0018 0019 #ifndef FTCACHE_H_ 0020 #define FTCACHE_H_ 0021 0022 0023 #include <freetype/ftglyph.h> 0024 0025 0026 FT_BEGIN_HEADER 0027 0028 0029 /************************************************************************** 0030 * 0031 * @section: 0032 * cache_subsystem 0033 * 0034 * @title: 0035 * Cache Sub-System 0036 * 0037 * @abstract: 0038 * How to cache face, size, and glyph data with FreeType~2. 0039 * 0040 * @description: 0041 * This section describes the FreeType~2 cache sub-system, which is used 0042 * to limit the number of concurrently opened @FT_Face and @FT_Size 0043 * objects, as well as caching information like character maps and glyph 0044 * images while limiting their maximum memory usage. 0045 * 0046 * Note that all types and functions begin with the `FTC_` prefix rather 0047 * than the usual `FT_` prefix in the rest of FreeType. 0048 * 0049 * The cache is highly portable and, thus, doesn't know anything about 0050 * the fonts installed on your system, or how to access them. Therefore, 0051 * it requires the following. 0052 * 0053 * * @FTC_FaceID, an arbitrary non-zero value that uniquely identifies 0054 * available or installed font faces, has to be provided to the 0055 * cache by the client. Note that the cache only stores and compares 0056 * these values and doesn't try to interpret them in any way, but they 0057 * have to be persistent on the client side. 0058 * 0059 * * @FTC_Face_Requester, a method to convert an @FTC_FaceID into a new 0060 * @FT_Face object when necessary, has to be provided to the cache by 0061 * the client. The @FT_Face object is completely managed by the cache, 0062 * including its termination through @FT_Done_Face. To monitor 0063 * termination of face objects, the finalizer callback in the `generic` 0064 * field of the @FT_Face object can be used, which might also be used 0065 * to store the @FTC_FaceID of the face. 0066 * 0067 * Clients are free to map face IDs to anything useful. The most simple 0068 * usage is, for example, to associate them to a `{pathname,face_index}` 0069 * pair that is then used by @FTC_Face_Requester to call @FT_New_Face. 0070 * However, more complex schemes are also possible. 0071 * 0072 * Note that for the cache to work correctly, the face ID values must be 0073 * **persistent**, which means that the contents they point to should not 0074 * change at runtime, or that their value should not become invalid. 0075 * If this is unavoidable (e.g., when a font is uninstalled at runtime), 0076 * you should call @FTC_Manager_RemoveFaceID as soon as possible to let 0077 * the cache get rid of any references to the old @FTC_FaceID it may keep 0078 * internally. Failure to do so will lead to incorrect behaviour or even 0079 * crashes in @FTC_Face_Requester. 0080 * 0081 * To use the cache, start with calling @FTC_Manager_New to create a new 0082 * @FTC_Manager object, which models a single cache instance. You can 0083 * then look up @FT_Face and @FT_Size objects with 0084 * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively, and 0085 * use them in any FreeType work stream. You can also cache other 0086 * FreeType objects as follows. 0087 * 0088 * * If you want to use the charmap caching, call @FTC_CMapCache_New, 0089 * then later use @FTC_CMapCache_Lookup to perform the equivalent of 0090 * @FT_Get_Char_Index, only much faster. 0091 * 0092 * * If you want to use the @FT_Glyph caching, call @FTC_ImageCache_New, 0093 * then later use @FTC_ImageCache_Lookup to retrieve the corresponding 0094 * @FT_Glyph objects from the cache. 0095 * 0096 * * If you need lots of small bitmaps, it is much more memory-efficient 0097 * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This 0098 * returns @FTC_SBitRec structures, which are used to store small 0099 * bitmaps directly. (A small bitmap is one whose metrics and 0100 * dimensions all fit into 8-bit integers). 0101 * 0102 * @order: 0103 * FTC_Manager 0104 * FTC_FaceID 0105 * FTC_Face_Requester 0106 * 0107 * FTC_Manager_New 0108 * FTC_Manager_Reset 0109 * FTC_Manager_Done 0110 * FTC_Manager_LookupFace 0111 * FTC_Manager_LookupSize 0112 * FTC_Manager_RemoveFaceID 0113 * 0114 * FTC_Node 0115 * FTC_Node_Unref 0116 * 0117 * FTC_ImageCache 0118 * FTC_ImageCache_New 0119 * FTC_ImageCache_Lookup 0120 * 0121 * FTC_SBit 0122 * FTC_SBitCache 0123 * FTC_SBitCache_New 0124 * FTC_SBitCache_Lookup 0125 * 0126 * FTC_CMapCache 0127 * FTC_CMapCache_New 0128 * FTC_CMapCache_Lookup 0129 * 0130 *************************************************************************/ 0131 0132 0133 /*************************************************************************/ 0134 /*************************************************************************/ 0135 /*************************************************************************/ 0136 /***** *****/ 0137 /***** BASIC TYPE DEFINITIONS *****/ 0138 /***** *****/ 0139 /*************************************************************************/ 0140 /*************************************************************************/ 0141 /*************************************************************************/ 0142 0143 0144 /************************************************************************** 0145 * 0146 * @type: 0147 * FTC_FaceID 0148 * 0149 * @description: 0150 * An opaque pointer type that is used to identity face objects. The 0151 * contents of such objects is application-dependent. 0152 * 0153 * These pointers are typically used to point to a user-defined structure 0154 * containing a font file path, and face index. 0155 * 0156 * @note: 0157 * Never use `NULL` as a valid @FTC_FaceID. 0158 * 0159 * Face IDs are passed by the client to the cache manager that calls, 0160 * when needed, the @FTC_Face_Requester to translate them into new 0161 * @FT_Face objects. 0162 * 0163 * If the content of a given face ID changes at runtime, or if the value 0164 * becomes invalid (e.g., when uninstalling a font), you should 0165 * immediately call @FTC_Manager_RemoveFaceID before any other cache 0166 * function. 0167 * 0168 * Failure to do so will result in incorrect behaviour or even memory 0169 * leaks and crashes. 0170 */ 0171 typedef FT_Pointer FTC_FaceID; 0172 0173 0174 /************************************************************************** 0175 * 0176 * @functype: 0177 * FTC_Face_Requester 0178 * 0179 * @description: 0180 * A callback function provided by client applications. It is used by 0181 * the cache manager to translate a given @FTC_FaceID into a new valid 0182 * @FT_Face object, on demand. 0183 * 0184 * @input: 0185 * face_id :: 0186 * The face ID to resolve. 0187 * 0188 * library :: 0189 * A handle to a FreeType library object. 0190 * 0191 * req_data :: 0192 * Application-provided request data (see note below). 0193 * 0194 * @output: 0195 * aface :: 0196 * A new @FT_Face handle. 0197 * 0198 * @return: 0199 * FreeType error code. 0~means success. 0200 * 0201 * @note: 0202 * The third parameter `req_data` is the same as the one passed by the 0203 * client when @FTC_Manager_New is called. 0204 * 0205 * The face requester should not perform funny things on the returned 0206 * face object, like creating a new @FT_Size for it, or setting a 0207 * transformation through @FT_Set_Transform! 0208 */ 0209 typedef FT_Error 0210 (*FTC_Face_Requester)( FTC_FaceID face_id, 0211 FT_Library library, 0212 FT_Pointer req_data, 0213 FT_Face* aface ); 0214 0215 /* */ 0216 0217 0218 /*************************************************************************/ 0219 /*************************************************************************/ 0220 /*************************************************************************/ 0221 /***** *****/ 0222 /***** CACHE MANAGER OBJECT *****/ 0223 /***** *****/ 0224 /*************************************************************************/ 0225 /*************************************************************************/ 0226 /*************************************************************************/ 0227 0228 0229 /************************************************************************** 0230 * 0231 * @type: 0232 * FTC_Manager 0233 * 0234 * @description: 0235 * This object corresponds to one instance of the cache-subsystem. It is 0236 * used to cache one or more @FT_Face objects, along with corresponding 0237 * @FT_Size objects. 0238 * 0239 * The manager intentionally limits the total number of opened @FT_Face 0240 * and @FT_Size objects to control memory usage. See the `max_faces` and 0241 * `max_sizes` parameters of @FTC_Manager_New. 0242 * 0243 * The manager is also used to cache 'nodes' of various types while 0244 * limiting their total memory usage. 0245 * 0246 * All limitations are enforced by keeping lists of managed objects in 0247 * most-recently-used order, and flushing old nodes to make room for new 0248 * ones. 0249 */ 0250 typedef struct FTC_ManagerRec_* FTC_Manager; 0251 0252 0253 /************************************************************************** 0254 * 0255 * @type: 0256 * FTC_Node 0257 * 0258 * @description: 0259 * An opaque handle to a cache node object. Each cache node is 0260 * reference-counted. A node with a count of~0 might be flushed out of a 0261 * full cache whenever a lookup request is performed. 0262 * 0263 * If you look up nodes, you have the ability to 'acquire' them, i.e., to 0264 * increment their reference count. This will prevent the node from 0265 * being flushed out of the cache until you explicitly 'release' it (see 0266 * @FTC_Node_Unref). 0267 * 0268 * See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. 0269 */ 0270 typedef struct FTC_NodeRec_* FTC_Node; 0271 0272 0273 /************************************************************************** 0274 * 0275 * @function: 0276 * FTC_Manager_New 0277 * 0278 * @description: 0279 * Create a new cache manager. 0280 * 0281 * @input: 0282 * library :: 0283 * The parent FreeType library handle to use. 0284 * 0285 * max_faces :: 0286 * Maximum number of opened @FT_Face objects managed by this cache 0287 * instance. Use~0 for defaults. 0288 * 0289 * max_sizes :: 0290 * Maximum number of opened @FT_Size objects managed by this cache 0291 * instance. Use~0 for defaults. 0292 * 0293 * max_bytes :: 0294 * Maximum number of bytes to use for cached data nodes. Use~0 for 0295 * defaults. Note that this value does not account for managed 0296 * @FT_Face and @FT_Size objects. 0297 * 0298 * requester :: 0299 * An application-provided callback used to translate face IDs into 0300 * real @FT_Face objects. 0301 * 0302 * req_data :: 0303 * A generic pointer that is passed to the requester each time it is 0304 * called (see @FTC_Face_Requester). 0305 * 0306 * @output: 0307 * amanager :: 0308 * A handle to a new manager object. 0~in case of failure. 0309 * 0310 * @return: 0311 * FreeType error code. 0~means success. 0312 */ 0313 FT_EXPORT( FT_Error ) 0314 FTC_Manager_New( FT_Library library, 0315 FT_UInt max_faces, 0316 FT_UInt max_sizes, 0317 FT_ULong max_bytes, 0318 FTC_Face_Requester requester, 0319 FT_Pointer req_data, 0320 FTC_Manager *amanager ); 0321 0322 0323 /************************************************************************** 0324 * 0325 * @function: 0326 * FTC_Manager_Reset 0327 * 0328 * @description: 0329 * Empty a given cache manager. This simply gets rid of all the 0330 * currently cached @FT_Face and @FT_Size objects within the manager. 0331 * 0332 * @inout: 0333 * manager :: 0334 * A handle to the manager. 0335 */ 0336 FT_EXPORT( void ) 0337 FTC_Manager_Reset( FTC_Manager manager ); 0338 0339 0340 /************************************************************************** 0341 * 0342 * @function: 0343 * FTC_Manager_Done 0344 * 0345 * @description: 0346 * Destroy a given manager after emptying it. 0347 * 0348 * @input: 0349 * manager :: 0350 * A handle to the target cache manager object. 0351 */ 0352 FT_EXPORT( void ) 0353 FTC_Manager_Done( FTC_Manager manager ); 0354 0355 0356 /************************************************************************** 0357 * 0358 * @function: 0359 * FTC_Manager_LookupFace 0360 * 0361 * @description: 0362 * Retrieve the @FT_Face object that corresponds to a given face ID 0363 * through a cache manager. 0364 * 0365 * @input: 0366 * manager :: 0367 * A handle to the cache manager. 0368 * 0369 * face_id :: 0370 * The ID of the face object. 0371 * 0372 * @output: 0373 * aface :: 0374 * A handle to the face object. 0375 * 0376 * @return: 0377 * FreeType error code. 0~means success. 0378 * 0379 * @note: 0380 * The returned @FT_Face object is always owned by the manager. You 0381 * should never try to discard it yourself. 0382 * 0383 * The @FT_Face object doesn't necessarily have a current size object 0384 * (i.e., face->size can be~0). If you need a specific 'font size', use 0385 * @FTC_Manager_LookupSize instead. 0386 * 0387 * Never change the face's transformation matrix (i.e., never call the 0388 * @FT_Set_Transform function) on a returned face! If you need to 0389 * transform glyphs, do it yourself after glyph loading. 0390 * 0391 * When you perform a lookup, out-of-memory errors are detected _within_ 0392 * the lookup and force incremental flushes of the cache until enough 0393 * memory is released for the lookup to succeed. 0394 * 0395 * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already 0396 * been completely flushed, and still no memory was available for the 0397 * operation. 0398 */ 0399 FT_EXPORT( FT_Error ) 0400 FTC_Manager_LookupFace( FTC_Manager manager, 0401 FTC_FaceID face_id, 0402 FT_Face *aface ); 0403 0404 0405 /************************************************************************** 0406 * 0407 * @struct: 0408 * FTC_ScalerRec 0409 * 0410 * @description: 0411 * A structure used to describe a given character size in either pixels 0412 * or points to the cache manager. See @FTC_Manager_LookupSize. 0413 * 0414 * @fields: 0415 * face_id :: 0416 * The source face ID. 0417 * 0418 * width :: 0419 * The character width. 0420 * 0421 * height :: 0422 * The character height. 0423 * 0424 * pixel :: 0425 * A Boolean. If 1, the `width` and `height` fields are interpreted as 0426 * integer pixel character sizes. Otherwise, they are expressed as 0427 * 1/64 of points. 0428 * 0429 * x_res :: 0430 * Only used when `pixel` is value~0 to indicate the horizontal 0431 * resolution in dpi. 0432 * 0433 * y_res :: 0434 * Only used when `pixel` is value~0 to indicate the vertical 0435 * resolution in dpi. 0436 * 0437 * @note: 0438 * This type is mainly used to retrieve @FT_Size objects through the 0439 * cache manager. 0440 */ 0441 typedef struct FTC_ScalerRec_ 0442 { 0443 FTC_FaceID face_id; 0444 FT_UInt width; 0445 FT_UInt height; 0446 FT_Int pixel; 0447 FT_UInt x_res; 0448 FT_UInt y_res; 0449 0450 } FTC_ScalerRec; 0451 0452 0453 /************************************************************************** 0454 * 0455 * @struct: 0456 * FTC_Scaler 0457 * 0458 * @description: 0459 * A handle to an @FTC_ScalerRec structure. 0460 */ 0461 typedef struct FTC_ScalerRec_* FTC_Scaler; 0462 0463 0464 /************************************************************************** 0465 * 0466 * @function: 0467 * FTC_Manager_LookupSize 0468 * 0469 * @description: 0470 * Retrieve the @FT_Size object that corresponds to a given 0471 * @FTC_ScalerRec pointer through a cache manager. 0472 * 0473 * @input: 0474 * manager :: 0475 * A handle to the cache manager. 0476 * 0477 * scaler :: 0478 * A scaler handle. 0479 * 0480 * @output: 0481 * asize :: 0482 * A handle to the size object. 0483 * 0484 * @return: 0485 * FreeType error code. 0~means success. 0486 * 0487 * @note: 0488 * The returned @FT_Size object is always owned by the manager. You 0489 * should never try to discard it by yourself. 0490 * 0491 * You can access the parent @FT_Face object simply as `size->face` if 0492 * you need it. Note that this object is also owned by the manager. 0493 * 0494 * @note: 0495 * When you perform a lookup, out-of-memory errors are detected _within_ 0496 * the lookup and force incremental flushes of the cache until enough 0497 * memory is released for the lookup to succeed. 0498 * 0499 * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already 0500 * been completely flushed, and still no memory is available for the 0501 * operation. 0502 */ 0503 FT_EXPORT( FT_Error ) 0504 FTC_Manager_LookupSize( FTC_Manager manager, 0505 FTC_Scaler scaler, 0506 FT_Size *asize ); 0507 0508 0509 /************************************************************************** 0510 * 0511 * @function: 0512 * FTC_Node_Unref 0513 * 0514 * @description: 0515 * Decrement a cache node's internal reference count. When the count 0516 * reaches 0, it is not destroyed but becomes eligible for subsequent 0517 * cache flushes. 0518 * 0519 * @input: 0520 * node :: 0521 * The cache node handle. 0522 * 0523 * manager :: 0524 * The cache manager handle. 0525 */ 0526 FT_EXPORT( void ) 0527 FTC_Node_Unref( FTC_Node node, 0528 FTC_Manager manager ); 0529 0530 0531 /************************************************************************** 0532 * 0533 * @function: 0534 * FTC_Manager_RemoveFaceID 0535 * 0536 * @description: 0537 * A special function used to indicate to the cache manager that a given 0538 * @FTC_FaceID is no longer valid, either because its content changed, or 0539 * because it was deallocated or uninstalled. 0540 * 0541 * @input: 0542 * manager :: 0543 * The cache manager handle. 0544 * 0545 * face_id :: 0546 * The @FTC_FaceID to be removed. 0547 * 0548 * @note: 0549 * This function flushes all nodes from the cache corresponding to this 0550 * `face_id`, with the exception of nodes with a non-null reference 0551 * count. 0552 * 0553 * Such nodes are however modified internally so as to never appear in 0554 * later lookups with the same `face_id` value, and to be immediately 0555 * destroyed when released by all their users. 0556 * 0557 */ 0558 FT_EXPORT( void ) 0559 FTC_Manager_RemoveFaceID( FTC_Manager manager, 0560 FTC_FaceID face_id ); 0561 0562 0563 /************************************************************************** 0564 * 0565 * @type: 0566 * FTC_CMapCache 0567 * 0568 * @description: 0569 * An opaque handle used to model a charmap cache. This cache is to hold 0570 * character codes -> glyph indices mappings. 0571 * 0572 */ 0573 typedef struct FTC_CMapCacheRec_* FTC_CMapCache; 0574 0575 0576 /************************************************************************** 0577 * 0578 * @function: 0579 * FTC_CMapCache_New 0580 * 0581 * @description: 0582 * Create a new charmap cache. 0583 * 0584 * @input: 0585 * manager :: 0586 * A handle to the cache manager. 0587 * 0588 * @output: 0589 * acache :: 0590 * A new cache handle. `NULL` in case of error. 0591 * 0592 * @return: 0593 * FreeType error code. 0~means success. 0594 * 0595 * @note: 0596 * Like all other caches, this one will be destroyed with the cache 0597 * manager. 0598 * 0599 */ 0600 FT_EXPORT( FT_Error ) 0601 FTC_CMapCache_New( FTC_Manager manager, 0602 FTC_CMapCache *acache ); 0603 0604 0605 /************************************************************************** 0606 * 0607 * @function: 0608 * FTC_CMapCache_Lookup 0609 * 0610 * @description: 0611 * Translate a character code into a glyph index, using the charmap 0612 * cache. 0613 * 0614 * @input: 0615 * cache :: 0616 * A charmap cache handle. 0617 * 0618 * face_id :: 0619 * The source face ID. 0620 * 0621 * cmap_index :: 0622 * The index of the charmap in the source face. Any negative value 0623 * means to use the cache @FT_Face's default charmap. 0624 * 0625 * char_code :: 0626 * The character code (in the corresponding charmap). 0627 * 0628 * @return: 0629 * Glyph index. 0~means 'no glyph'. 0630 * 0631 */ 0632 FT_EXPORT( FT_UInt ) 0633 FTC_CMapCache_Lookup( FTC_CMapCache cache, 0634 FTC_FaceID face_id, 0635 FT_Int cmap_index, 0636 FT_UInt32 char_code ); 0637 0638 0639 /*************************************************************************/ 0640 /*************************************************************************/ 0641 /*************************************************************************/ 0642 /***** *****/ 0643 /***** IMAGE CACHE OBJECT *****/ 0644 /***** *****/ 0645 /*************************************************************************/ 0646 /*************************************************************************/ 0647 /*************************************************************************/ 0648 0649 0650 /************************************************************************** 0651 * 0652 * @struct: 0653 * FTC_ImageTypeRec 0654 * 0655 * @description: 0656 * A structure used to model the type of images in a glyph cache. 0657 * 0658 * @fields: 0659 * face_id :: 0660 * The face ID. 0661 * 0662 * width :: 0663 * The width in pixels. 0664 * 0665 * height :: 0666 * The height in pixels. 0667 * 0668 * flags :: 0669 * The load flags, as in @FT_Load_Glyph. 0670 * 0671 */ 0672 typedef struct FTC_ImageTypeRec_ 0673 { 0674 FTC_FaceID face_id; 0675 FT_UInt width; 0676 FT_UInt height; 0677 FT_Int32 flags; 0678 0679 } FTC_ImageTypeRec; 0680 0681 0682 /************************************************************************** 0683 * 0684 * @type: 0685 * FTC_ImageType 0686 * 0687 * @description: 0688 * A handle to an @FTC_ImageTypeRec structure. 0689 * 0690 */ 0691 typedef struct FTC_ImageTypeRec_* FTC_ImageType; 0692 0693 0694 /* */ 0695 0696 0697 #define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ 0698 ( (d1)->face_id == (d2)->face_id && \ 0699 (d1)->width == (d2)->width && \ 0700 (d1)->flags == (d2)->flags ) 0701 0702 0703 /************************************************************************** 0704 * 0705 * @type: 0706 * FTC_ImageCache 0707 * 0708 * @description: 0709 * A handle to a glyph image cache object. They are designed to hold 0710 * many distinct glyph images while not exceeding a certain memory 0711 * threshold. 0712 */ 0713 typedef struct FTC_ImageCacheRec_* FTC_ImageCache; 0714 0715 0716 /************************************************************************** 0717 * 0718 * @function: 0719 * FTC_ImageCache_New 0720 * 0721 * @description: 0722 * Create a new glyph image cache. 0723 * 0724 * @input: 0725 * manager :: 0726 * The parent manager for the image cache. 0727 * 0728 * @output: 0729 * acache :: 0730 * A handle to the new glyph image cache object. 0731 * 0732 * @return: 0733 * FreeType error code. 0~means success. 0734 */ 0735 FT_EXPORT( FT_Error ) 0736 FTC_ImageCache_New( FTC_Manager manager, 0737 FTC_ImageCache *acache ); 0738 0739 0740 /************************************************************************** 0741 * 0742 * @function: 0743 * FTC_ImageCache_Lookup 0744 * 0745 * @description: 0746 * Retrieve a given glyph image from a glyph image cache. 0747 * 0748 * @input: 0749 * cache :: 0750 * A handle to the source glyph image cache. 0751 * 0752 * type :: 0753 * A pointer to a glyph image type descriptor. 0754 * 0755 * gindex :: 0756 * The glyph index to retrieve. 0757 * 0758 * @output: 0759 * aglyph :: 0760 * The corresponding @FT_Glyph object. 0~in case of failure. 0761 * 0762 * anode :: 0763 * Used to return the address of the corresponding cache node after 0764 * incrementing its reference count (see note below). 0765 * 0766 * @return: 0767 * FreeType error code. 0~means success. 0768 * 0769 * @note: 0770 * The returned glyph is owned and managed by the glyph image cache. 0771 * Never try to transform or discard it manually! You can however create 0772 * a copy with @FT_Glyph_Copy and modify the new one. 0773 * 0774 * If `anode` is _not_ `NULL`, it receives the address of the cache node 0775 * containing the glyph image, after increasing its reference count. 0776 * This ensures that the node (as well as the @FT_Glyph) will always be 0777 * kept in the cache until you call @FTC_Node_Unref to 'release' it. 0778 * 0779 * If `anode` is `NULL`, the cache node is left unchanged, which means 0780 * that the @FT_Glyph could be flushed out of the cache on the next call 0781 * to one of the caching sub-system APIs. Don't assume that it is 0782 * persistent! 0783 */ 0784 FT_EXPORT( FT_Error ) 0785 FTC_ImageCache_Lookup( FTC_ImageCache cache, 0786 FTC_ImageType type, 0787 FT_UInt gindex, 0788 FT_Glyph *aglyph, 0789 FTC_Node *anode ); 0790 0791 0792 /************************************************************************** 0793 * 0794 * @function: 0795 * FTC_ImageCache_LookupScaler 0796 * 0797 * @description: 0798 * A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec to 0799 * specify the face ID and its size. 0800 * 0801 * @input: 0802 * cache :: 0803 * A handle to the source glyph image cache. 0804 * 0805 * scaler :: 0806 * A pointer to a scaler descriptor. 0807 * 0808 * load_flags :: 0809 * The corresponding load flags. 0810 * 0811 * gindex :: 0812 * The glyph index to retrieve. 0813 * 0814 * @output: 0815 * aglyph :: 0816 * The corresponding @FT_Glyph object. 0~in case of failure. 0817 * 0818 * anode :: 0819 * Used to return the address of the corresponding cache node after 0820 * incrementing its reference count (see note below). 0821 * 0822 * @return: 0823 * FreeType error code. 0~means success. 0824 * 0825 * @note: 0826 * The returned glyph is owned and managed by the glyph image cache. 0827 * Never try to transform or discard it manually! You can however create 0828 * a copy with @FT_Glyph_Copy and modify the new one. 0829 * 0830 * If `anode` is _not_ `NULL`, it receives the address of the cache node 0831 * containing the glyph image, after increasing its reference count. 0832 * This ensures that the node (as well as the @FT_Glyph) will always be 0833 * kept in the cache until you call @FTC_Node_Unref to 'release' it. 0834 * 0835 * If `anode` is `NULL`, the cache node is left unchanged, which means 0836 * that the @FT_Glyph could be flushed out of the cache on the next call 0837 * to one of the caching sub-system APIs. Don't assume that it is 0838 * persistent! 0839 * 0840 * Calls to @FT_Set_Char_Size and friends have no effect on cached 0841 * glyphs; you should always use the FreeType cache API instead. 0842 */ 0843 FT_EXPORT( FT_Error ) 0844 FTC_ImageCache_LookupScaler( FTC_ImageCache cache, 0845 FTC_Scaler scaler, 0846 FT_ULong load_flags, 0847 FT_UInt gindex, 0848 FT_Glyph *aglyph, 0849 FTC_Node *anode ); 0850 0851 0852 /************************************************************************** 0853 * 0854 * @type: 0855 * FTC_SBit 0856 * 0857 * @description: 0858 * A handle to a small bitmap descriptor. See the @FTC_SBitRec structure 0859 * for details. 0860 */ 0861 typedef struct FTC_SBitRec_* FTC_SBit; 0862 0863 0864 /************************************************************************** 0865 * 0866 * @struct: 0867 * FTC_SBitRec 0868 * 0869 * @description: 0870 * A very compact structure used to describe a small glyph bitmap. 0871 * 0872 * @fields: 0873 * width :: 0874 * The bitmap width in pixels. 0875 * 0876 * height :: 0877 * The bitmap height in pixels. 0878 * 0879 * left :: 0880 * The horizontal distance from the pen position to the left bitmap 0881 * border (a.k.a. 'left side bearing', or 'lsb'). 0882 * 0883 * top :: 0884 * The vertical distance from the pen position (on the baseline) to the 0885 * upper bitmap border (a.k.a. 'top side bearing'). The distance is 0886 * positive for upwards y~coordinates. 0887 * 0888 * format :: 0889 * The format of the glyph bitmap (monochrome or gray). 0890 * 0891 * max_grays :: 0892 * Maximum gray level value (in the range 1 to~255). 0893 * 0894 * pitch :: 0895 * The number of bytes per bitmap line. May be positive or negative. 0896 * 0897 * xadvance :: 0898 * The horizontal advance width in pixels. 0899 * 0900 * yadvance :: 0901 * The vertical advance height in pixels. 0902 * 0903 * buffer :: 0904 * A pointer to the bitmap pixels. 0905 */ 0906 typedef struct FTC_SBitRec_ 0907 { 0908 FT_Byte width; 0909 FT_Byte height; 0910 FT_Char left; 0911 FT_Char top; 0912 0913 FT_Byte format; 0914 FT_Byte max_grays; 0915 FT_Short pitch; 0916 FT_Char xadvance; 0917 FT_Char yadvance; 0918 0919 FT_Byte* buffer; 0920 0921 } FTC_SBitRec; 0922 0923 0924 /************************************************************************** 0925 * 0926 * @type: 0927 * FTC_SBitCache 0928 * 0929 * @description: 0930 * A handle to a small bitmap cache. These are special cache objects 0931 * used to store small glyph bitmaps (and anti-aliased pixmaps) in a much 0932 * more efficient way than the traditional glyph image cache implemented 0933 * by @FTC_ImageCache. 0934 */ 0935 typedef struct FTC_SBitCacheRec_* FTC_SBitCache; 0936 0937 0938 /************************************************************************** 0939 * 0940 * @function: 0941 * FTC_SBitCache_New 0942 * 0943 * @description: 0944 * Create a new cache to store small glyph bitmaps. 0945 * 0946 * @input: 0947 * manager :: 0948 * A handle to the source cache manager. 0949 * 0950 * @output: 0951 * acache :: 0952 * A handle to the new sbit cache. `NULL` in case of error. 0953 * 0954 * @return: 0955 * FreeType error code. 0~means success. 0956 */ 0957 FT_EXPORT( FT_Error ) 0958 FTC_SBitCache_New( FTC_Manager manager, 0959 FTC_SBitCache *acache ); 0960 0961 0962 /************************************************************************** 0963 * 0964 * @function: 0965 * FTC_SBitCache_Lookup 0966 * 0967 * @description: 0968 * Look up a given small glyph bitmap in a given sbit cache and 'lock' it 0969 * to prevent its flushing from the cache until needed. 0970 * 0971 * @input: 0972 * cache :: 0973 * A handle to the source sbit cache. 0974 * 0975 * type :: 0976 * A pointer to the glyph image type descriptor. 0977 * 0978 * gindex :: 0979 * The glyph index. 0980 * 0981 * @output: 0982 * sbit :: 0983 * A handle to a small bitmap descriptor. 0984 * 0985 * anode :: 0986 * Used to return the address of the corresponding cache node after 0987 * incrementing its reference count (see note below). 0988 * 0989 * @return: 0990 * FreeType error code. 0~means success. 0991 * 0992 * @note: 0993 * The small bitmap descriptor and its bit buffer are owned by the cache 0994 * and should never be freed by the application. They might as well 0995 * disappear from memory on the next cache lookup, so don't treat them as 0996 * persistent data. 0997 * 0998 * The descriptor's `buffer` field is set to~0 to indicate a missing 0999 * glyph bitmap. 1000 * 1001 * If `anode` is _not_ `NULL`, it receives the address of the cache node 1002 * containing the bitmap, after increasing its reference count. This 1003 * ensures that the node (as well as the image) will always be kept in 1004 * the cache until you call @FTC_Node_Unref to 'release' it. 1005 * 1006 * If `anode` is `NULL`, the cache node is left unchanged, which means 1007 * that the bitmap could be flushed out of the cache on the next call to 1008 * one of the caching sub-system APIs. Don't assume that it is 1009 * persistent! 1010 */ 1011 FT_EXPORT( FT_Error ) 1012 FTC_SBitCache_Lookup( FTC_SBitCache cache, 1013 FTC_ImageType type, 1014 FT_UInt gindex, 1015 FTC_SBit *sbit, 1016 FTC_Node *anode ); 1017 1018 1019 /************************************************************************** 1020 * 1021 * @function: 1022 * FTC_SBitCache_LookupScaler 1023 * 1024 * @description: 1025 * A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec to 1026 * specify the face ID and its size. 1027 * 1028 * @input: 1029 * cache :: 1030 * A handle to the source sbit cache. 1031 * 1032 * scaler :: 1033 * A pointer to the scaler descriptor. 1034 * 1035 * load_flags :: 1036 * The corresponding load flags. 1037 * 1038 * gindex :: 1039 * The glyph index. 1040 * 1041 * @output: 1042 * sbit :: 1043 * A handle to a small bitmap descriptor. 1044 * 1045 * anode :: 1046 * Used to return the address of the corresponding cache node after 1047 * incrementing its reference count (see note below). 1048 * 1049 * @return: 1050 * FreeType error code. 0~means success. 1051 * 1052 * @note: 1053 * The small bitmap descriptor and its bit buffer are owned by the cache 1054 * and should never be freed by the application. They might as well 1055 * disappear from memory on the next cache lookup, so don't treat them as 1056 * persistent data. 1057 * 1058 * The descriptor's `buffer` field is set to~0 to indicate a missing 1059 * glyph bitmap. 1060 * 1061 * If `anode` is _not_ `NULL`, it receives the address of the cache node 1062 * containing the bitmap, after increasing its reference count. This 1063 * ensures that the node (as well as the image) will always be kept in 1064 * the cache until you call @FTC_Node_Unref to 'release' it. 1065 * 1066 * If `anode` is `NULL`, the cache node is left unchanged, which means 1067 * that the bitmap could be flushed out of the cache on the next call to 1068 * one of the caching sub-system APIs. Don't assume that it is 1069 * persistent! 1070 */ 1071 FT_EXPORT( FT_Error ) 1072 FTC_SBitCache_LookupScaler( FTC_SBitCache cache, 1073 FTC_Scaler scaler, 1074 FT_ULong load_flags, 1075 FT_UInt gindex, 1076 FTC_SBit *sbit, 1077 FTC_Node *anode ); 1078 1079 /* */ 1080 1081 1082 FT_END_HEADER 1083 1084 #endif /* FTCACHE_H_ */ 1085 1086 1087 /* END */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|