1
0

ftcsbits.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /***************************************************************************/
  2. /* */
  3. /* ftcsbits.h */
  4. /* */
  5. /* A small-bitmap 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. #ifndef __FTCSBITS_H__
  18. #define __FTCSBITS_H__
  19. #include <ft2build.h>
  20. #include FT_CACHE_H
  21. #include FT_CACHE_IMAGE_H
  22. FT_BEGIN_HEADER
  23. /*************************************************************************/
  24. /* */
  25. /* <Section> */
  26. /* cache_subsystem */
  27. /* */
  28. /*************************************************************************/
  29. /*************************************************************************/
  30. /* */
  31. /* <Type> */
  32. /* FTC_SBit */
  33. /* */
  34. /* <Description> */
  35. /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */
  36. /* structure for details. */
  37. /* */
  38. typedef struct FTC_SBitRec_* FTC_SBit;
  39. /*************************************************************************/
  40. /* */
  41. /* <Struct> */
  42. /* FTC_SBitRec */
  43. /* */
  44. /* <Description> */
  45. /* A very compact structure used to describe a small glyph bitmap. */
  46. /* */
  47. /* <Fields> */
  48. /* width :: The bitmap width in pixels. */
  49. /* */
  50. /* height :: The bitmap height in pixels. */
  51. /* */
  52. /* left :: The horizontal distance from the pen position to the */
  53. /* left bitmap border (a.k.a. `left side bearing', or */
  54. /* `lsb'). */
  55. /* */
  56. /* top :: The vertical distance from the pen position (on the */
  57. /* baseline) to the upper bitmap border (a.k.a. `top */
  58. /* side bearing'). The distance is positive for upwards */
  59. /* Y coordinates. */
  60. /* */
  61. /* format :: The format of the glyph bitmap (monochrome or gray). */
  62. /* */
  63. /* max_grays :: Maximum gray level value (in the range 1 to 255). */
  64. /* */
  65. /* pitch :: The number of bytes per bitmap line. May be positive */
  66. /* or negative. */
  67. /* */
  68. /* xadvance :: The horizontal advance width in pixels. */
  69. /* */
  70. /* yadvance :: The vertical advance height in pixels. */
  71. /* */
  72. /* buffer :: A pointer to the bitmap pixels. */
  73. /* */
  74. typedef struct FTC_SBitRec_
  75. {
  76. FT_Byte width;
  77. FT_Byte height;
  78. FT_Char left;
  79. FT_Char top;
  80. FT_Byte format;
  81. FT_Byte max_grays;
  82. FT_Short pitch;
  83. FT_Char xadvance;
  84. FT_Char yadvance;
  85. FT_Byte* buffer;
  86. } FTC_SBitRec;
  87. /*************************************************************************/
  88. /* */
  89. /* <Type> */
  90. /* FTC_SBitCache */
  91. /* */
  92. /* <Description> */
  93. /* A handle to a small bitmap cache. These are special cache objects */
  94. /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */
  95. /* much more efficient way than the traditional glyph image cache */
  96. /* implemented by @FTC_ImageCache. */
  97. /* */
  98. typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
  99. /*************************************************************************/
  100. /* */
  101. /* <Type> */
  102. /* FTC_SBit_Cache */
  103. /* */
  104. /* <Description> */
  105. /* DEPRECATED. Use @FTC_SBitCache instead. */
  106. /* */
  107. typedef FTC_SBitCache FTC_SBit_Cache;
  108. /*************************************************************************/
  109. /* */
  110. /* <Function> */
  111. /* FTC_SBitCache_New */
  112. /* */
  113. /* <Description> */
  114. /* Creates a new cache to store small glyph bitmaps. */
  115. /* */
  116. /* <Input> */
  117. /* manager :: A handle to the source cache manager. */
  118. /* */
  119. /* <Output> */
  120. /* acache :: A handle to the new sbit cache. NULL in case of error. */
  121. /* */
  122. /* <Return> */
  123. /* FreeType error code. 0 means success. */
  124. /* */
  125. FT_EXPORT( FT_Error )
  126. FTC_SBitCache_New( FTC_Manager manager,
  127. FTC_SBitCache *acache );
  128. /*************************************************************************/
  129. /* */
  130. /* <Function> */
  131. /* FTC_SBitCache_Lookup */
  132. /* */
  133. /* <Description> */
  134. /* Looks up a given small glyph bitmap in a given sbit cache and */
  135. /* "lock" it to prevent its flushing from the cache until needed */
  136. /* */
  137. /* <Input> */
  138. /* cache :: A handle to the source sbit cache. */
  139. /* */
  140. /* type :: A pointer to the glyph image type descriptor. */
  141. /* */
  142. /* gindex :: The glyph index. */
  143. /* */
  144. /* <Output> */
  145. /* sbit :: A handle to a small bitmap descriptor. */
  146. /* */
  147. /* anode :: Used to return the address of of the corresponding cache */
  148. /* node after incrementing its reference count (see note */
  149. /* below). */
  150. /* */
  151. /* <Return> */
  152. /* FreeType error code. 0 means success. */
  153. /* */
  154. /* <Note> */
  155. /* The small bitmap descriptor and its bit buffer are owned by the */
  156. /* cache and should never be freed by the application. They might */
  157. /* as well disappear from memory on the next cache lookup, so don't */
  158. /* treat them as persistent data. */
  159. /* */
  160. /* The descriptor's `buffer' field is set to 0 to indicate a missing */
  161. /* glyph bitmap. */
  162. /* */
  163. /* If "anode" is _not_ NULL, it receives the address of the cache */
  164. /* node containing the bitmap, after increasing its reference count. */
  165. /* This ensures that the node (as well as the image) will always be */
  166. /* kept in the cache until you call @FTC_Node_Unref to "release" it. */
  167. /* */
  168. /* If "anode" is NULL, the cache node is left unchanged, which means */
  169. /* that the bitmap could be flushed out of the cache on the next */
  170. /* call to one of the caching sub-system APIs. Don't assume that it */
  171. /* is persistent! */
  172. /* */
  173. FT_EXPORT( FT_Error )
  174. FTC_SBitCache_Lookup( FTC_SBitCache cache,
  175. FTC_ImageType type,
  176. FT_UInt gindex,
  177. FTC_SBit *sbit,
  178. FTC_Node *anode );
  179. /* */
  180. /*************************************************************************/
  181. /* */
  182. /* <Function> */
  183. /* FTC_SBit_Cache_New */
  184. /* */
  185. /* <Description> */
  186. /* DEPRECATED. Use @FTC_SBitCache_New instead. */
  187. /* */
  188. /* Creates a new cache to store small glyph bitmaps. */
  189. /* */
  190. /* <Input> */
  191. /* manager :: A handle to the source cache manager. */
  192. /* */
  193. /* <Output> */
  194. /* acache :: A handle to the new sbit cache. NULL in case of error. */
  195. /* */
  196. /* <Return> */
  197. /* FreeType error code. 0 means success. */
  198. /* */
  199. FT_EXPORT( FT_Error )
  200. FTC_SBit_Cache_New( FTC_Manager manager,
  201. FTC_SBit_Cache *acache );
  202. /*************************************************************************/
  203. /* */
  204. /* <Function> */
  205. /* FTC_SBit_Cache_Lookup */
  206. /* */
  207. /* <Description> */
  208. /* DEPRECATED. Use @FTC_SBitCache_Lookup instead. */
  209. /* */
  210. /* Looks up a given small glyph bitmap in a given sbit cache. */
  211. /* */
  212. /* <Input> */
  213. /* cache :: A handle to the source sbit cache. */
  214. /* */
  215. /* desc :: A pointer to the glyph image descriptor. */
  216. /* */
  217. /* gindex :: The glyph index. */
  218. /* */
  219. /* <Output> */
  220. /* sbit :: A handle to a small bitmap descriptor. */
  221. /* */
  222. /* <Return> */
  223. /* FreeType error code. 0 means success. */
  224. /* */
  225. /* <Note> */
  226. /* The small bitmap descriptor and its bit buffer are owned by the */
  227. /* cache and should never be freed by the application. They might */
  228. /* as well disappear from memory on the next cache lookup, so don't */
  229. /* treat them as persistent data. */
  230. /* */
  231. /* The descriptor's `buffer' field is set to 0 to indicate a missing */
  232. /* glyph bitmap. */
  233. /* */
  234. FT_EXPORT( FT_Error )
  235. FTC_SBit_Cache_Lookup( FTC_SBit_Cache cache,
  236. FTC_Image_Desc* desc,
  237. FT_UInt gindex,
  238. FTC_SBit *sbit );
  239. FT_END_HEADER
  240. #endif /* __FTCSBITS_H__ */
  241. /* END */