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