• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftdriver.h                                                             */
4 /*                                                                         */
5 /*    FreeType font driver interface (specification).                      */
6 /*                                                                         */
7 /*  Copyright 1996-2001, 2002, 2003, 2006, 2008 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 __FTDRIVER_H__
20 #define __FTDRIVER_H__
21 
22 
23 #include <ft2build.h>
24 #include FT_MODULE_H
25 
26 
27 FT_BEGIN_HEADER
28 
29 
30   typedef FT_Error
31   (*FT_Face_InitFunc)( FT_Stream      stream,
32                        FT_Face        face,
33                        FT_Int         typeface_index,
34                        FT_Int         num_params,
35                        FT_Parameter*  parameters );
36 
37   typedef void
38   (*FT_Face_DoneFunc)( FT_Face  face );
39 
40 
41   typedef FT_Error
42   (*FT_Size_InitFunc)( FT_Size  size );
43 
44   typedef void
45   (*FT_Size_DoneFunc)( FT_Size  size );
46 
47 
48   typedef FT_Error
49   (*FT_Slot_InitFunc)( FT_GlyphSlot  slot );
50 
51   typedef void
52   (*FT_Slot_DoneFunc)( FT_GlyphSlot  slot );
53 
54 
55   typedef FT_Error
56   (*FT_Size_RequestFunc)( FT_Size          size,
57                           FT_Size_Request  req );
58 
59   typedef FT_Error
60   (*FT_Size_SelectFunc)( FT_Size   size,
61                          FT_ULong  size_index );
62 
63 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
64 
65   typedef FT_Error
66   (*FT_Size_ResetPointsFunc)( FT_Size     size,
67                               FT_F26Dot6  char_width,
68                               FT_F26Dot6  char_height,
69                               FT_UInt     horz_resolution,
70                               FT_UInt     vert_resolution );
71 
72   typedef FT_Error
73   (*FT_Size_ResetPixelsFunc)( FT_Size  size,
74                               FT_UInt  pixel_width,
75                               FT_UInt  pixel_height );
76 
77 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
78 
79   typedef FT_Error
80   (*FT_Slot_LoadFunc)( FT_GlyphSlot  slot,
81                        FT_Size       size,
82                        FT_UInt       glyph_index,
83                        FT_Int32      load_flags );
84 
85 
86   typedef FT_UInt
87   (*FT_CharMap_CharIndexFunc)( FT_CharMap  charmap,
88                                FT_Long     charcode );
89 
90   typedef FT_Long
91   (*FT_CharMap_CharNextFunc)( FT_CharMap  charmap,
92                               FT_Long     charcode );
93 
94 
95   typedef FT_Error
96   (*FT_Face_GetKerningFunc)( FT_Face     face,
97                              FT_UInt     left_glyph,
98                              FT_UInt     right_glyph,
99                              FT_Vector*  kerning );
100 
101 
102   typedef FT_Error
103   (*FT_Face_AttachFunc)( FT_Face    face,
104                          FT_Stream  stream );
105 
106 
107   typedef FT_Error
108   (*FT_Face_GetAdvancesFunc)( FT_Face    face,
109                               FT_UInt    first,
110                               FT_UInt    count,
111                               FT_Int32   flags,
112                               FT_Fixed*  advances );
113 
114 
115   /*************************************************************************/
116   /*                                                                       */
117   /* <Struct>                                                              */
118   /*    FT_Driver_ClassRec                                                 */
119   /*                                                                       */
120   /* <Description>                                                         */
121   /*    The font driver class.  This structure mostly contains pointers to */
122   /*    driver methods.                                                    */
123   /*                                                                       */
124   /* <Fields>                                                              */
125   /*    root             :: The parent module.                             */
126   /*                                                                       */
127   /*    face_object_size :: The size of a face object in bytes.            */
128   /*                                                                       */
129   /*    size_object_size :: The size of a size object in bytes.            */
130   /*                                                                       */
131   /*    slot_object_size :: The size of a glyph object in bytes.           */
132   /*                                                                       */
133   /*    init_face        :: The format-specific face constructor.          */
134   /*                                                                       */
135   /*    done_face        :: The format-specific face destructor.           */
136   /*                                                                       */
137   /*    init_size        :: The format-specific size constructor.          */
138   /*                                                                       */
139   /*    done_size        :: The format-specific size destructor.           */
140   /*                                                                       */
141   /*    init_slot        :: The format-specific slot constructor.          */
142   /*                                                                       */
143   /*    done_slot        :: The format-specific slot destructor.           */
144   /*                                                                       */
145   /*                                                                       */
146   /*    load_glyph       :: A function handle to load a glyph to a slot.   */
147   /*                        This field is mandatory!                       */
148   /*                                                                       */
149   /*    get_kerning      :: A function handle to return the unscaled       */
150   /*                        kerning for a given pair of glyphs.  Can be    */
151   /*                        set to 0 if the format doesn't support         */
152   /*                        kerning.                                       */
153   /*                                                                       */
154   /*    attach_file      :: This function handle is used to read           */
155   /*                        additional data for a face from another        */
156   /*                        file/stream.  For example, this can be used to */
157   /*                        add data from AFM or PFM files on a Type 1     */
158   /*                        face, or a CIDMap on a CID-keyed face.         */
159   /*                                                                       */
160   /*    get_advances     :: A function handle used to return advance       */
161   /*                        widths of `count' glyphs (in font units),      */
162   /*                        starting at `first'.  The `vertical' flag must */
163   /*                        be set to get vertical advance heights.  The   */
164   /*                        `advances' buffer is caller-allocated.         */
165   /*                        Currently not implemented.  The idea of this   */
166   /*                        function is to be able to perform              */
167   /*                        device-independent text layout without loading */
168   /*                        a single glyph image.                          */
169   /*                                                                       */
170   /*    request_size     :: A handle to a function used to request the new */
171   /*                        character size.  Can be set to 0 if the        */
172   /*                        scaling done in the base layer suffices.       */
173   /*                                                                       */
174   /*    select_size      :: A handle to a function used to select a new    */
175   /*                        fixed size.  It is used only if                */
176   /*                        @FT_FACE_FLAG_FIXED_SIZES is set.  Can be set  */
177   /*                        to 0 if the scaling done in the base layer     */
178   /*                        suffices.                                      */
179   /* <Note>                                                                */
180   /*    Most function pointers, with the exception of `load_glyph', can be */
181   /*    set to 0 to indicate a default behaviour.                          */
182   /*                                                                       */
183   typedef struct  FT_Driver_ClassRec_
184   {
185     FT_Module_Class           root;
186 
187     FT_Long                   face_object_size;
188     FT_Long                   size_object_size;
189     FT_Long                   slot_object_size;
190 
191     FT_Face_InitFunc          init_face;
192     FT_Face_DoneFunc          done_face;
193 
194     FT_Size_InitFunc          init_size;
195     FT_Size_DoneFunc          done_size;
196 
197     FT_Slot_InitFunc          init_slot;
198     FT_Slot_DoneFunc          done_slot;
199 
200 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
201 
202     FT_Size_ResetPointsFunc   set_char_sizes;
203     FT_Size_ResetPixelsFunc   set_pixel_sizes;
204 
205 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
206 
207     FT_Slot_LoadFunc          load_glyph;
208 
209     FT_Face_GetKerningFunc    get_kerning;
210     FT_Face_AttachFunc        attach_file;
211     FT_Face_GetAdvancesFunc   get_advances;
212 
213     /* since version 2.2 */
214     FT_Size_RequestFunc       request_size;
215     FT_Size_SelectFunc        select_size;
216 
217   } FT_Driver_ClassRec, *FT_Driver_Class;
218 
219 
220   /*
221    *  The following functions are used as stubs for `set_char_sizes' and
222    *  `set_pixel_sizes'; the code uses `request_size' and `select_size'
223    *  functions instead.
224    *
225    *  Implementation is in `src/base/ftobjs.c'.
226    */
227 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
228 
229   FT_BASE( FT_Error )
230   ft_stub_set_char_sizes( FT_Size     size,
231                           FT_F26Dot6  width,
232                           FT_F26Dot6  height,
233                           FT_UInt     horz_res,
234                           FT_UInt     vert_res );
235 
236   FT_BASE( FT_Error )
237   ft_stub_set_pixel_sizes( FT_Size  size,
238                            FT_UInt  width,
239                            FT_UInt  height );
240 
241 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
242 
243 
244 FT_END_HEADER
245 
246 #endif /* __FTDRIVER_H__ */
247 
248 
249 /* END */
250