ftrender.h 6.5 KB

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