The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* autohint.h */ |
| 4 | /* */ |
| 5 | /* High-level `autohint' module-specific interface (specification). */ |
| 6 | /* */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 7 | /* Copyright 1996-2002, 2007, 2009, 2012 by */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 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 | /*************************************************************************/ |
| 20 | /* */ |
| 21 | /* The auto-hinter is used to load and automatically hint glyphs if a */ |
| 22 | /* format-specific hinter isn't available. */ |
| 23 | /* */ |
| 24 | /*************************************************************************/ |
| 25 | |
| 26 | |
| 27 | #ifndef __AUTOHINT_H__ |
| 28 | #define __AUTOHINT_H__ |
| 29 | |
| 30 | |
| 31 | /*************************************************************************/ |
| 32 | /* */ |
| 33 | /* A small technical note regarding automatic hinting in order to */ |
| 34 | /* clarify this module interface. */ |
| 35 | /* */ |
| 36 | /* An automatic hinter might compute two kinds of data for a given face: */ |
| 37 | /* */ |
| 38 | /* - global hints: Usually some metrics that describe global properties */ |
| 39 | /* of the face. It is computed by scanning more or less */ |
| 40 | /* aggressively the glyphs in the face, and thus can be */ |
| 41 | /* very slow to compute (even if the size of global */ |
| 42 | /* hints is really small). */ |
| 43 | /* */ |
| 44 | /* - glyph hints: These describe some important features of the glyph */ |
| 45 | /* outline, as well as how to align them. They are */ |
| 46 | /* generally much faster to compute than global hints. */ |
| 47 | /* */ |
| 48 | /* The current FreeType auto-hinter does a pretty good job while */ |
| 49 | /* performing fast computations for both global and glyph hints. */ |
| 50 | /* However, we might be interested in introducing more complex and */ |
| 51 | /* powerful algorithms in the future, like the one described in the John */ |
| 52 | /* D. Hobby paper, which unfortunately requires a lot more horsepower. */ |
| 53 | /* */ |
| 54 | /* Because a sufficiently sophisticated font management system would */ |
| 55 | /* typically implement an LRU cache of opened face objects to reduce */ |
| 56 | /* memory usage, it is a good idea to be able to avoid recomputing */ |
| 57 | /* global hints every time the same face is re-opened. */ |
| 58 | /* */ |
| 59 | /* We thus provide the ability to cache global hints outside of the face */ |
| 60 | /* object, in order to speed up font re-opening time. Of course, this */ |
| 61 | /* feature is purely optional, so most client programs won't even notice */ |
| 62 | /* it. */ |
| 63 | /* */ |
| 64 | /* I initially thought that it would be a good idea to cache the glyph */ |
| 65 | /* hints too. However, my general idea now is that if you really need */ |
| 66 | /* to cache these too, you are simply in need of a new font format, */ |
| 67 | /* where all this information could be stored within the font file and */ |
| 68 | /* decoded on the fly. */ |
| 69 | /* */ |
| 70 | /*************************************************************************/ |
| 71 | |
| 72 | |
| 73 | #include <ft2build.h> |
| 74 | #include FT_FREETYPE_H |
| 75 | |
| 76 | |
| 77 | FT_BEGIN_HEADER |
| 78 | |
| 79 | |
| 80 | typedef struct FT_AutoHinterRec_ *FT_AutoHinter; |
| 81 | |
| 82 | |
| 83 | /*************************************************************************/ |
| 84 | /* */ |
| 85 | /* <FuncType> */ |
| 86 | /* FT_AutoHinter_GlobalGetFunc */ |
| 87 | /* */ |
| 88 | /* <Description> */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 89 | /* Retrieve the global hints computed for a given face object. The */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 90 | /* resulting data is dissociated from the face and will survive a */ |
| 91 | /* call to FT_Done_Face(). It must be discarded through the API */ |
| 92 | /* FT_AutoHinter_GlobalDoneFunc(). */ |
| 93 | /* */ |
| 94 | /* <Input> */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 95 | /* hinter :: A handle to the source auto-hinter. */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 96 | /* */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 97 | /* face :: A handle to the source face object. */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 98 | /* */ |
| 99 | /* <Output> */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 100 | /* global_hints :: A typeless pointer to the global hints. */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 101 | /* */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 102 | /* global_len :: The size in bytes of the global hints. */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 103 | /* */ |
| 104 | typedef void |
| 105 | (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter, |
| 106 | FT_Face face, |
| 107 | void** global_hints, |
| 108 | long* global_len ); |
| 109 | |
| 110 | |
| 111 | /*************************************************************************/ |
| 112 | /* */ |
| 113 | /* <FuncType> */ |
| 114 | /* FT_AutoHinter_GlobalDoneFunc */ |
| 115 | /* */ |
| 116 | /* <Description> */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 117 | /* Discard the global hints retrieved through */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 118 | /* FT_AutoHinter_GlobalGetFunc(). This is the only way these hints */ |
| 119 | /* are freed from memory. */ |
| 120 | /* */ |
| 121 | /* <Input> */ |
| 122 | /* hinter :: A handle to the auto-hinter module. */ |
| 123 | /* */ |
| 124 | /* global :: A pointer to retrieved global hints to discard. */ |
| 125 | /* */ |
| 126 | typedef void |
| 127 | (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter, |
| 128 | void* global ); |
| 129 | |
| 130 | |
| 131 | /*************************************************************************/ |
| 132 | /* */ |
| 133 | /* <FuncType> */ |
| 134 | /* FT_AutoHinter_GlobalResetFunc */ |
| 135 | /* */ |
| 136 | /* <Description> */ |
| 137 | /* This function is used to recompute the global metrics in a given */ |
| 138 | /* font. This is useful when global font data changes (e.g. Multiple */ |
| 139 | /* Masters fonts where blend coordinates change). */ |
| 140 | /* */ |
| 141 | /* <Input> */ |
| 142 | /* hinter :: A handle to the source auto-hinter. */ |
| 143 | /* */ |
| 144 | /* face :: A handle to the face. */ |
| 145 | /* */ |
| 146 | typedef void |
| 147 | (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter, |
| 148 | FT_Face face ); |
| 149 | |
| 150 | |
| 151 | /*************************************************************************/ |
| 152 | /* */ |
| 153 | /* <FuncType> */ |
| 154 | /* FT_AutoHinter_GlyphLoadFunc */ |
| 155 | /* */ |
| 156 | /* <Description> */ |
| 157 | /* This function is used to load, scale, and automatically hint a */ |
| 158 | /* glyph from a given face. */ |
| 159 | /* */ |
| 160 | /* <Input> */ |
| 161 | /* face :: A handle to the face. */ |
| 162 | /* */ |
| 163 | /* glyph_index :: The glyph index. */ |
| 164 | /* */ |
| 165 | /* load_flags :: The load flags. */ |
| 166 | /* */ |
| 167 | /* <Note> */ |
| 168 | /* This function is capable of loading composite glyphs by hinting */ |
| 169 | /* each sub-glyph independently (which improves quality). */ |
| 170 | /* */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 171 | /* It will call the font driver with @FT_Load_Glyph, with */ |
| 172 | /* @FT_LOAD_NO_SCALE set. */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 173 | /* */ |
| 174 | typedef FT_Error |
| 175 | (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter, |
| 176 | FT_GlyphSlot slot, |
| 177 | FT_Size size, |
| 178 | FT_UInt glyph_index, |
| 179 | FT_Int32 load_flags ); |
| 180 | |
| 181 | |
| 182 | /*************************************************************************/ |
| 183 | /* */ |
| 184 | /* <Struct> */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 185 | /* FT_AutoHinter_InterfaceRec */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 186 | /* */ |
| 187 | /* <Description> */ |
| 188 | /* The auto-hinter module's interface. */ |
| 189 | /* */ |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 190 | typedef struct FT_AutoHinter_InterfaceRec_ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 191 | { |
| 192 | FT_AutoHinter_GlobalResetFunc reset_face; |
| 193 | FT_AutoHinter_GlobalGetFunc get_global_hints; |
| 194 | FT_AutoHinter_GlobalDoneFunc done_global_hints; |
| 195 | FT_AutoHinter_GlyphLoadFunc load_glyph; |
| 196 | |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 197 | } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface; |
| 198 | |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 199 | |
David 'Digit' Turner | 295ffce | 2010-03-03 14:24:57 -0800 | [diff] [blame] | 200 | #ifndef FT_CONFIG_OPTION_PIC |
| 201 | |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 202 | #define FT_DEFINE_AUTOHINTER_INTERFACE( \ |
| 203 | class_, \ |
| 204 | reset_face_, \ |
| 205 | get_global_hints_, \ |
| 206 | done_global_hints_, \ |
| 207 | load_glyph_ ) \ |
| 208 | FT_CALLBACK_TABLE_DEF \ |
| 209 | const FT_AutoHinter_InterfaceRec class_ = \ |
| 210 | { \ |
| 211 | reset_face_, \ |
| 212 | get_global_hints_, \ |
| 213 | done_global_hints_, \ |
| 214 | load_glyph_ \ |
David 'Digit' Turner | 295ffce | 2010-03-03 14:24:57 -0800 | [diff] [blame] | 215 | }; |
| 216 | |
Eric Vannier | 41371e1 | 2012-03-22 16:08:33 -0700 | [diff] [blame] | 217 | #else /* FT_CONFIG_OPTION_PIC */ |
David 'Digit' Turner | 295ffce | 2010-03-03 14:24:57 -0800 | [diff] [blame] | 218 | |
Victoria Lease | 727dee1 | 2013-06-10 13:55:54 -0700 | [diff] [blame] | 219 | #define FT_DEFINE_AUTOHINTER_INTERFACE( \ |
| 220 | class_, \ |
| 221 | reset_face_, \ |
| 222 | get_global_hints_, \ |
| 223 | done_global_hints_, \ |
| 224 | load_glyph_ ) \ |
| 225 | void \ |
| 226 | FT_Init_Class_ ## class_( FT_Library library, \ |
| 227 | FT_AutoHinter_InterfaceRec* clazz ) \ |
| 228 | { \ |
| 229 | FT_UNUSED( library ); \ |
| 230 | \ |
| 231 | clazz->reset_face = reset_face_; \ |
| 232 | clazz->get_global_hints = get_global_hints_; \ |
| 233 | clazz->done_global_hints = done_global_hints_; \ |
| 234 | clazz->load_glyph = load_glyph_; \ |
Eric Vannier | 41371e1 | 2012-03-22 16:08:33 -0700 | [diff] [blame] | 235 | } |
David 'Digit' Turner | 295ffce | 2010-03-03 14:24:57 -0800 | [diff] [blame] | 236 | |
Eric Vannier | 41371e1 | 2012-03-22 16:08:33 -0700 | [diff] [blame] | 237 | #endif /* FT_CONFIG_OPTION_PIC */ |
The Android Open Source Project | 049d6fe | 2009-03-03 19:29:31 -0800 | [diff] [blame] | 238 | |
| 239 | FT_END_HEADER |
| 240 | |
| 241 | #endif /* __AUTOHINT_H__ */ |
| 242 | |
| 243 | |
| 244 | /* END */ |