ftcimage.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /***************************************************************************/
  2. /* */
  3. /* ftcimage.h */
  4. /* */
  5. /* FreeType Image cache (specification). */
  6. /* */
  7. /* Copyright 2000-2001, 2002 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. /* */
  19. /* Each image cache really manages FT_Glyph objects. */
  20. /* */
  21. /*************************************************************************/
  22. #ifndef __FTCIMAGE_H__
  23. #define __FTCIMAGE_H__
  24. #include <ft2build.h>
  25. #include FT_CACHE_H
  26. FT_BEGIN_HEADER
  27. /*************************************************************************/
  28. /* */
  29. /* <Section> */
  30. /* cache_subsystem */
  31. /* */
  32. /*************************************************************************/
  33. /*************************************************************************/
  34. /*************************************************************************/
  35. /*************************************************************************/
  36. /***** *****/
  37. /***** IMAGE CACHE OBJECT *****/
  38. /***** *****/
  39. /*************************************************************************/
  40. /*************************************************************************/
  41. /*************************************************************************/
  42. /**************************************************************************
  43. *
  44. * @struct:
  45. * FTC_ImageTypeRec
  46. *
  47. * @description:
  48. * A simple structure used to describe the type of glyph image to be
  49. * loaded into the cache.
  50. *
  51. * @fields:
  52. * font :: An @FTC_FontRec used to describe the glyph's face and size.
  53. *
  54. * flags :: The load flags to be applied when loading the glyph; see
  55. * the @FT_LOAD_XXX constants for details.
  56. *
  57. * @note:
  58. * This type completely replaces the @FTC_Image_Desc structure which is
  59. * now obsolete.
  60. */
  61. typedef struct FTC_ImageTypeRec_
  62. {
  63. FTC_FontRec font;
  64. FT_Int32 flags;
  65. } FTC_ImageTypeRec;
  66. typedef struct FTC_ImageTypeRec_* FTC_ImageType;
  67. /* */
  68. #define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
  69. ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
  70. (d1)->flags == (d2)->flags )
  71. #define FTC_IMAGE_TYPE_HASH( d ) \
  72. (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
  73. ( (d)->flags << 4 ) )
  74. /*************************************************************************/
  75. /* */
  76. /* <Type> */
  77. /* FTC_ImageCache */
  78. /* */
  79. /* <Description> */
  80. /* A handle to an glyph image cache object. They are designed to */
  81. /* hold many distinct glyph images while not exceeding a certain */
  82. /* memory threshold. */
  83. /* */
  84. typedef struct FTC_ImageCacheRec_* FTC_ImageCache;
  85. /*************************************************************************/
  86. /* */
  87. /* <Function> */
  88. /* FTC_ImageCache_New */
  89. /* */
  90. /* <Description> */
  91. /* Creates a new glyph image cache. */
  92. /* */
  93. /* <Input> */
  94. /* manager :: The parent manager for the image cache. */
  95. /* */
  96. /* <Output> */
  97. /* acache :: A handle to the new glyph image cache object. */
  98. /* */
  99. /* <Return> */
  100. /* FreeType error code. 0 means success. */
  101. /* */
  102. FT_EXPORT( FT_Error )
  103. FTC_ImageCache_New( FTC_Manager manager,
  104. FTC_ImageCache *acache );
  105. /*************************************************************************/
  106. /* */
  107. /* <Function> */
  108. /* FTC_ImageCache_Lookup */
  109. /* */
  110. /* <Description> */
  111. /* Retrieves a given glyph image from a glyph image cache. */
  112. /* */
  113. /* <Input> */
  114. /* cache :: A handle to the source glyph image cache. */
  115. /* */
  116. /* type :: A pointer to a glyph image type descriptor. */
  117. /* */
  118. /* gindex :: The glyph index to retrieve. */
  119. /* */
  120. /* <Output> */
  121. /* aglyph :: The corresponding @FT_Glyph object. 0 in case of */
  122. /* failure. */
  123. /* */
  124. /* anode :: Used to return the address of of the corresponding cache */
  125. /* node after incrementing its reference count (see note */
  126. /* below). */
  127. /* */
  128. /* <Return> */
  129. /* FreeType error code. 0 means success. */
  130. /* */
  131. /* <Note> */
  132. /* The returned glyph is owned and managed by the glyph image cache. */
  133. /* Never try to transform or discard it manually! You can however */
  134. /* create a copy with @FT_Glyph_Copy and modify the new one. */
  135. /* */
  136. /* If "anode" is _not_ NULL, it receives the address of the cache */
  137. /* node containing the glyph image, after increasing its reference */
  138. /* count. This ensures that the node (as well as the FT_Glyph) will */
  139. /* always be kept in the cache until you call @FTC_Node_Unref to */
  140. /* "release" it. */
  141. /* */
  142. /* If "anode" is NULL, the cache node is left unchanged, which means */
  143. /* that the FT_Glyph could be flushed out of the cache on the next */
  144. /* call to one of the caching sub-system APIs. Don't assume that it */
  145. /* is persistent! */
  146. /* */
  147. FT_EXPORT( FT_Error )
  148. FTC_ImageCache_Lookup( FTC_ImageCache cache,
  149. FTC_ImageType type,
  150. FT_UInt gindex,
  151. FT_Glyph *aglyph,
  152. FTC_Node *anode );
  153. /* */
  154. #define ftc_image_format( x ) ( (x) & 7 )
  155. #define ftc_image_format_bitmap 0x0000
  156. #define ftc_image_format_outline 0x0001
  157. #define ftc_image_format_mask 0x000F
  158. #define ftc_image_flag_monochrome 0x0010
  159. #define ftc_image_flag_unhinted 0x0020
  160. #define ftc_image_flag_autohinted 0x0040
  161. #define ftc_image_flag_unscaled 0x0080
  162. #define ftc_image_flag_no_sbits 0x0100
  163. /* monochrome bitmap */
  164. #define ftc_image_mono ftc_image_format_bitmap | \
  165. ftc_image_flag_monochrome
  166. /* anti-aliased bitmap */
  167. #define ftc_image_grays ftc_image_format_bitmap
  168. /* scaled outline */
  169. #define ftc_image_outline ftc_image_format_outline
  170. /*************************************************************************/
  171. /* */
  172. /* <Struct> */
  173. /* FTC_Image_Desc */
  174. /* */
  175. /* <Description> */
  176. /* THIS TYPE IS DEPRECATED. Use @FTC_ImageDesc instead. */
  177. /* */
  178. /* A simple structure used to describe a given glyph image category. */
  179. /* */
  180. /* <Fields> */
  181. /* size :: An @FTC_SizeRec used to describe the glyph's face */
  182. /* and size. */
  183. /* */
  184. /* image_type :: The glyph image's type. */
  185. /* */
  186. typedef struct FTC_Image_Desc_
  187. {
  188. FTC_FontRec font;
  189. FT_UInt image_type;
  190. } FTC_Image_Desc;
  191. /*************************************************************************/
  192. /* */
  193. /* <Type> */
  194. /* FTC_Image_Cache */
  195. /* */
  196. /* <Description> */
  197. /* THIS TYPE IS DEPRECATED. Use @FTC_ImageCache instead. */
  198. /* */
  199. typedef FTC_ImageCache FTC_Image_Cache;
  200. /*************************************************************************/
  201. /* */
  202. /* <Function> */
  203. /* FTC_Image_Cache_New */
  204. /* */
  205. /* <Description> */
  206. /* THIS FUNCTION IS DEPRECATED. Use @FTC_ImageCache_New instead. */
  207. /* */
  208. /* Creates a new glyph image cache. */
  209. /* */
  210. /* <Input> */
  211. /* manager :: The parent manager for the image cache. */
  212. /* */
  213. /* <Output> */
  214. /* acache :: A handle to the new glyph image cache object. */
  215. /* */
  216. /* <Return> */
  217. /* FreeType error code. 0 means success. */
  218. /* */
  219. FT_EXPORT( FT_Error )
  220. FTC_Image_Cache_New( FTC_Manager manager,
  221. FTC_Image_Cache *acache );
  222. /*************************************************************************/
  223. /* */
  224. /* <Function> */
  225. /* FTC_Image_Cache_Lookup */
  226. /* */
  227. /* <Description> */
  228. /* THIS FUNCTION IS DEPRECATED. Use @FTC_ImageCache_Lookup instead. */
  229. /* */
  230. /* <Input> */
  231. /* cache :: A handle to the source glyph image cache. */
  232. /* */
  233. /* desc :: A pointer to a glyph image descriptor. */
  234. /* */
  235. /* gindex :: The glyph index to retrieve. */
  236. /* */
  237. /* <Output> */
  238. /* aglyph :: The corresponding @FT_Glyph object. 0 in case of */
  239. /* failure. */
  240. /* */
  241. /* <Return> */
  242. /* FreeType error code. 0 means success. */
  243. /* */
  244. /* <Note> */
  245. /* The returned glyph is owned and managed by the glyph image cache. */
  246. /* Never try to transform or discard it manually! You can however */
  247. /* create a copy with @FT_Glyph_Copy and modify the new one. */
  248. /* */
  249. /* Because the glyph image cache limits the total amount of memory */
  250. /* taken by the glyphs it holds, the returned glyph might disappear */
  251. /* on a later invocation of this function! It is a cache after */
  252. /* all... */
  253. /* */
  254. /* Use this function to "lock" the glyph as long as it is needed. */
  255. /* */
  256. FT_EXPORT( FT_Error )
  257. FTC_Image_Cache_Lookup( FTC_Image_Cache cache,
  258. FTC_Image_Desc* desc,
  259. FT_UInt gindex,
  260. FT_Glyph *aglyph );
  261. /* */
  262. FT_END_HEADER
  263. #endif /* __FTCIMAGE_H__ */
  264. /* END */