ftincrem.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /***************************************************************************/
  2. /* */
  3. /* ftincrem.h */
  4. /* */
  5. /* FreeType incremental loading (specification). */
  6. /* */
  7. /* Copyright 2002, 2003, 2006, 2007 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 __FTINCREM_H__
  18. #define __FTINCREM_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. #ifdef FREETYPE_H
  22. #error "freetype.h of FreeType 1 has been loaded!"
  23. #error "Please fix the directory search order for header files"
  24. #error "so that freetype.h of FreeType 2 is found first."
  25. #endif
  26. FT_BEGIN_HEADER
  27. /***************************************************************************
  28. *
  29. * @section:
  30. * incremental
  31. *
  32. * @title:
  33. * Incremental Loading
  34. *
  35. * @abstract:
  36. * Custom Glyph Loading.
  37. *
  38. * @description:
  39. * This section contains various functions used to perform so-called
  40. * `incremental' glyph loading. This is a mode where all glyphs loaded
  41. * from a given @FT_Face are provided by the client application,
  42. *
  43. * Apart from that, all other tables are loaded normally from the font
  44. * file. This mode is useful when FreeType is used within another
  45. * engine, e.g., a Postscript Imaging Processor.
  46. *
  47. * To enable this mode, you must use @FT_Open_Face, passing an
  48. * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
  49. * @FT_Incremental_Interface value. See the comments for
  50. * @FT_Incremental_InterfaceRec for an example.
  51. *
  52. */
  53. /***************************************************************************
  54. *
  55. * @type:
  56. * FT_Incremental
  57. *
  58. * @description:
  59. * An opaque type describing a user-provided object used to implement
  60. * `incremental' glyph loading within FreeType. This is used to support
  61. * embedded fonts in certain environments (e.g., Postscript interpreters),
  62. * where the glyph data isn't in the font file, or must be overridden by
  63. * different values.
  64. *
  65. * @note:
  66. * It is up to client applications to create and implement @FT_Incremental
  67. * objects, as long as they provide implementations for the methods
  68. * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
  69. * and @FT_Incremental_GetGlyphMetricsFunc.
  70. *
  71. * See the description of @FT_Incremental_InterfaceRec to understand how
  72. * to use incremental objects with FreeType.
  73. */
  74. typedef struct FT_IncrementalRec_* FT_Incremental;
  75. /***************************************************************************
  76. *
  77. * @struct:
  78. * FT_Incremental_Metrics
  79. *
  80. * @description:
  81. * A small structure used to contain the basic glyph metrics returned
  82. * by the @FT_Incremental_GetGlyphMetricsFunc method.
  83. *
  84. * @fields:
  85. * bearing_x ::
  86. * Left bearing, in font units.
  87. *
  88. * bearing_y ::
  89. * Top bearing, in font units.
  90. *
  91. * advance ::
  92. * Glyph advance, in font units.
  93. *
  94. * @note:
  95. * These correspond to horizontal or vertical metrics depending on the
  96. * value of the `vertical' argument to the function
  97. * @FT_Incremental_GetGlyphMetricsFunc.
  98. */
  99. typedef struct FT_Incremental_MetricsRec_
  100. {
  101. FT_Long bearing_x;
  102. FT_Long bearing_y;
  103. FT_Long advance;
  104. } FT_Incremental_MetricsRec, *FT_Incremental_Metrics;
  105. /***************************************************************************
  106. *
  107. * @type:
  108. * FT_Incremental_GetGlyphDataFunc
  109. *
  110. * @description:
  111. * A function called by FreeType to access a given glyph's data bytes
  112. * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
  113. * enabled.
  114. *
  115. * Note that the format of the glyph's data bytes depends on the font
  116. * file format. For TrueType, it must correspond to the raw bytes within
  117. * the `glyf' table. For Postscript formats, it must correspond to the
  118. * *unencrypted* charstring bytes, without any `lenIV' header. It is
  119. * undefined for any other format.
  120. *
  121. * @input:
  122. * incremental ::
  123. * Handle to an opaque @FT_Incremental handle provided by the client
  124. * application.
  125. *
  126. * glyph_index ::
  127. * Index of relevant glyph.
  128. *
  129. * @output:
  130. * adata ::
  131. * A structure describing the returned glyph data bytes (which will be
  132. * accessed as a read-only byte block).
  133. *
  134. * @return:
  135. * FreeType error code. 0 means success.
  136. *
  137. * @note:
  138. * If this function returns successfully the method
  139. * @FT_Incremental_FreeGlyphDataFunc will be called later to release
  140. * the data bytes.
  141. *
  142. * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
  143. * compound glyphs.
  144. */
  145. typedef FT_Error
  146. (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
  147. FT_UInt glyph_index,
  148. FT_Data* adata );
  149. /***************************************************************************
  150. *
  151. * @type:
  152. * FT_Incremental_FreeGlyphDataFunc
  153. *
  154. * @description:
  155. * A function used to release the glyph data bytes returned by a
  156. * successful call to @FT_Incremental_GetGlyphDataFunc.
  157. *
  158. * @input:
  159. * incremental ::
  160. * A handle to an opaque @FT_Incremental handle provided by the client
  161. * application.
  162. *
  163. * data ::
  164. * A structure describing the glyph data bytes (which will be accessed
  165. * as a read-only byte block).
  166. */
  167. typedef void
  168. (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
  169. FT_Data* data );
  170. /***************************************************************************
  171. *
  172. * @type:
  173. * FT_Incremental_GetGlyphMetricsFunc
  174. *
  175. * @description:
  176. * A function used to retrieve the basic metrics of a given glyph index
  177. * before accessing its data. This is necessary because, in certain
  178. * formats like TrueType, the metrics are stored in a different place from
  179. * the glyph images proper.
  180. *
  181. * @input:
  182. * incremental ::
  183. * A handle to an opaque @FT_Incremental handle provided by the client
  184. * application.
  185. *
  186. * glyph_index ::
  187. * Index of relevant glyph.
  188. *
  189. * vertical ::
  190. * If true, return vertical metrics.
  191. *
  192. * ametrics ::
  193. * This parameter is used for both input and output.
  194. * The original glyph metrics, if any, in font units. If metrics are
  195. * not available all the values must be set to zero.
  196. *
  197. * @output:
  198. * ametrics ::
  199. * The replacement glyph metrics in font units.
  200. *
  201. */
  202. typedef FT_Error
  203. (*FT_Incremental_GetGlyphMetricsFunc)
  204. ( FT_Incremental incremental,
  205. FT_UInt glyph_index,
  206. FT_Bool vertical,
  207. FT_Incremental_MetricsRec *ametrics );
  208. /**************************************************************************
  209. *
  210. * @struct:
  211. * FT_Incremental_FuncsRec
  212. *
  213. * @description:
  214. * A table of functions for accessing fonts that load data
  215. * incrementally. Used in @FT_Incremental_InterfaceRec.
  216. *
  217. * @fields:
  218. * get_glyph_data ::
  219. * The function to get glyph data. Must not be null.
  220. *
  221. * free_glyph_data ::
  222. * The function to release glyph data. Must not be null.
  223. *
  224. * get_glyph_metrics ::
  225. * The function to get glyph metrics. May be null if the font does
  226. * not provide overriding glyph metrics.
  227. */
  228. typedef struct FT_Incremental_FuncsRec_
  229. {
  230. FT_Incremental_GetGlyphDataFunc get_glyph_data;
  231. FT_Incremental_FreeGlyphDataFunc free_glyph_data;
  232. FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
  233. } FT_Incremental_FuncsRec;
  234. /***************************************************************************
  235. *
  236. * @struct:
  237. * FT_Incremental_InterfaceRec
  238. *
  239. * @description:
  240. * A structure to be used with @FT_Open_Face to indicate that the user
  241. * wants to support incremental glyph loading. You should use it with
  242. * @FT_PARAM_TAG_INCREMENTAL as in the following example:
  243. *
  244. * {
  245. * FT_Incremental_InterfaceRec inc_int;
  246. * FT_Parameter parameter;
  247. * FT_Open_Args open_args;
  248. *
  249. *
  250. * // set up incremental descriptor
  251. * inc_int.funcs = my_funcs;
  252. * inc_int.object = my_object;
  253. *
  254. * // set up optional parameter
  255. * parameter.tag = FT_PARAM_TAG_INCREMENTAL;
  256. * parameter.data = &inc_int;
  257. *
  258. * // set up FT_Open_Args structure
  259. * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
  260. * open_args.pathname = my_font_pathname;
  261. * open_args.num_params = 1;
  262. * open_args.params = &parameter; // we use one optional argument
  263. *
  264. * // open the font
  265. * error = FT_Open_Face( library, &open_args, index, &face );
  266. * ...
  267. * }
  268. */
  269. typedef struct FT_Incremental_InterfaceRec_
  270. {
  271. const FT_Incremental_FuncsRec* funcs;
  272. FT_Incremental object;
  273. } FT_Incremental_InterfaceRec;
  274. /***************************************************************************
  275. *
  276. * @type:
  277. * FT_Incremental_Interface
  278. *
  279. * @description:
  280. * A pointer to an @FT_Incremental_InterfaceRec structure.
  281. *
  282. */
  283. typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
  284. /***************************************************************************
  285. *
  286. * @constant:
  287. * FT_PARAM_TAG_INCREMENTAL
  288. *
  289. * @description:
  290. * A constant used as the tag of @FT_Parameter structures to indicate
  291. * an incremental loading object to be used by FreeType.
  292. *
  293. */
  294. #define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
  295. /* */
  296. FT_END_HEADER
  297. #endif /* __FTINCREM_H__ */
  298. /* END */