ftoutln.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /***************************************************************************/
  2. /* */
  3. /* ftoutln.h */
  4. /* */
  5. /* Support for the FT_Outline type used to store glyph shapes of */
  6. /* most scalable font formats (specification). */
  7. /* */
  8. /* Copyright 1996-2001, 2002 by */
  9. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  10. /* */
  11. /* This file is part of the FreeType project, and may only be used, */
  12. /* modified, and distributed under the terms of the FreeType project */
  13. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /***************************************************************************/
  18. #ifndef __FTOUTLN_H__
  19. #define __FTOUTLN_H__
  20. #include <ft2build.h>
  21. #include FT_FREETYPE_H
  22. FT_BEGIN_HEADER
  23. /*************************************************************************/
  24. /* */
  25. /* <Section> */
  26. /* outline_processing */
  27. /* */
  28. /* <Title> */
  29. /* Outline Processing */
  30. /* */
  31. /* <Abstract> */
  32. /* Functions to create, transform, and render vectorial glyph images. */
  33. /* */
  34. /* <Description> */
  35. /* This section contains routines used to create and destroy scalable */
  36. /* glyph images known as `outlines'. These can also be measured, */
  37. /* transformed, and converted into bitmaps and pixmaps. */
  38. /* */
  39. /* <Order> */
  40. /* FT_Outline */
  41. /* FT_Outline_Flags */
  42. /* FT_Outline_New */
  43. /* FT_Outline_Done */
  44. /* FT_Outline_Copy */
  45. /* FT_Outline_Translate */
  46. /* FT_Outline_Transform */
  47. /* FT_Outline_Reverse */
  48. /* FT_Outline_Check */
  49. /* */
  50. /* FT_Outline_Get_CBox */
  51. /* FT_Outline_Get_BBox */
  52. /* */
  53. /* FT_Outline_Get_Bitmap */
  54. /* FT_Outline_Render */
  55. /* */
  56. /* FT_Outline_Decompose */
  57. /* FT_Outline_Funcs */
  58. /* FT_Outline_MoveTo_Func */
  59. /* FT_Outline_LineTo_Func */
  60. /* FT_Outline_ConicTo_Func */
  61. /* FT_Outline_CubicTo_Func */
  62. /* */
  63. /*************************************************************************/
  64. /*************************************************************************/
  65. /* */
  66. /* <Function> */
  67. /* FT_Outline_Decompose */
  68. /* */
  69. /* <Description> */
  70. /* Walks over an outline's structure to decompose it into individual */
  71. /* segments and Bezier arcs. This function is also able to emit */
  72. /* `move to' and `close to' operations to indicate the start and end */
  73. /* of new contours in the outline. */
  74. /* */
  75. /* <Input> */
  76. /* outline :: A pointer to the source target. */
  77. /* */
  78. /* func_interface :: A table of `emitters', i.e,. function pointers */
  79. /* called during decomposition to indicate path */
  80. /* operations. */
  81. /* */
  82. /* <InOut> */
  83. /* user :: A typeless pointer which is passed to each */
  84. /* emitter during the decomposition. It can be */
  85. /* used to store the state during the */
  86. /* decomposition. */
  87. /* */
  88. /* <Return> */
  89. /* FreeType error code. 0 means sucess. */
  90. /* */
  91. FT_EXPORT( FT_Error )
  92. FT_Outline_Decompose( FT_Outline* outline,
  93. const FT_Outline_Funcs* func_interface,
  94. void* user );
  95. /*************************************************************************/
  96. /* */
  97. /* <Function> */
  98. /* FT_Outline_New */
  99. /* */
  100. /* <Description> */
  101. /* Creates a new outline of a given size. */
  102. /* */
  103. /* <Input> */
  104. /* library :: A handle to the library object from where the */
  105. /* outline is allocated. Note however that the new */
  106. /* outline will NOT necessarily be FREED, when */
  107. /* destroying the library, by FT_Done_FreeType(). */
  108. /* */
  109. /* numPoints :: The maximal number of points within the outline. */
  110. /* */
  111. /* numContours :: The maximal number of contours within the outline. */
  112. /* */
  113. /* <Output> */
  114. /* anoutline :: A handle to the new outline. NULL in case of */
  115. /* error. */
  116. /* */
  117. /* <Return> */
  118. /* FreeType error code. 0 means success. */
  119. /* */
  120. /* <Note> */
  121. /* The reason why this function takes a `library' parameter is simply */
  122. /* to use the library's memory allocator. */
  123. /* */
  124. FT_EXPORT( FT_Error )
  125. FT_Outline_New( FT_Library library,
  126. FT_UInt numPoints,
  127. FT_Int numContours,
  128. FT_Outline *anoutline );
  129. FT_EXPORT( FT_Error )
  130. FT_Outline_New_Internal( FT_Memory memory,
  131. FT_UInt numPoints,
  132. FT_Int numContours,
  133. FT_Outline *anoutline );
  134. /*************************************************************************/
  135. /* */
  136. /* <Function> */
  137. /* FT_Outline_Done */
  138. /* */
  139. /* <Description> */
  140. /* Destroys an outline created with FT_Outline_New(). */
  141. /* */
  142. /* <Input> */
  143. /* library :: A handle of the library object used to allocate the */
  144. /* outline. */
  145. /* */
  146. /* outline :: A pointer to the outline object to be discarded. */
  147. /* */
  148. /* <Return> */
  149. /* FreeType error code. 0 means success. */
  150. /* */
  151. /* <Note> */
  152. /* If the outline's `owner' field is not set, only the outline */
  153. /* descriptor will be released. */
  154. /* */
  155. /* The reason why this function takes an `library' parameter is */
  156. /* simply to use FT_Free(). */
  157. /* */
  158. FT_EXPORT( FT_Error )
  159. FT_Outline_Done( FT_Library library,
  160. FT_Outline* outline );
  161. FT_EXPORT( FT_Error )
  162. FT_Outline_Done_Internal( FT_Memory memory,
  163. FT_Outline* outline );
  164. /*************************************************************************/
  165. /* */
  166. /* <Function> */
  167. /* FT_Outline_Check */
  168. /* */
  169. /* <Description> */
  170. /* Check the contents of an outline descriptor. */
  171. /* */
  172. /* <Input> */
  173. /* outline :: A handle to a source outline. */
  174. /* */
  175. /* <Return> */
  176. /* FreeType error code. 0 means success. */
  177. /* */
  178. FT_EXPORT( FT_Error )
  179. FT_Outline_Check( FT_Outline* outline );
  180. /*************************************************************************/
  181. /* */
  182. /* <Function> */
  183. /* FT_Outline_Get_CBox */
  184. /* */
  185. /* <Description> */
  186. /* Returns an outline's `control box'. The control box encloses all */
  187. /* the outline's points, including Bezier control points. Though it */
  188. /* coincides with the exact bounding box for most glyphs, it can be */
  189. /* slightly larger in some situations (like when rotating an outline */
  190. /* which contains Bezier outside arcs). */
  191. /* */
  192. /* Computing the control box is very fast, while getting the bounding */
  193. /* box can take much more time as it needs to walk over all segments */
  194. /* and arcs in the outline. To get the latter, you can use the */
  195. /* `ftbbox' component which is dedicated to this single task. */
  196. /* */
  197. /* <Input> */
  198. /* outline :: A pointer to the source outline descriptor. */
  199. /* */
  200. /* <Output> */
  201. /* acbox :: The outline's control box. */
  202. /* */
  203. FT_EXPORT( void )
  204. FT_Outline_Get_CBox( FT_Outline* outline,
  205. FT_BBox *acbox );
  206. /*************************************************************************/
  207. /* */
  208. /* <Function> */
  209. /* FT_Outline_Translate */
  210. /* */
  211. /* <Description> */
  212. /* Applies a simple translation to the points of an outline. */
  213. /* */
  214. /* <InOut> */
  215. /* outline :: A pointer to the target outline descriptor. */
  216. /* */
  217. /* <Input> */
  218. /* xOffset :: The horizontal offset. */
  219. /* */
  220. /* yOffset :: The vertical offset. */
  221. /* */
  222. FT_EXPORT( void )
  223. FT_Outline_Translate( FT_Outline* outline,
  224. FT_Pos xOffset,
  225. FT_Pos yOffset );
  226. /*************************************************************************/
  227. /* */
  228. /* <Function> */
  229. /* FT_Outline_Copy */
  230. /* */
  231. /* <Description> */
  232. /* Copies an outline into another one. Both objects must have the */
  233. /* same sizes (number of points & number of contours) when this */
  234. /* function is called. */
  235. /* */
  236. /* <Input> */
  237. /* source :: A handle to the source outline. */
  238. /* */
  239. /* <Output> */
  240. /* target :: A handle to the target outline. */
  241. /* */
  242. /* <Return> */
  243. /* FreeType error code. 0 means success. */
  244. /* */
  245. FT_EXPORT( FT_Error )
  246. FT_Outline_Copy( FT_Outline* source,
  247. FT_Outline *target );
  248. /*************************************************************************/
  249. /* */
  250. /* <Function> */
  251. /* FT_Outline_Transform */
  252. /* */
  253. /* <Description> */
  254. /* Applies a simple 2x2 matrix to all of an outline's points. Useful */
  255. /* for applying rotations, slanting, flipping, etc. */
  256. /* */
  257. /* <InOut> */
  258. /* outline :: A pointer to the target outline descriptor. */
  259. /* */
  260. /* <Input> */
  261. /* matrix :: A pointer to the transformation matrix. */
  262. /* */
  263. /* <Note> */
  264. /* You can use FT_Outline_Translate() if you need to translate the */
  265. /* outline's points. */
  266. /* */
  267. FT_EXPORT( void )
  268. FT_Outline_Transform( FT_Outline* outline,
  269. FT_Matrix* matrix );
  270. /*************************************************************************/
  271. /* */
  272. /* <Function> */
  273. /* FT_Outline_Reverse */
  274. /* */
  275. /* <Description> */
  276. /* Reverses the drawing direction of an outline. This is used to */
  277. /* ensure consistent fill conventions for mirrored glyphs. */
  278. /* */
  279. /* <InOut> */
  280. /* outline :: A pointer to the target outline descriptor. */
  281. /* */
  282. /* <Note> */
  283. /* This functions toggles the bit flag `FT_OUTLINE_REVERSE_FILL' in */
  284. /* the outline's `flags' field. */
  285. /* */
  286. /* It shouldn't be used by a normal client application, unless it */
  287. /* knows what it is doing. */
  288. /* */
  289. FT_EXPORT( void )
  290. FT_Outline_Reverse( FT_Outline* outline );
  291. /*************************************************************************/
  292. /* */
  293. /* <Function> */
  294. /* FT_Outline_Get_Bitmap */
  295. /* */
  296. /* <Description> */
  297. /* Renders an outline within a bitmap. The outline's image is simply */
  298. /* OR-ed to the target bitmap. */
  299. /* */
  300. /* <Input> */
  301. /* library :: A handle to a FreeType library object. */
  302. /* */
  303. /* outline :: A pointer to the source outline descriptor. */
  304. /* */
  305. /* <Output> */
  306. /* abitmap :: A pointer to the target bitmap descriptor. */
  307. /* */
  308. /* <Return> */
  309. /* FreeType error code. 0 means success. */
  310. /* */
  311. /* <Note> */
  312. /* This function does NOT CREATE the bitmap, it only renders an */
  313. /* outline image within the one you pass to it! */
  314. /* */
  315. /* It will use the raster correponding to the default glyph format. */
  316. /* */
  317. FT_EXPORT( FT_Error )
  318. FT_Outline_Get_Bitmap( FT_Library library,
  319. FT_Outline* outline,
  320. FT_Bitmap *abitmap );
  321. /*************************************************************************/
  322. /* */
  323. /* <Function> */
  324. /* FT_Outline_Render */
  325. /* */
  326. /* <Description> */
  327. /* Renders an outline within a bitmap using the current scan-convert. */
  328. /* This functions uses an FT_Raster_Params structure as an argument, */
  329. /* allowing advanced features like direct composition, translucency, */
  330. /* etc. */
  331. /* */
  332. /* <Input> */
  333. /* library :: A handle to a FreeType library object. */
  334. /* */
  335. /* outline :: A pointer to the source outline descriptor. */
  336. /* */
  337. /* <InOut> */
  338. /* params :: A pointer to a FT_Raster_Params structure used to */
  339. /* describe the rendering operation. */
  340. /* */
  341. /* <Return> */
  342. /* FreeType error code. 0 means success. */
  343. /* */
  344. /* <Note> */
  345. /* You should know what you are doing and how FT_Raster_Params works */
  346. /* to use this function. */
  347. /* */
  348. /* The field `params.source' will be set to `outline' before the scan */
  349. /* converter is called, which means that the value you give to it is */
  350. /* actually ignored. */
  351. /* */
  352. FT_EXPORT( FT_Error )
  353. FT_Outline_Render( FT_Library library,
  354. FT_Outline* outline,
  355. FT_Raster_Params* params );
  356. /* */
  357. FT_END_HEADER
  358. #endif /* __FTOUTLN_H__ */
  359. /* END */