ftrender.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /***************************************************************************/
  2. /* */
  3. /* ftrender.h */
  4. /* */
  5. /* FreeType renderer modules public interface (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2005, 2006, 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 __FTRENDER_H__
  18. #define __FTRENDER_H__
  19. #include <ft2build.h>
  20. #include FT_MODULE_H
  21. #include FT_GLYPH_H
  22. FT_BEGIN_HEADER
  23. /*************************************************************************/
  24. /* */
  25. /* <Section> */
  26. /* module_management */
  27. /* */
  28. /*************************************************************************/
  29. /* create a new glyph object */
  30. typedef FT_Error
  31. (*FT_Glyph_InitFunc)( FT_Glyph glyph,
  32. FT_GlyphSlot slot );
  33. /* destroys a given glyph object */
  34. typedef void
  35. (*FT_Glyph_DoneFunc)( FT_Glyph glyph );
  36. typedef void
  37. (*FT_Glyph_TransformFunc)( FT_Glyph glyph,
  38. const FT_Matrix* matrix,
  39. const FT_Vector* delta );
  40. typedef void
  41. (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
  42. FT_BBox* abbox );
  43. typedef FT_Error
  44. (*FT_Glyph_CopyFunc)( FT_Glyph source,
  45. FT_Glyph target );
  46. typedef FT_Error
  47. (*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
  48. FT_GlyphSlot slot );
  49. /* deprecated */
  50. #define FT_Glyph_Init_Func FT_Glyph_InitFunc
  51. #define FT_Glyph_Done_Func FT_Glyph_DoneFunc
  52. #define FT_Glyph_Transform_Func FT_Glyph_TransformFunc
  53. #define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc
  54. #define FT_Glyph_Copy_Func FT_Glyph_CopyFunc
  55. #define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc
  56. struct FT_Glyph_Class_
  57. {
  58. FT_Long glyph_size;
  59. FT_Glyph_Format glyph_format;
  60. FT_Glyph_InitFunc glyph_init;
  61. FT_Glyph_DoneFunc glyph_done;
  62. FT_Glyph_CopyFunc glyph_copy;
  63. FT_Glyph_TransformFunc glyph_transform;
  64. FT_Glyph_GetBBoxFunc glyph_bbox;
  65. FT_Glyph_PrepareFunc glyph_prepare;
  66. };
  67. typedef FT_Error
  68. (*FT_Renderer_RenderFunc)( FT_Renderer renderer,
  69. FT_GlyphSlot slot,
  70. FT_UInt mode,
  71. const FT_Vector* origin );
  72. typedef FT_Error
  73. (*FT_Renderer_TransformFunc)( FT_Renderer renderer,
  74. FT_GlyphSlot slot,
  75. const FT_Matrix* matrix,
  76. const FT_Vector* delta );
  77. typedef void
  78. (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
  79. FT_GlyphSlot slot,
  80. FT_BBox* cbox );
  81. typedef FT_Error
  82. (*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
  83. FT_ULong mode_tag,
  84. FT_Pointer mode_ptr );
  85. /* deprecated identifiers */
  86. #define FTRenderer_render FT_Renderer_RenderFunc
  87. #define FTRenderer_transform FT_Renderer_TransformFunc
  88. #define FTRenderer_getCBox FT_Renderer_GetCBoxFunc
  89. #define FTRenderer_setMode FT_Renderer_SetModeFunc
  90. /*************************************************************************/
  91. /* */
  92. /* <Struct> */
  93. /* FT_Renderer_Class */
  94. /* */
  95. /* <Description> */
  96. /* The renderer module class descriptor. */
  97. /* */
  98. /* <Fields> */
  99. /* root :: The root @FT_Module_Class fields. */
  100. /* */
  101. /* glyph_format :: The glyph image format this renderer handles. */
  102. /* */
  103. /* render_glyph :: A method used to render the image that is in a */
  104. /* given glyph slot into a bitmap. */
  105. /* */
  106. /* transform_glyph :: A method used to transform the image that is in */
  107. /* a given glyph slot. */
  108. /* */
  109. /* get_glyph_cbox :: A method used to access the glyph's cbox. */
  110. /* */
  111. /* set_mode :: A method used to pass additional parameters. */
  112. /* */
  113. /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
  114. /* This is a pointer to its raster's class. */
  115. /* */
  116. typedef struct FT_Renderer_Class_
  117. {
  118. FT_Module_Class root;
  119. FT_Glyph_Format glyph_format;
  120. FT_Renderer_RenderFunc render_glyph;
  121. FT_Renderer_TransformFunc transform_glyph;
  122. FT_Renderer_GetCBoxFunc get_glyph_cbox;
  123. FT_Renderer_SetModeFunc set_mode;
  124. FT_Raster_Funcs* raster_class;
  125. } FT_Renderer_Class;
  126. /*************************************************************************/
  127. /* */
  128. /* <Function> */
  129. /* FT_Get_Renderer */
  130. /* */
  131. /* <Description> */
  132. /* Retrieve the current renderer for a given glyph format. */
  133. /* */
  134. /* <Input> */
  135. /* library :: A handle to the library object. */
  136. /* */
  137. /* format :: The glyph format. */
  138. /* */
  139. /* <Return> */
  140. /* A renderer handle. 0~if none found. */
  141. /* */
  142. /* <Note> */
  143. /* An error will be returned if a module already exists by that name, */
  144. /* or if the module requires a version of FreeType that is too great. */
  145. /* */
  146. /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */
  147. /* renderer by its name, use @FT_Get_Module. */
  148. /* */
  149. FT_EXPORT( FT_Renderer )
  150. FT_Get_Renderer( FT_Library library,
  151. FT_Glyph_Format format );
  152. /*************************************************************************/
  153. /* */
  154. /* <Function> */
  155. /* FT_Set_Renderer */
  156. /* */
  157. /* <Description> */
  158. /* Set the current renderer to use, and set additional mode. */
  159. /* */
  160. /* <InOut> */
  161. /* library :: A handle to the library object. */
  162. /* */
  163. /* <Input> */
  164. /* renderer :: A handle to the renderer object. */
  165. /* */
  166. /* num_params :: The number of additional parameters. */
  167. /* */
  168. /* parameters :: Additional parameters. */
  169. /* */
  170. /* <Return> */
  171. /* FreeType error code. 0~means success. */
  172. /* */
  173. /* <Note> */
  174. /* In case of success, the renderer will be used to convert glyph */
  175. /* images in the renderer's known format into bitmaps. */
  176. /* */
  177. /* This doesn't change the current renderer for other formats. */
  178. /* */
  179. /* Currently, only the B/W renderer, if compiled with */
  180. /* FT_RASTER_OPTION_ANTI_ALIASING (providing a 5-levels */
  181. /* anti-aliasing mode; this option must be set directly in */
  182. /* `ftraster.c' and is undefined by default) accepts a single tag */
  183. /* `pal5' to set its gray palette as a character string with */
  184. /* 5~elements. Consequently, the third and fourth argument are zero */
  185. /* normally. */
  186. /* */
  187. FT_EXPORT( FT_Error )
  188. FT_Set_Renderer( FT_Library library,
  189. FT_Renderer renderer,
  190. FT_UInt num_params,
  191. FT_Parameter* parameters );
  192. /* */
  193. FT_END_HEADER
  194. #endif /* __FTRENDER_H__ */
  195. /* END */