PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/compiler/android-ndk/jni/freetype/include/freetype/ftimage.h

http://ftk.googlecode.com/
C++ Header | 1042 lines | 170 code | 102 blank | 770 comment | 0 complexity | ed6e8727abd9693d4a78f42b9b7e6c20 MD5 | raw file
Possible License(s): LGPL-3.0
  1. /***************************************************************************/
  2. /* */
  3. /* ftimage.h */
  4. /* */
  5. /* FreeType glyph image formats and default raster interface */
  6. /* (specification). */
  7. /* */
  8. /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
  9. /* 2010 by */
  10. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  11. /* */
  12. /* This file is part of the FreeType project, and may only be used, */
  13. /* modified, and distributed under the terms of the FreeType project */
  14. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  15. /* this file you indicate that you have read the license and */
  16. /* understand and accept it fully. */
  17. /* */
  18. /***************************************************************************/
  19. /*************************************************************************/
  20. /* */
  21. /* Note: A `raster' is simply a scan-line converter, used to render */
  22. /* FT_Outlines into FT_Bitmaps. */
  23. /* */
  24. /*************************************************************************/
  25. #ifndef __FTIMAGE_H__
  26. #define __FTIMAGE_H__
  27. /* _STANDALONE_ is from ftgrays.c */
  28. #ifndef _STANDALONE_
  29. #include <ft2build.h>
  30. #endif
  31. FT_BEGIN_HEADER
  32. /*************************************************************************/
  33. /* */
  34. /* <Section> */
  35. /* basic_types */
  36. /* */
  37. /*************************************************************************/
  38. /*************************************************************************/
  39. /* */
  40. /* <Type> */
  41. /* FT_Pos */
  42. /* */
  43. /* <Description> */
  44. /* The type FT_Pos is used to store vectorial coordinates. Depending */
  45. /* on the context, these can represent distances in integer font */
  46. /* units, or 16.16, or 26.6 fixed float pixel coordinates. */
  47. /* */
  48. typedef signed long FT_Pos;
  49. /*************************************************************************/
  50. /* */
  51. /* <Struct> */
  52. /* FT_Vector */
  53. /* */
  54. /* <Description> */
  55. /* A simple structure used to store a 2D vector; coordinates are of */
  56. /* the FT_Pos type. */
  57. /* */
  58. /* <Fields> */
  59. /* x :: The horizontal coordinate. */
  60. /* y :: The vertical coordinate. */
  61. /* */
  62. typedef struct FT_Vector_
  63. {
  64. FT_Pos x;
  65. FT_Pos y;
  66. } FT_Vector;
  67. /*************************************************************************/
  68. /* */
  69. /* <Struct> */
  70. /* FT_BBox */
  71. /* */
  72. /* <Description> */
  73. /* A structure used to hold an outline's bounding box, i.e., the */
  74. /* coordinates of its extrema in the horizontal and vertical */
  75. /* directions. */
  76. /* */
  77. /* <Fields> */
  78. /* xMin :: The horizontal minimum (left-most). */
  79. /* */
  80. /* yMin :: The vertical minimum (bottom-most). */
  81. /* */
  82. /* xMax :: The horizontal maximum (right-most). */
  83. /* */
  84. /* yMax :: The vertical maximum (top-most). */
  85. /* */
  86. /* <Note> */
  87. /* The bounding box is specified with the coordinates of the lower */
  88. /* left and the upper right corner. In PostScript, those values are */
  89. /* often called (llx,lly) and (urx,ury), respectively. */
  90. /* */
  91. /* If `yMin' is negative, this value gives the glyph's descender. */
  92. /* Otherwise, the glyph doesn't descend below the baseline. */
  93. /* Similarly, if `ymax' is positive, this value gives the glyph's */
  94. /* ascender. */
  95. /* */
  96. /* `xMin' gives the horizontal distance from the glyph's origin to */
  97. /* the left edge of the glyph's bounding box. If `xMin' is negative, */
  98. /* the glyph extends to the left of the origin. */
  99. /* */
  100. typedef struct FT_BBox_
  101. {
  102. FT_Pos xMin, yMin;
  103. FT_Pos xMax, yMax;
  104. } FT_BBox;
  105. /*************************************************************************/
  106. /* */
  107. /* <Enum> */
  108. /* FT_Pixel_Mode */
  109. /* */
  110. /* <Description> */
  111. /* An enumeration type used to describe the format of pixels in a */
  112. /* given bitmap. Note that additional formats may be added in the */
  113. /* future. */
  114. /* */
  115. /* <Values> */
  116. /* FT_PIXEL_MODE_NONE :: */
  117. /* Value~0 is reserved. */
  118. /* */
  119. /* FT_PIXEL_MODE_MONO :: */
  120. /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */
  121. /* are stored in most-significant order (MSB), which means that */
  122. /* the left-most pixel in a byte has value 128. */
  123. /* */
  124. /* FT_PIXEL_MODE_GRAY :: */
  125. /* An 8-bit bitmap, generally used to represent anti-aliased glyph */
  126. /* images. Each pixel is stored in one byte. Note that the number */
  127. /* of `gray' levels is stored in the `num_grays' field of the */
  128. /* @FT_Bitmap structure (it generally is 256). */
  129. /* */
  130. /* FT_PIXEL_MODE_GRAY2 :: */
  131. /* A 2-bit per pixel bitmap, used to represent embedded */
  132. /* anti-aliased bitmaps in font files according to the OpenType */
  133. /* specification. We haven't found a single font using this */
  134. /* format, however. */
  135. /* */
  136. /* FT_PIXEL_MODE_GRAY4 :: */
  137. /* A 4-bit per pixel bitmap, representing embedded anti-aliased */
  138. /* bitmaps in font files according to the OpenType specification. */
  139. /* We haven't found a single font using this format, however. */
  140. /* */
  141. /* FT_PIXEL_MODE_LCD :: */
  142. /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
  143. /* used for display on LCD displays; the bitmap is three times */
  144. /* wider than the original glyph image. See also */
  145. /* @FT_RENDER_MODE_LCD. */
  146. /* */
  147. /* FT_PIXEL_MODE_LCD_V :: */
  148. /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
  149. /* used for display on rotated LCD displays; the bitmap is three */
  150. /* times taller than the original glyph image. See also */
  151. /* @FT_RENDER_MODE_LCD_V. */
  152. /* */
  153. typedef enum FT_Pixel_Mode_
  154. {
  155. FT_PIXEL_MODE_NONE = 0,
  156. FT_PIXEL_MODE_MONO,
  157. FT_PIXEL_MODE_GRAY,
  158. FT_PIXEL_MODE_GRAY2,
  159. FT_PIXEL_MODE_GRAY4,
  160. FT_PIXEL_MODE_LCD,
  161. FT_PIXEL_MODE_LCD_V,
  162. FT_PIXEL_MODE_MAX /* do not remove */
  163. } FT_Pixel_Mode;
  164. /*************************************************************************/
  165. /* */
  166. /* <Enum> */
  167. /* ft_pixel_mode_xxx */
  168. /* */
  169. /* <Description> */
  170. /* A list of deprecated constants. Use the corresponding */
  171. /* @FT_Pixel_Mode values instead. */
  172. /* */
  173. /* <Values> */
  174. /* ft_pixel_mode_none :: See @FT_PIXEL_MODE_NONE. */
  175. /* ft_pixel_mode_mono :: See @FT_PIXEL_MODE_MONO. */
  176. /* ft_pixel_mode_grays :: See @FT_PIXEL_MODE_GRAY. */
  177. /* ft_pixel_mode_pal2 :: See @FT_PIXEL_MODE_GRAY2. */
  178. /* ft_pixel_mode_pal4 :: See @FT_PIXEL_MODE_GRAY4. */
  179. /* */
  180. #define ft_pixel_mode_none FT_PIXEL_MODE_NONE
  181. #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
  182. #define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
  183. #define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
  184. #define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
  185. /* */
  186. #if 0
  187. /*************************************************************************/
  188. /* */
  189. /* <Enum> */
  190. /* FT_Palette_Mode */
  191. /* */
  192. /* <Description> */
  193. /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
  194. /* */
  195. /* An enumeration type to describe the format of a bitmap palette, */
  196. /* used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */
  197. /* */
  198. /* <Values> */
  199. /* ft_palette_mode_rgb :: The palette is an array of 3-byte RGB */
  200. /* records. */
  201. /* */
  202. /* ft_palette_mode_rgba :: The palette is an array of 4-byte RGBA */
  203. /* records. */
  204. /* */
  205. /* <Note> */
  206. /* As ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */
  207. /* FreeType, these types are not handled by the library itself. */
  208. /* */
  209. typedef enum FT_Palette_Mode_
  210. {
  211. ft_palette_mode_rgb = 0,
  212. ft_palette_mode_rgba,
  213. ft_palette_mode_max /* do not remove */
  214. } FT_Palette_Mode;
  215. /* */
  216. #endif
  217. /*************************************************************************/
  218. /* */
  219. /* <Struct> */
  220. /* FT_Bitmap */
  221. /* */
  222. /* <Description> */
  223. /* A structure used to describe a bitmap or pixmap to the raster. */
  224. /* Note that we now manage pixmaps of various depths through the */
  225. /* `pixel_mode' field. */
  226. /* */
  227. /* <Fields> */
  228. /* rows :: The number of bitmap rows. */
  229. /* */
  230. /* width :: The number of pixels in bitmap row. */
  231. /* */
  232. /* pitch :: The pitch's absolute value is the number of bytes */
  233. /* taken by one bitmap row, including padding. */
  234. /* However, the pitch is positive when the bitmap has */
  235. /* a `down' flow, and negative when it has an `up' */
  236. /* flow. In all cases, the pitch is an offset to add */
  237. /* to a bitmap pointer in order to go down one row. */
  238. /* */
  239. /* For the B/W rasterizer, `pitch' is always an even */
  240. /* number. */
  241. /* */
  242. /* buffer :: A typeless pointer to the bitmap buffer. This */
  243. /* value should be aligned on 32-bit boundaries in */
  244. /* most cases. */
  245. /* */
  246. /* num_grays :: This field is only used with */
  247. /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */
  248. /* levels used in the bitmap. */
  249. /* */
  250. /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
  251. /* See @FT_Pixel_Mode for possible values. */
  252. /* */
  253. /* palette_mode :: This field is intended for paletted pixel modes; */
  254. /* it indicates how the palette is stored. Not */
  255. /* used currently. */
  256. /* */
  257. /* palette :: A typeless pointer to the bitmap palette; this */
  258. /* field is intended for paletted pixel modes. Not */
  259. /* used currently. */
  260. /* */
  261. /* <Note> */
  262. /* For now, the only pixel modes supported by FreeType are mono and */
  263. /* grays. However, drivers might be added in the future to support */
  264. /* more `colorful' options. */
  265. /* */
  266. typedef struct FT_Bitmap_
  267. {
  268. int rows;
  269. int width;
  270. int pitch;
  271. unsigned char* buffer;
  272. short num_grays;
  273. char pixel_mode;
  274. char palette_mode;
  275. void* palette;
  276. } FT_Bitmap;
  277. /*************************************************************************/
  278. /* */
  279. /* <Section> */
  280. /* outline_processing */
  281. /* */
  282. /*************************************************************************/
  283. /*************************************************************************/
  284. /* */
  285. /* <Struct> */
  286. /* FT_Outline */
  287. /* */
  288. /* <Description> */
  289. /* This structure is used to describe an outline to the scan-line */
  290. /* converter. */
  291. /* */
  292. /* <Fields> */
  293. /* n_contours :: The number of contours in the outline. */
  294. /* */
  295. /* n_points :: The number of points in the outline. */
  296. /* */
  297. /* points :: A pointer to an array of `n_points' @FT_Vector */
  298. /* elements, giving the outline's point coordinates. */
  299. /* */
  300. /* tags :: A pointer to an array of `n_points' chars, giving */
  301. /* each outline point's type. */
  302. /* */
  303. /* If bit~0 is unset, the point is `off' the curve, */
  304. /* i.e., a Bézier control point, while it is `on' if */
  305. /* set. */
  306. /* */
  307. /* Bit~1 is meaningful for `off' points only. If set, */
  308. /* it indicates a third-order Bézier arc control point; */
  309. /* and a second-order control point if unset. */
  310. /* */
  311. /* If bit~2 is set, bits 5-7 contain the drop-out mode */
  312. /* (as defined in the OpenType specification; the value */
  313. /* is the same as the argument to the SCANMODE */
  314. /* instruction). */
  315. /* */
  316. /* Bits 3 and~4 are reserved for internal purposes. */
  317. /* */
  318. /* contours :: An array of `n_contours' shorts, giving the end */
  319. /* point of each contour within the outline. For */
  320. /* example, the first contour is defined by the points */
  321. /* `0' to `contours[0]', the second one is defined by */
  322. /* the points `contours[0]+1' to `contours[1]', etc. */
  323. /* */
  324. /* flags :: A set of bit flags used to characterize the outline */
  325. /* and give hints to the scan-converter and hinter on */
  326. /* how to convert/grid-fit it. See @FT_OUTLINE_FLAGS. */
  327. /* */
  328. /* <Note> */
  329. /* The B/W rasterizer only checks bit~2 in the `tags' array for the */
  330. /* first point of each contour. The drop-out mode as given with */
  331. /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */
  332. /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */
  333. /* */
  334. typedef struct FT_Outline_
  335. {
  336. short n_contours; /* number of contours in glyph */
  337. short n_points; /* number of points in the glyph */
  338. FT_Vector* points; /* the outline's points */
  339. char* tags; /* the points flags */
  340. short* contours; /* the contour end points */
  341. int flags; /* outline masks */
  342. } FT_Outline;
  343. /* Following limits must be consistent with */
  344. /* FT_Outline.{n_contours,n_points} */
  345. #define FT_OUTLINE_CONTOURS_MAX SHRT_MAX
  346. #define FT_OUTLINE_POINTS_MAX SHRT_MAX
  347. /*************************************************************************/
  348. /* */
  349. /* <Enum> */
  350. /* FT_OUTLINE_FLAGS */
  351. /* */
  352. /* <Description> */
  353. /* A list of bit-field constants use for the flags in an outline's */
  354. /* `flags' field. */
  355. /* */
  356. /* <Values> */
  357. /* FT_OUTLINE_NONE :: */
  358. /* Value~0 is reserved. */
  359. /* */
  360. /* FT_OUTLINE_OWNER :: */
  361. /* If set, this flag indicates that the outline's field arrays */
  362. /* (i.e., `points', `flags', and `contours') are `owned' by the */
  363. /* outline object, and should thus be freed when it is destroyed. */
  364. /* */
  365. /* FT_OUTLINE_EVEN_ODD_FILL :: */
  366. /* By default, outlines are filled using the non-zero winding rule. */
  367. /* If set to 1, the outline will be filled using the even-odd fill */
  368. /* rule (only works with the smooth rasterizer). */
  369. /* */
  370. /* FT_OUTLINE_REVERSE_FILL :: */
  371. /* By default, outside contours of an outline are oriented in */
  372. /* clock-wise direction, as defined in the TrueType specification. */
  373. /* This flag is set if the outline uses the opposite direction */
  374. /* (typically for Type~1 fonts). This flag is ignored by the scan */
  375. /* converter. */
  376. /* */
  377. /* FT_OUTLINE_IGNORE_DROPOUTS :: */
  378. /* By default, the scan converter will try to detect drop-outs in */
  379. /* an outline and correct the glyph bitmap to ensure consistent */
  380. /* shape continuity. If set, this flag hints the scan-line */
  381. /* converter to ignore such cases. See below for more information. */
  382. /* */
  383. /* FT_OUTLINE_SMART_DROPOUTS :: */
  384. /* Select smart dropout control. If unset, use simple dropout */
  385. /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */
  386. /* below for more information. */
  387. /* */
  388. /* FT_OUTLINE_INCLUDE_STUBS :: */
  389. /* If set, turn pixels on for `stubs', otherwise exclude them. */
  390. /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */
  391. /* more information. */
  392. /* */
  393. /* FT_OUTLINE_HIGH_PRECISION :: */
  394. /* This flag indicates that the scan-line converter should try to */
  395. /* convert this outline to bitmaps with the highest possible */
  396. /* quality. It is typically set for small character sizes. Note */
  397. /* that this is only a hint that might be completely ignored by a */
  398. /* given scan-converter. */
  399. /* */
  400. /* FT_OUTLINE_SINGLE_PASS :: */
  401. /* This flag is set to force a given scan-converter to only use a */
  402. /* single pass over the outline to render a bitmap glyph image. */
  403. /* Normally, it is set for very large character sizes. It is only */
  404. /* a hint that might be completely ignored by a given */
  405. /* scan-converter. */
  406. /* */
  407. /* <Note> */
  408. /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */
  409. /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */
  410. /* rasterizer. */
  411. /* */
  412. /* There exists a second mechanism to pass the drop-out mode to the */
  413. /* B/W rasterizer; see the `tags' field in @FT_Outline. */
  414. /* */
  415. /* Please refer to the description of the `SCANTYPE' instruction in */
  416. /* the OpenType specification (in file `ttinst1.doc') how simple */
  417. /* drop-outs, smart drop-outs, and stubs are defined. */
  418. /* */
  419. #define FT_OUTLINE_NONE 0x0
  420. #define FT_OUTLINE_OWNER 0x1
  421. #define FT_OUTLINE_EVEN_ODD_FILL 0x2
  422. #define FT_OUTLINE_REVERSE_FILL 0x4
  423. #define FT_OUTLINE_IGNORE_DROPOUTS 0x8
  424. #define FT_OUTLINE_SMART_DROPOUTS 0x10
  425. #define FT_OUTLINE_INCLUDE_STUBS 0x20
  426. #define FT_OUTLINE_HIGH_PRECISION 0x100
  427. #define FT_OUTLINE_SINGLE_PASS 0x200
  428. /*************************************************************************
  429. *
  430. * @enum:
  431. * ft_outline_flags
  432. *
  433. * @description:
  434. * These constants are deprecated. Please use the corresponding
  435. * @FT_OUTLINE_FLAGS values.
  436. *
  437. * @values:
  438. * ft_outline_none :: See @FT_OUTLINE_NONE.
  439. * ft_outline_owner :: See @FT_OUTLINE_OWNER.
  440. * ft_outline_even_odd_fill :: See @FT_OUTLINE_EVEN_ODD_FILL.
  441. * ft_outline_reverse_fill :: See @FT_OUTLINE_REVERSE_FILL.
  442. * ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS.
  443. * ft_outline_high_precision :: See @FT_OUTLINE_HIGH_PRECISION.
  444. * ft_outline_single_pass :: See @FT_OUTLINE_SINGLE_PASS.
  445. */
  446. #define ft_outline_none FT_OUTLINE_NONE
  447. #define ft_outline_owner FT_OUTLINE_OWNER
  448. #define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
  449. #define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
  450. #define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
  451. #define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
  452. #define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
  453. /* */
  454. #define FT_CURVE_TAG( flag ) ( flag & 3 )
  455. #define FT_CURVE_TAG_ON 1
  456. #define FT_CURVE_TAG_CONIC 0
  457. #define FT_CURVE_TAG_CUBIC 2
  458. #define FT_CURVE_TAG_HAS_SCANMODE 4
  459. #define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
  460. #define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
  461. #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
  462. FT_CURVE_TAG_TOUCH_Y )
  463. #define FT_Curve_Tag_On FT_CURVE_TAG_ON
  464. #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
  465. #define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
  466. #define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
  467. #define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
  468. /*************************************************************************/
  469. /* */
  470. /* <FuncType> */
  471. /* FT_Outline_MoveToFunc */
  472. /* */
  473. /* <Description> */
  474. /* A function pointer type used to describe the signature of a `move */
  475. /* to' function during outline walking/decomposition. */
  476. /* */
  477. /* A `move to' is emitted to start a new contour in an outline. */
  478. /* */
  479. /* <Input> */
  480. /* to :: A pointer to the target point of the `move to'. */
  481. /* */
  482. /* user :: A typeless pointer which is passed from the caller of the */
  483. /* decomposition function. */
  484. /* */
  485. /* <Return> */
  486. /* Error code. 0~means success. */
  487. /* */
  488. typedef int
  489. (*FT_Outline_MoveToFunc)( const FT_Vector* to,
  490. void* user );
  491. #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
  492. /*************************************************************************/
  493. /* */
  494. /* <FuncType> */
  495. /* FT_Outline_LineToFunc */
  496. /* */
  497. /* <Description> */
  498. /* A function pointer type used to describe the signature of a `line */
  499. /* to' function during outline walking/decomposition. */
  500. /* */
  501. /* A `line to' is emitted to indicate a segment in the outline. */
  502. /* */
  503. /* <Input> */
  504. /* to :: A pointer to the target point of the `line to'. */
  505. /* */
  506. /* user :: A typeless pointer which is passed from the caller of the */
  507. /* decomposition function. */
  508. /* */
  509. /* <Return> */
  510. /* Error code. 0~means success. */
  511. /* */
  512. typedef int
  513. (*FT_Outline_LineToFunc)( const FT_Vector* to,
  514. void* user );
  515. #define FT_Outline_LineTo_Func FT_Outline_LineToFunc
  516. /*************************************************************************/
  517. /* */
  518. /* <FuncType> */
  519. /* FT_Outline_ConicToFunc */
  520. /* */
  521. /* <Description> */
  522. /* A function pointer type used to describe the signature of a `conic */
  523. /* to' function during outline walking or decomposition. */
  524. /* */
  525. /* A `conic to' is emitted to indicate a second-order Bézier arc in */
  526. /* the outline. */
  527. /* */
  528. /* <Input> */
  529. /* control :: An intermediate control point between the last position */
  530. /* and the new target in `to'. */
  531. /* */
  532. /* to :: A pointer to the target end point of the conic arc. */
  533. /* */
  534. /* user :: A typeless pointer which is passed from the caller of */
  535. /* the decomposition function. */
  536. /* */
  537. /* <Return> */
  538. /* Error code. 0~means success. */
  539. /* */
  540. typedef int
  541. (*FT_Outline_ConicToFunc)( const FT_Vector* control,
  542. const FT_Vector* to,
  543. void* user );
  544. #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
  545. /*************************************************************************/
  546. /* */
  547. /* <FuncType> */
  548. /* FT_Outline_CubicToFunc */
  549. /* */
  550. /* <Description> */
  551. /* A function pointer type used to describe the signature of a `cubic */
  552. /* to' function during outline walking or decomposition. */
  553. /* */
  554. /* A `cubic to' is emitted to indicate a third-order Bézier arc. */
  555. /* */
  556. /* <Input> */
  557. /* control1 :: A pointer to the first Bézier control point. */
  558. /* */
  559. /* control2 :: A pointer to the second Bézier control point. */
  560. /* */
  561. /* to :: A pointer to the target end point. */
  562. /* */
  563. /* user :: A typeless pointer which is passed from the caller of */
  564. /* the decomposition function. */
  565. /* */
  566. /* <Return> */
  567. /* Error code. 0~means success. */
  568. /* */
  569. typedef int
  570. (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
  571. const FT_Vector* control2,
  572. const FT_Vector* to,
  573. void* user );
  574. #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
  575. /*************************************************************************/
  576. /* */
  577. /* <Struct> */
  578. /* FT_Outline_Funcs */
  579. /* */
  580. /* <Description> */
  581. /* A structure to hold various function pointers used during outline */
  582. /* decomposition in order to emit segments, conic, and cubic Béziers. */
  583. /* */
  584. /* <Fields> */
  585. /* move_to :: The `move to' emitter. */
  586. /* */
  587. /* line_to :: The segment emitter. */
  588. /* */
  589. /* conic_to :: The second-order Bézier arc emitter. */
  590. /* */
  591. /* cubic_to :: The third-order Bézier arc emitter. */
  592. /* */
  593. /* shift :: The shift that is applied to coordinates before they */
  594. /* are sent to the emitter. */
  595. /* */
  596. /* delta :: The delta that is applied to coordinates before they */
  597. /* are sent to the emitter, but after the shift. */
  598. /* */
  599. /* <Note> */
  600. /* The point coordinates sent to the emitters are the transformed */
  601. /* version of the original coordinates (this is important for high */
  602. /* accuracy during scan-conversion). The transformation is simple: */
  603. /* */
  604. /* { */
  605. /* x' = (x << shift) - delta */
  606. /* y' = (x << shift) - delta */
  607. /* } */
  608. /* */
  609. /* Set the values of `shift' and `delta' to~0 to get the original */
  610. /* point coordinates. */
  611. /* */
  612. typedef struct FT_Outline_Funcs_
  613. {
  614. FT_Outline_MoveToFunc move_to;
  615. FT_Outline_LineToFunc line_to;
  616. FT_Outline_ConicToFunc conic_to;
  617. FT_Outline_CubicToFunc cubic_to;
  618. int shift;
  619. FT_Pos delta;
  620. } FT_Outline_Funcs;
  621. /*************************************************************************/
  622. /* */
  623. /* <Section> */
  624. /* basic_types */
  625. /* */
  626. /*************************************************************************/
  627. /*************************************************************************/
  628. /* */
  629. /* <Macro> */
  630. /* FT_IMAGE_TAG */
  631. /* */
  632. /* <Description> */
  633. /* This macro converts four-letter tags to an unsigned long type. */
  634. /* */
  635. /* <Note> */
  636. /* Since many 16-bit compilers don't like 32-bit enumerations, you */
  637. /* should redefine this macro in case of problems to something like */
  638. /* this: */
  639. /* */
  640. /* { */
  641. /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
  642. /* } */
  643. /* */
  644. /* to get a simple enumeration without assigning special numbers. */
  645. /* */
  646. #ifndef FT_IMAGE_TAG
  647. #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
  648. value = ( ( (unsigned long)_x1 << 24 ) | \
  649. ( (unsigned long)_x2 << 16 ) | \
  650. ( (unsigned long)_x3 << 8 ) | \
  651. (unsigned long)_x4 )
  652. #endif /* FT_IMAGE_TAG */
  653. /*************************************************************************/
  654. /* */
  655. /* <Enum> */
  656. /* FT_Glyph_Format */
  657. /* */
  658. /* <Description> */
  659. /* An enumeration type used to describe the format of a given glyph */
  660. /* image. Note that this version of FreeType only supports two image */
  661. /* formats, even though future font drivers will be able to register */
  662. /* their own format. */
  663. /* */
  664. /* <Values> */
  665. /* FT_GLYPH_FORMAT_NONE :: */
  666. /* The value~0 is reserved. */
  667. /* */
  668. /* FT_GLYPH_FORMAT_COMPOSITE :: */
  669. /* The glyph image is a composite of several other images. This */
  670. /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
  671. /* report compound glyphs (like accented characters). */
  672. /* */
  673. /* FT_GLYPH_FORMAT_BITMAP :: */
  674. /* The glyph image is a bitmap, and can be described as an */
  675. /* @FT_Bitmap. You generally need to access the `bitmap' field of */
  676. /* the @FT_GlyphSlotRec structure to read it. */
  677. /* */
  678. /* FT_GLYPH_FORMAT_OUTLINE :: */
  679. /* The glyph image is a vectorial outline made of line segments */
  680. /* and Bézier arcs; it can be described as an @FT_Outline; you */
  681. /* generally want to access the `outline' field of the */
  682. /* @FT_GlyphSlotRec structure to read it. */
  683. /* */
  684. /* FT_GLYPH_FORMAT_PLOTTER :: */
  685. /* The glyph image is a vectorial path with no inside and outside */
  686. /* contours. Some Type~1 fonts, like those in the Hershey family, */
  687. /* contain glyphs in this format. These are described as */
  688. /* @FT_Outline, but FreeType isn't currently capable of rendering */
  689. /* them correctly. */
  690. /* */
  691. typedef enum FT_Glyph_Format_
  692. {
  693. FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
  694. FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
  695. FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
  696. FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
  697. FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
  698. } FT_Glyph_Format;
  699. /*************************************************************************/
  700. /* */
  701. /* <Enum> */
  702. /* ft_glyph_format_xxx */
  703. /* */
  704. /* <Description> */
  705. /* A list of deprecated constants. Use the corresponding */
  706. /* @FT_Glyph_Format values instead. */
  707. /* */
  708. /* <Values> */
  709. /* ft_glyph_format_none :: See @FT_GLYPH_FORMAT_NONE. */
  710. /* ft_glyph_format_composite :: See @FT_GLYPH_FORMAT_COMPOSITE. */
  711. /* ft_glyph_format_bitmap :: See @FT_GLYPH_FORMAT_BITMAP. */
  712. /* ft_glyph_format_outline :: See @FT_GLYPH_FORMAT_OUTLINE. */
  713. /* ft_glyph_format_plotter :: See @FT_GLYPH_FORMAT_PLOTTER. */
  714. /* */
  715. #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
  716. #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
  717. #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
  718. #define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
  719. #define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
  720. /*************************************************************************/
  721. /*************************************************************************/
  722. /*************************************************************************/
  723. /***** *****/
  724. /***** R A S T E R D E F I N I T I O N S *****/
  725. /***** *****/
  726. /*************************************************************************/
  727. /*************************************************************************/
  728. /*************************************************************************/
  729. /*************************************************************************/
  730. /* */
  731. /* A raster is a scan converter, in charge of rendering an outline into */
  732. /* a a bitmap. This section contains the public API for rasters. */
  733. /* */
  734. /* Note that in FreeType 2, all rasters are now encapsulated within */
  735. /* specific modules called `renderers'. See `freetype/ftrender.h' for */
  736. /* more details on renderers. */
  737. /* */
  738. /*************************************************************************/
  739. /*************************************************************************/
  740. /* */
  741. /* <Section> */
  742. /* raster */
  743. /* */
  744. /* <Title> */
  745. /* Scanline Converter */
  746. /* */
  747. /* <Abstract> */
  748. /* How vectorial outlines are converted into bitmaps and pixmaps. */
  749. /* */
  750. /* <Description> */
  751. /* This section contains technical definitions. */
  752. /* */
  753. /*************************************************************************/
  754. /*************************************************************************/
  755. /* */
  756. /* <Type> */
  757. /* FT_Raster */
  758. /* */
  759. /* <Description> */
  760. /* A handle (pointer) to a raster object. Each object can be used */
  761. /* independently to convert an outline into a bitmap or pixmap. */
  762. /* */
  763. typedef struct FT_RasterRec_* FT_Raster;
  764. /*************************************************************************/
  765. /* */
  766. /* <Struct> */
  767. /* FT_Span */
  768. /* */
  769. /* <Description> */
  770. /* A structure used to model a single span of gray (or black) pixels */
  771. /* when rendering a monochrome or anti-aliased bitmap. */
  772. /* */
  773. /* <Fields> */
  774. /* x :: The span's horizontal start position. */
  775. /* */
  776. /* len :: The span's length in pixels. */
  777. /* */
  778. /* coverage :: The span color/coverage, ranging from 0 (background) */
  779. /* to 255 (foreground). Only used for anti-aliased */
  780. /* rendering. */
  781. /* */
  782. /* <Note> */
  783. /* This structure is used by the span drawing callback type named */
  784. /* @FT_SpanFunc which takes the y~coordinate of the span as a */
  785. /* a parameter. */
  786. /* */
  787. /* The coverage value is always between 0 and 255. If you want less */
  788. /* gray values, the callback function has to reduce them. */
  789. /* */
  790. typedef struct FT_Span_
  791. {
  792. short x;
  793. unsigned short len;
  794. unsigned char coverage;
  795. } FT_Span;
  796. /*************************************************************************/
  797. /* */
  798. /* <FuncType> */
  799. /* FT_SpanFunc */
  800. /* */
  801. /* <Description> */
  802. /* A function used as a call-back by the anti-aliased renderer in */
  803. /* order to let client applications draw themselves the gray pixel */
  804. /* spans on each scan line. */
  805. /* */
  806. /* <Input> */
  807. /* y :: The scanline's y~coordinate. */
  808. /* */
  809. /* count :: The number of spans to draw on this scanline. */
  810. /* */
  811. /* spans :: A table of `count' spans to draw on the scanline. */
  812. /* */
  813. /* user :: User-supplied data that is passed to the callback. */
  814. /* */
  815. /* <Note> */
  816. /* This callback allows client applications to directly render the */
  817. /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
  818. /* */
  819. /* This can be used to write anti-aliased outlines directly to a */
  820. /* given background bitmap, and even perform translucency. */
  821. /* */
  822. /* Note that the `count' field cannot be greater than a fixed value */
  823. /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */
  824. /* `ftoption.h'. By default, this value is set to~32, which means */
  825. /* that if there are more than 32~spans on a given scanline, the */
  826. /* callback is called several times with the same `y' parameter in */
  827. /* order to draw all callbacks. */
  828. /* */
  829. /* Otherwise, the callback is only called once per scan-line, and */
  830. /* only for those scanlines that do have `gray' pixels on them. */
  831. /* */
  832. typedef void
  833. (*FT_SpanFunc)( int y,
  834. int count,
  835. const FT_Span* spans,
  836. void* user );
  837. #define FT_Raster_Span_Func FT_SpanFunc
  838. /*************************************************************************/
  839. /* */
  840. /* <FuncType> */
  841. /* FT_Raster_BitTest_Func */
  842. /* */
  843. /* <Description> */
  844. /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
  845. /* */
  846. /* A function used as a call-back by the monochrome scan-converter */
  847. /* to test whether a given target pixel is already set to the drawing */
  848. /* `color'. These tests are crucial to implement drop-out control */
  849. /* per-se the TrueType spec. */
  850. /* */
  851. /* <Input> */
  852. /* y :: The pixel's y~coordinate. */
  853. /* */
  854. /* x :: The pixel's x~coordinate. */
  855. /* */
  856. /* user :: User-supplied data that is passed to the callback. */
  857. /* */
  858. /* <Return> */
  859. /* 1~if the pixel is `set', 0~otherwise. */
  860. /* */
  861. typedef int
  862. (*FT_Raster_BitTest_Func)( int y,
  863. int x,
  864. void* user );
  865. /*************************************************************************/
  866. /* */
  867. /* <FuncType> */
  868. /* FT_Raster_BitSet_Func */
  869. /* */
  870. /* <Description> */
  871. /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
  872. /* */
  873. /* A function used as a call-back by the monochrome scan-converter */
  874. /* to set an individual target pixel. This is crucial to implement */
  875. /* drop-out control according to the TrueType specification. */
  876. /* */
  877. /* <Input> */
  878. /* y :: The pixel's y~coordinate. */
  879. /* */
  880. /* x :: The pixel's x~coordinate. */
  881. /* */
  882. /* user :: User-supplied data that is passed to the callback. */
  883. /* */
  884. /* <Return> */
  885. /* 1~if the pixel is `set', 0~otherwise. */
  886. /* */
  887. typedef void
  888. (*FT_Raster_BitSet_Func)( int y,
  889. int x,
  890. void* user );
  891. /*************************************************************************/
  892. /* */
  893. /* <Enum> */
  894. /* FT_RASTER_FLAG_XXX */
  895. /* */
  896. /* <Description> */
  897. /* A list of bit flag constants as used in the `flags' field of a */
  898. /* @FT_Raster_Params structure. */
  899. /* */
  900. /* <Values> */
  901. /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
  902. /* */
  903. /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
  904. /* anti-aliased glyph image should be */
  905. /* generated. Otherwise, it will be */
  906. /* monochrome (1-bit). */
  907. /* */
  908. /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
  909. /* rendering. In this mode, client */
  910. /* applications must provide their own span */
  911. /* callback. This lets them directly */
  912. /* draw or compose over an existing bitmap. */
  913. /* If this bit is not set, the target */
  914. /* pixmap's buffer _must_ be zeroed before */
  915. /* rendering. */
  916. /* */
  917. /* Note that for now, direct rendering is */
  918. /* only possible with anti-aliased glyphs. */
  919. /* */
  920. /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
  921. /* rendering mode. If set, the output will */
  922. /* be clipped to a box specified in the */
  923. /* `clip_box' field of the */
  924. /* @FT_Raster_Params structure. */
  925. /* */
  926. /* Note that by default, the glyph bitmap */
  927. /* is clipped to the target pixmap, except */
  928. /* in direct rendering mode where all spans */
  929. /* are generated if no clipping box is set. */
  930. /* */
  931. #define FT_RASTER_FLAG_DEFAULT 0x0
  932. #define FT_RASTER_FLAG_AA 0x1
  933. #define FT_RASTER_FLAG_DIRECT 0x2
  934. #define FT_RASTER_FLAG_CLIP 0x4
  935. /* deprecated */
  936. #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
  937. #define ft_raster_flag_aa FT_RASTER_FLAG_AA
  938. #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
  939. #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
  940. /**********************