Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
afmodule.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* afmodule.c */
4 /* */
5 /* Auto-fitter module implementation (body). */
6 /* */
7 /* Copyright 2003-2006, 2009, 2011-2013 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 #include "afglobal.h"
20 #include "afmodule.h"
21 #include "afloader.h"
22 #include "aferrors.h"
23 #include "afpic.h"
24 
25 #ifdef FT_DEBUG_AUTOFIT
26  int _af_debug_disable_horz_hints;
27  int _af_debug_disable_vert_hints;
28  int _af_debug_disable_blue_hints;
29  void* _af_debug_hints;
30 #endif
31 
32 #include FT_INTERNAL_OBJECTS_H
33 #include FT_INTERNAL_DEBUG_H
34 #include FT_AUTOHINTER_H
35 #include FT_SERVICE_PROPERTIES_H
36 
37 
38  /*************************************************************************/
39  /* */
40  /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
41  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
42  /* messages during execution. */
43  /* */
44 #undef FT_COMPONENT
45 #define FT_COMPONENT trace_afmodule
46 
47 
48  FT_Error
50  AF_FaceGlobals* aglobals,
51  AF_Module module )
52  {
54  AF_FaceGlobals globals;
55 
56 
57  if ( !face )
58  return FT_THROW( Invalid_Argument );
59 
60  globals = (AF_FaceGlobals)face->autohint.data;
61  if ( !globals )
62  {
63  /* trigger computation of the global script data */
64  /* in case it hasn't been done yet */
65  error = af_face_globals_new( face, &globals, module );
66  if ( !error )
67  {
68  face->autohint.data =
69  (FT_Pointer)globals;
70  face->autohint.finalizer =
72  }
73  }
74 
75  if ( !error )
76  *aglobals = globals;
77 
78  return error;
79  }
80 
81 
82  FT_Error
84  const char* property_name,
85  const void* value )
86  {
88  AF_Module module = (AF_Module)ft_module;
89 
90 
91  if ( !ft_strcmp( property_name, "fallback-script" ) )
92  {
93  FT_UInt* fallback_script = (FT_UInt*)value;
94 
95 
96  module->fallback_script = *fallback_script;
97 
98  return error;
99  }
100  else if ( !ft_strcmp( property_name, "increase-x-height" ) )
101  {
103  AF_FaceGlobals globals;
104 
105 
106  error = af_property_get_face_globals( prop->face, &globals, module );
107  if ( !error )
108  globals->increase_x_height = prop->limit;
109 
110  return error;
111  }
112 
113  FT_TRACE0(( "af_property_set: missing property `%s'\n",
114  property_name ));
115  return FT_THROW( Missing_Property );
116  }
117 
118 
119  FT_Error
121  const char* property_name,
122  void* value )
123  {
125  AF_Module module = (AF_Module)ft_module;
126  FT_UInt fallback_script = module->fallback_script;
127 
128 
129  if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
130  {
132  AF_FaceGlobals globals;
133 
134 
135  error = af_property_get_face_globals( prop->face, &globals, module );
136  if ( !error )
137  prop->map = globals->glyph_scripts;
138 
139  return error;
140  }
141  else if ( !ft_strcmp( property_name, "fallback-script" ) )
142  {
143  FT_UInt* val = (FT_UInt*)value;
144 
145 
146  *val = fallback_script;
147 
148  return error;
149  }
150  else if ( !ft_strcmp( property_name, "increase-x-height" ) )
151  {
153  AF_FaceGlobals globals;
154 
155 
156  error = af_property_get_face_globals( prop->face, &globals, module );
157  if ( !error )
158  prop->limit = globals->increase_x_height;
159 
160  return error;
161  }
162 
163 
164  FT_TRACE0(( "af_property_get: missing property `%s'\n",
165  property_name ));
166  return FT_THROW( Missing_Property );
167  }
168 
169 
171  af_service_properties,
174 
175 
177  af_services,
179 
180 
183  const char* module_interface )
184  {
185  /* AF_SERVICES_GET derefers `library' in PIC mode */
186 #ifdef FT_CONFIG_OPTION_PIC
188 
189 
190  if ( !module )
191  return NULL;
192  library = module->library;
193  if ( !library )
194  return NULL;
195 #else
196  FT_UNUSED( module );
197 #endif
198 
199  return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
200  }
201 
202 
204  af_autofitter_init( FT_Module ft_module ) /* AF_Module */
205  {
206  AF_Module module = (AF_Module)ft_module;
207 
208 
209  module->fallback_script = AF_SCRIPT_FALLBACK;
210 
211  return af_loader_init( module );
212  }
213 
214 
215  FT_CALLBACK_DEF( void )
216  af_autofitter_done( FT_Module ft_module ) /* AF_Module */
217  {
218  AF_Module module = (AF_Module)ft_module;
219 
220 
221  af_loader_done( module );
222  }
223 
224 
227  FT_GlyphSlot slot,
228  FT_Size size,
229  FT_UInt glyph_index,
230  FT_Int32 load_flags )
231  {
232  FT_UNUSED( size );
233 
234  return af_loader_load_glyph( module, slot->face,
235  glyph_index, load_flags );
236  }
237 
238 
240  af_autofitter_interface,
241  NULL, /* reset_face */
242  NULL, /* get_global_hints */
243  NULL, /* done_global_hints */
245 
246 
248  autofit_module_class,
249 
251  sizeof ( AF_ModuleRec ),
252 
253  "autofitter",
254  0x10000L, /* version 1.0 of the autofitter */
255  0x20000L, /* requires FreeType 2.0 or above */
256 
257  (const void*)&AF_INTERFACE_GET,
258 
262 
263 
264 /* END */
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
Definition: ftobjs.c:58
int FT_Error
Definition: fttypes.h:296
FT_Error(* FT_Module_Constructor)(FT_Module module)
Definition: ftmodapi.h:121
typedefFT_BEGIN_HEADER struct AF_ModuleRec_ * AF_Module
Definition: afloader.h:28
FT_Generic_Finalizer finalizer
Definition: fttypes.h:458
#define FT_DEFINE_MODULE( class_, flags_, size_, name_, version_, requires_, interface_, init_, done_, get_interface_)
Definition: ftobjs.h:1445
#define NULL
Definition: ftobjs.h:61
af_autofitter_load_glyph(AF_Module module, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: afmodule.c:226
void(* FT_Generic_Finalizer)(void *object)
Definition: fttypes.h:424
return FT_THROW(Missing_Property)
#define FT_UNUSED(arg)
Definition: ftconfig.h:76
FT_DEFINE_AUTOHINTER_INTERFACE(af_autofitter_interface, NULL, NULL, NULL,(FT_AutoHinter_GlyphLoadFunc) af_autofitter_load_glyph) FT_DEFINE_MODULE(autofit_module_class
FT_Library library
Definition: cffdrivr.c:414
return FT_Err_Ok
Definition: ftbbox.c:645
#define FT_DEFINE_SERVICEDESCREC1(class_, serv_id_1, serv_data_1)
Definition: ftserv.h:196
af_face_globals_new(FT_Face face, AF_FaceGlobals *aglobals, AF_Module module)
Definition: afglobal.c:159
const void FT_Module_Constructor FT_Module_Destructor af_autofitter_done
Definition: afmodule.c:253
FT_SERVICE_ID_PROPERTIES
Definition: afmodule.c:178
FT_Generic autohint
Definition: freetype.h:968
FT_UInt increase_x_height
Definition: afglobal.h:69
GLenum GLuint GLint GLenum face
#define const
Definition: zconf.h:91
af_loader_init(AF_Module module)
Definition: afloader.c:29
FT_Module_Interface(* FT_Module_Requester)(FT_Module module, const char *name)
Definition: ftmodapi.h:153
TT_CMap_Info_GetFunc tt_get_cmap_info const char * module_interface
Definition: sfdriver.c:429
FT_BEGIN_HEADER struct AF_ModuleRec_ AF_ModuleRec
FT_Error error
Definition: cffdrivr.c:411
void * FT_Pointer
Definition: fttypes.h:307
FT_Pointer FT_Module_Interface
Definition: ftmodapi.h:106
GLuint GLfloat * val
signed int FT_Int32
Definition: ftconfig.h:132
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:323
af_face_globals_free(AF_FaceGlobals globals)
Definition: afglobal.c:195
const void FT_Module_Constructor af_autofitter_init
Definition: afmodule.c:253
&AF_SERVICE_PROPERTIES_GET af_get_interface(FT_Module module, const char *module_interface)
Definition: afmodule.c:182
GLsizei const GLfloat * value
FT_Error(* FT_AutoHinter_GlyphLoadFunc)(FT_AutoHinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: autohint.h:175
FT_Error af_property_get(FT_Module ft_module, const char *property_name, void *value)
Definition: afmodule.c:120
#define AF_SERVICES_GET
Definition: afpic.h:30
void * data
Definition: fttypes.h:457
af_loader_load_glyph(AF_Module module, FT_Face face, FT_UInt gindex, FT_Int32 load_flags)
Definition: afloader.c:493
if(!abbox) return FT_THROW(Invalid_Argument)
af_loader_done(AF_Module module)
Definition: afloader.c:79
#define AF_SCRIPT_FALLBACK
Definition: afglobal.h:37
FT_MODULE_HINTER
Definition: afmodule.c:250
const void *& AF_INTERFACE_GET
Definition: afmodule.c:253
FT_Error(* FT_Properties_SetFunc)(FT_Module module, const char *property_name, const void *value)
Definition: svprop.h:30
struct AF_FaceGlobalsRec_ * AF_FaceGlobals
Definition: aftypes.h:249
unsigned int FT_UInt
Definition: fttypes.h:227
FT_Error af_property_get_face_globals(FT_Face face, AF_FaceGlobals *aglobals, AF_Module module)
Definition: afmodule.c:49
void(* FT_Module_Destructor)(FT_Module module)
Definition: ftmodapi.h:136
FT_Error af_property_set(FT_Module ft_module, const char *property_name, const void *value)
Definition: afmodule.c:83
FT_DEFINE_SERVICE_PROPERTIESREC(af_service_properties,(FT_Properties_SetFunc) af_property_set,(FT_Properties_GetFunc) af_property_get) FT_DEFINE_SERVICEDESCREC1(af_services
#define AF_SERVICE_PROPERTIES_GET
Definition: afpic.h:31
FT_Error(* FT_Properties_GetFunc)(FT_Module module, const char *property_name, void *value)
Definition: svprop.h:35
const char * property_name
Definition: cffdrivr.c:581
FT_Byte * glyph_scripts
Definition: afglobal.h:66
FT_TRACE0(("cff_property_set: missing property `%s'\, property_name))
GLsizeiptr size
#define ft_strcmp
Definition: ftstdlib.h:85