1 /***************************************************************************/ 2 /* */ 3 /* ahmodule.c */ 4 /* */ 5 /* Auto-hinting module implementation (declaration). */ 6 /* */ 7 /* Copyright 2000-2001, 2002 Catharon Productions Inc. */ 8 /* Author: David Turner */ 9 /* */ 10 /* This file is part of the Catharon Typography Project and shall only */ 11 /* be used, modified, and distributed under the terms of the Catharon */ 12 /* Open Source License that should come with this file under the name */ 13 /* `CatharonLicense.txt'. By continuing to use, modify, or distribute */ 14 /* this file you indicate that you have read the license and */ 15 /* understand and accept it fully. */ 16 /* */ 17 /* Note that this license is compatible with the FreeType license. */ 18 /* */ 19 /***************************************************************************/ 20 21 22 #include <ft2build.h> 23 #include FT_MODULE_H 24 #include "ahhint.h" 25 26 27 #ifdef DEBUG_HINTER 28 AH_Hinter ah_debug_hinter = NULL; 29 FT_Bool ah_debug_disable_horz = 0; 30 FT_Bool ah_debug_disable_vert = 0; 31 #endif 32 33 typedef struct FT_AutoHinterRec_ 34 { 35 FT_ModuleRec root; 36 AH_Hinter hinter; 37 38 } FT_AutoHinterRec; 39 40 41 FT_CALLBACK_DEF( FT_Error ) ft_autohinter_init(FT_AutoHinter module)42 ft_autohinter_init( FT_AutoHinter module ) 43 { 44 FT_Error error; 45 46 47 error = ah_hinter_new( module->root.library, &module->hinter ); 48 #ifdef DEBUG_HINTER 49 if ( !error ) 50 ah_debug_hinter = module->hinter; 51 #endif 52 return error; 53 } 54 55 56 FT_CALLBACK_DEF( void ) ft_autohinter_done(FT_AutoHinter module)57 ft_autohinter_done( FT_AutoHinter module ) 58 { 59 ah_hinter_done( module->hinter ); 60 61 #ifdef DEBUG_HINTER 62 ah_debug_hinter = NULL; 63 #endif 64 } 65 66 67 FT_CALLBACK_DEF( FT_Error ) ft_autohinter_load_glyph(FT_AutoHinter module,FT_GlyphSlot slot,FT_Size size,FT_UInt glyph_index,FT_Int32 load_flags)68 ft_autohinter_load_glyph( FT_AutoHinter module, 69 FT_GlyphSlot slot, 70 FT_Size size, 71 FT_UInt glyph_index, 72 FT_Int32 load_flags ) 73 { 74 return ah_hinter_load_glyph( module->hinter, 75 slot, size, glyph_index, load_flags ); 76 } 77 78 79 FT_CALLBACK_DEF( void ) ft_autohinter_reset_globals(FT_AutoHinter module,FT_Face face)80 ft_autohinter_reset_globals( FT_AutoHinter module, 81 FT_Face face ) 82 { 83 FT_UNUSED( module ); 84 85 if ( face->autohint.data ) 86 ah_hinter_done_face_globals( (AH_Face_Globals)(face->autohint.data) ); 87 } 88 89 90 FT_CALLBACK_DEF( void ) ft_autohinter_get_globals(FT_AutoHinter module,FT_Face face,void ** global_hints,long * global_len)91 ft_autohinter_get_globals( FT_AutoHinter module, 92 FT_Face face, 93 void** global_hints, 94 long* global_len ) 95 { 96 ah_hinter_get_global_hints( module->hinter, face, 97 global_hints, global_len ); 98 } 99 100 101 FT_CALLBACK_DEF( void ) ft_autohinter_done_globals(FT_AutoHinter module,void * global_hints)102 ft_autohinter_done_globals( FT_AutoHinter module, 103 void* global_hints ) 104 { 105 ah_hinter_done_global_hints( module->hinter, global_hints ); 106 } 107 108 109 FT_CALLBACK_TABLE_DEF 110 const FT_AutoHinter_ServiceRec ft_autohinter_service = 111 { 112 ft_autohinter_reset_globals, 113 ft_autohinter_get_globals, 114 ft_autohinter_done_globals, 115 ft_autohinter_load_glyph 116 }; 117 118 119 FT_CALLBACK_TABLE_DEF 120 const FT_Module_Class autohint_module_class = 121 { 122 ft_module_hinter, 123 sizeof ( FT_AutoHinterRec ), 124 125 "autohinter", 126 0x10000L, /* version 1.0 of the autohinter */ 127 0x20000L, /* requires FreeType 2.0 or above */ 128 129 (const void*) &ft_autohinter_service, 130 131 (FT_Module_Constructor)ft_autohinter_init, 132 (FT_Module_Destructor) ft_autohinter_done, 133 (FT_Module_Requester) 0 134 }; 135 136 137 /* END */ 138