ftincrem.h 9.2 KB

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