ftincrem.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /***************************************************************************/
  2. /* */
  3. /* ftincrem.h */
  4. /* */
  5. /* FreeType incremental loading (specification). */
  6. /* */
  7. /* Copyright 2002, 2003, 2006, 2007, 2008, 2010 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. */
  75. typedef struct FT_IncrementalRec_* FT_Incremental;
  76. /***************************************************************************
  77. *
  78. * @struct:
  79. * FT_Incremental_MetricsRec
  80. *
  81. * @description:
  82. * A small structure used to contain the basic glyph metrics returned
  83. * by the @FT_Incremental_GetGlyphMetricsFunc method.
  84. *
  85. * @fields:
  86. * bearing_x ::
  87. * Left bearing, in font units.
  88. *
  89. * bearing_y ::
  90. * Top bearing, in font units.
  91. *
  92. * advance ::
  93. * Horizontal component of glyph advance, in font units.
  94. *
  95. * advance_v ::
  96. * Vertical component of glyph advance, in font units.
  97. *
  98. * @note:
  99. * These correspond to horizontal or vertical metrics depending on the
  100. * value of the `vertical' argument to the function
  101. * @FT_Incremental_GetGlyphMetricsFunc.
  102. *
  103. */
  104. typedef struct FT_Incremental_MetricsRec_
  105. {
  106. FT_Long bearing_x;
  107. FT_Long bearing_y;
  108. FT_Long advance;
  109. FT_Long advance_v; /* since 2.3.12 */
  110. } FT_Incremental_MetricsRec;
  111. /***************************************************************************
  112. *
  113. * @struct:
  114. * FT_Incremental_Metrics
  115. *
  116. * @description:
  117. * A handle to an @FT_Incremental_MetricsRec structure.
  118. *
  119. */
  120. typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics;
  121. /***************************************************************************
  122. *
  123. * @type:
  124. * FT_Incremental_GetGlyphDataFunc
  125. *
  126. * @description:
  127. * A function called by FreeType to access a given glyph's data bytes
  128. * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
  129. * enabled.
  130. *
  131. * Note that the format of the glyph's data bytes depends on the font
  132. * file format. For TrueType, it must correspond to the raw bytes within
  133. * the `glyf' table. For PostScript formats, it must correspond to the
  134. * *unencrypted* charstring bytes, without any `lenIV' header. It is
  135. * undefined for any other format.
  136. *
  137. * @input:
  138. * incremental ::
  139. * Handle to an opaque @FT_Incremental handle provided by the client
  140. * application.
  141. *
  142. * glyph_index ::
  143. * Index of relevant glyph.
  144. *
  145. * @output:
  146. * adata ::
  147. * A structure describing the returned glyph data bytes (which will be
  148. * accessed as a read-only byte block).
  149. *
  150. * @return:
  151. * FreeType error code. 0~means success.
  152. *
  153. * @note:
  154. * If this function returns successfully the method
  155. * @FT_Incremental_FreeGlyphDataFunc will be called later to release
  156. * the data bytes.
  157. *
  158. * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
  159. * compound glyphs.
  160. *
  161. */
  162. typedef FT_Error
  163. (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
  164. FT_UInt glyph_index,
  165. FT_Data* adata );
  166. /***************************************************************************
  167. *
  168. * @type:
  169. * FT_Incremental_FreeGlyphDataFunc
  170. *
  171. * @description:
  172. * A function used to release the glyph data bytes returned by a
  173. * successful call to @FT_Incremental_GetGlyphDataFunc.
  174. *
  175. * @input:
  176. * incremental ::
  177. * A handle to an opaque @FT_Incremental handle provided by the client
  178. * application.
  179. *
  180. * data ::
  181. * A structure describing the glyph data bytes (which will be accessed
  182. * as a read-only byte block).
  183. *
  184. */
  185. typedef void
  186. (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
  187. FT_Data* data );
  188. /***************************************************************************
  189. *
  190. * @type:
  191. * FT_Incremental_GetGlyphMetricsFunc
  192. *
  193. * @description:
  194. * A function used to retrieve the basic metrics of a given glyph index
  195. * before accessing its data. This is necessary because, in certain
  196. * formats like TrueType, the metrics are stored in a different place from
  197. * the glyph images proper.
  198. *
  199. * @input:
  200. * incremental ::
  201. * A handle to an opaque @FT_Incremental handle provided by the client
  202. * application.
  203. *
  204. * glyph_index ::
  205. * Index of relevant glyph.
  206. *
  207. * vertical ::
  208. * If true, return vertical metrics.
  209. *
  210. * ametrics ::
  211. * This parameter is used for both input and output.
  212. * The original glyph metrics, if any, in font units. If metrics are
  213. * not available all the values must be set to zero.
  214. *
  215. * @output:
  216. * ametrics ::
  217. * The replacement glyph metrics in font units.
  218. *
  219. */
  220. typedef FT_Error
  221. (*FT_Incremental_GetGlyphMetricsFunc)
  222. ( FT_Incremental incremental,
  223. FT_UInt glyph_index,
  224. FT_Bool vertical,
  225. FT_Incremental_MetricsRec *ametrics );
  226. /**************************************************************************
  227. *
  228. * @struct:
  229. * FT_Incremental_FuncsRec
  230. *
  231. * @description:
  232. * A table of functions for accessing fonts that load data
  233. * incrementally. Used in @FT_Incremental_InterfaceRec.
  234. *
  235. * @fields:
  236. * get_glyph_data ::
  237. * The function to get glyph data. Must not be null.
  238. *
  239. * free_glyph_data ::
  240. * The function to release glyph data. Must not be null.
  241. *
  242. * get_glyph_metrics ::
  243. * The function to get glyph metrics. May be null if the font does
  244. * not provide overriding glyph metrics.
  245. *
  246. */
  247. typedef struct FT_Incremental_FuncsRec_
  248. {
  249. FT_Incremental_GetGlyphDataFunc get_glyph_data;
  250. FT_Incremental_FreeGlyphDataFunc free_glyph_data;
  251. FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
  252. } FT_Incremental_FuncsRec;
  253. /***************************************************************************
  254. *
  255. * @struct:
  256. * FT_Incremental_InterfaceRec
  257. *
  258. * @description:
  259. * A structure to be used with @FT_Open_Face to indicate that the user
  260. * wants to support incremental glyph loading. You should use it with
  261. * @FT_PARAM_TAG_INCREMENTAL as in the following example:
  262. *
  263. * {
  264. * FT_Incremental_InterfaceRec inc_int;
  265. * FT_Parameter parameter;
  266. * FT_Open_Args open_args;
  267. *
  268. *
  269. * // set up incremental descriptor
  270. * inc_int.funcs = my_funcs;
  271. * inc_int.object = my_object;
  272. *
  273. * // set up optional parameter
  274. * parameter.tag = FT_PARAM_TAG_INCREMENTAL;
  275. * parameter.data = &inc_int;
  276. *
  277. * // set up FT_Open_Args structure
  278. * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
  279. * open_args.pathname = my_font_pathname;
  280. * open_args.num_params = 1;
  281. * open_args.params = &parameter; // we use one optional argument
  282. *
  283. * // open the font
  284. * error = FT_Open_Face( library, &open_args, index, &face );
  285. * ...
  286. * }
  287. *
  288. */
  289. typedef struct FT_Incremental_InterfaceRec_
  290. {
  291. const FT_Incremental_FuncsRec* funcs;
  292. FT_Incremental object;
  293. } FT_Incremental_InterfaceRec;
  294. /***************************************************************************
  295. *
  296. * @type:
  297. * FT_Incremental_Interface
  298. *
  299. * @description:
  300. * A pointer to an @FT_Incremental_InterfaceRec structure.
  301. *
  302. */
  303. typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
  304. /***************************************************************************
  305. *
  306. * @constant:
  307. * FT_PARAM_TAG_INCREMENTAL
  308. *
  309. * @description:
  310. * A constant used as the tag of @FT_Parameter structures to indicate
  311. * an incremental loading object to be used by FreeType.
  312. *
  313. */
  314. #define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
  315. /* */
  316. FT_END_HEADER
  317. #endif /* __FTINCREM_H__ */
  318. /* END */