autohint.h

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  autohint.h                                                             */
00004 /*                                                                         */
00005 /*    High-level `autohint' module-specific interface (specification).     */
00006 /*                                                                         */
00007 /*  Copyright 1996-2001, 2002, 2007 by                                     */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019   /*************************************************************************/
00020   /*                                                                       */
00021   /* The auto-hinter is used to load and automatically hint glyphs if a    */
00022   /* format-specific hinter isn't available.                               */
00023   /*                                                                       */
00024   /*************************************************************************/
00025 
00026 
00027 #ifndef __AUTOHINT_H__
00028 #define __AUTOHINT_H__
00029 
00030 
00031   /*************************************************************************/
00032   /*                                                                       */
00033   /* A small technical note regarding automatic hinting in order to        */
00034   /* clarify this module interface.                                        */
00035   /*                                                                       */
00036   /* An automatic hinter might compute two kinds of data for a given face: */
00037   /*                                                                       */
00038   /* - global hints: Usually some metrics that describe global properties  */
00039   /*                 of the face.  It is computed by scanning more or less */
00040   /*                 aggressively the glyphs in the face, and thus can be  */
00041   /*                 very slow to compute (even if the size of global      */
00042   /*                 hints is really small).                               */
00043   /*                                                                       */
00044   /* - glyph hints:  These describe some important features of the glyph   */
00045   /*                 outline, as well as how to align them.  They are      */
00046   /*                 generally much faster to compute than global hints.   */
00047   /*                                                                       */
00048   /* The current FreeType auto-hinter does a pretty good job while         */
00049   /* performing fast computations for both global and glyph hints.         */
00050   /* However, we might be interested in introducing more complex and       */
00051   /* powerful algorithms in the future, like the one described in the John */
00052   /* D. Hobby paper, which unfortunately requires a lot more horsepower.   */
00053   /*                                                                       */
00054   /* Because a sufficiently sophisticated font management system would     */
00055   /* typically implement an LRU cache of opened face objects to reduce     */
00056   /* memory usage, it is a good idea to be able to avoid recomputing       */
00057   /* global hints every time the same face is re-opened.                   */
00058   /*                                                                       */
00059   /* We thus provide the ability to cache global hints outside of the face */
00060   /* object, in order to speed up font re-opening time.  Of course, this   */
00061   /* feature is purely optional, so most client programs won't even notice */
00062   /* it.                                                                   */
00063   /*                                                                       */
00064   /* I initially thought that it would be a good idea to cache the glyph   */
00065   /* hints too.  However, my general idea now is that if you really need   */
00066   /* to cache these too, you are simply in need of a new font format,      */
00067   /* where all this information could be stored within the font file and   */
00068   /* decoded on the fly.                                                   */
00069   /*                                                                       */
00070   /*************************************************************************/
00071 
00072 
00073 #include <ft2build.h>
00074 #include FT_FREETYPE_H
00075 
00076 
00077 FT_BEGIN_HEADER
00078 
00079 
00080   typedef struct FT_AutoHinterRec_  *FT_AutoHinter;
00081 
00082 
00083   /*************************************************************************/
00084   /*                                                                       */
00085   /* <FuncType>                                                            */
00086   /*    FT_AutoHinter_GlobalGetFunc                                        */
00087   /*                                                                       */
00088   /* <Description>                                                         */
00089   /*    Retrieves the global hints computed for a given face object the    */
00090   /*    resulting data is dissociated from the face and will survive a     */
00091   /*    call to FT_Done_Face().  It must be discarded through the API      */
00092   /*    FT_AutoHinter_GlobalDoneFunc().                                    */
00093   /*                                                                       */
00094   /* <Input>                                                               */
00095   /*    hinter        :: A handle to the source auto-hinter.               */
00096   /*                                                                       */
00097   /*    face          :: A handle to the source face object.               */
00098   /*                                                                       */
00099   /* <Output>                                                              */
00100   /*    global_hints  :: A typeless pointer to the global hints.           */
00101   /*                                                                       */
00102   /*    global_len    :: The size in bytes of the global hints.            */
00103   /*                                                                       */
00104   typedef void
00105   (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter  hinter,
00106                                   FT_Face        face,
00107                                   void**         global_hints,
00108                                   long*          global_len );
00109 
00110 
00111   /*************************************************************************/
00112   /*                                                                       */
00113   /* <FuncType>                                                            */
00114   /*    FT_AutoHinter_GlobalDoneFunc                                       */
00115   /*                                                                       */
00116   /* <Description>                                                         */
00117   /*    Discards the global hints retrieved through                        */
00118   /*    FT_AutoHinter_GlobalGetFunc().  This is the only way these hints   */
00119   /*    are freed from memory.                                             */
00120   /*                                                                       */
00121   /* <Input>                                                               */
00122   /*    hinter :: A handle to the auto-hinter module.                      */
00123   /*                                                                       */
00124   /*    global :: A pointer to retrieved global hints to discard.          */
00125   /*                                                                       */
00126   typedef void
00127   (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter  hinter,
00128                                    void*          global );
00129 
00130 
00131   /*************************************************************************/
00132   /*                                                                       */
00133   /* <FuncType>                                                            */
00134   /*    FT_AutoHinter_GlobalResetFunc                                      */
00135   /*                                                                       */
00136   /* <Description>                                                         */
00137   /*    This function is used to recompute the global metrics in a given   */
00138   /*    font.  This is useful when global font data changes (e.g. Multiple */
00139   /*    Masters fonts where blend coordinates change).                     */
00140   /*                                                                       */
00141   /* <Input>                                                               */
00142   /*    hinter :: A handle to the source auto-hinter.                      */
00143   /*                                                                       */
00144   /*    face   :: A handle to the face.                                    */
00145   /*                                                                       */
00146   typedef void
00147   (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter  hinter,
00148                                     FT_Face        face );
00149 
00150 
00151   /*************************************************************************/
00152   /*                                                                       */
00153   /* <FuncType>                                                            */
00154   /*    FT_AutoHinter_GlyphLoadFunc                                        */
00155   /*                                                                       */
00156   /* <Description>                                                         */
00157   /*    This function is used to load, scale, and automatically hint a     */
00158   /*    glyph from a given face.                                           */
00159   /*                                                                       */
00160   /* <Input>                                                               */
00161   /*    face        :: A handle to the face.                               */
00162   /*                                                                       */
00163   /*    glyph_index :: The glyph index.                                    */
00164   /*                                                                       */
00165   /*    load_flags  :: The load flags.                                     */
00166   /*                                                                       */
00167   /* <Note>                                                                */
00168   /*    This function is capable of loading composite glyphs by hinting    */
00169   /*    each sub-glyph independently (which improves quality).             */
00170   /*                                                                       */
00171   /*    It will call the font driver with FT_Load_Glyph(), with            */
00172   /*    FT_LOAD_NO_SCALE set.                                              */
00173   /*                                                                       */
00174   typedef FT_Error
00175   (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter  hinter,
00176                                   FT_GlyphSlot   slot,
00177                                   FT_Size        size,
00178                                   FT_UInt        glyph_index,
00179                                   FT_Int32       load_flags );
00180 
00181 
00182   /*************************************************************************/
00183   /*                                                                       */
00184   /* <Struct>                                                              */
00185   /*    FT_AutoHinter_ServiceRec                                           */
00186   /*                                                                       */
00187   /* <Description>                                                         */
00188   /*    The auto-hinter module's interface.                                */
00189   /*                                                                       */
00190   typedef struct  FT_AutoHinter_ServiceRec_
00191   {
00192     FT_AutoHinter_GlobalResetFunc  reset_face;
00193     FT_AutoHinter_GlobalGetFunc    get_global_hints;
00194     FT_AutoHinter_GlobalDoneFunc   done_global_hints;
00195     FT_AutoHinter_GlyphLoadFunc    load_glyph;
00196 
00197   } FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service;
00198 
00199 #ifndef FT_CONFIG_OPTION_PIC
00200 
00201 #define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
00202                                      done_global_hints_, load_glyph_)        \
00203   FT_CALLBACK_TABLE_DEF                                                      \
00204   const FT_AutoHinter_ServiceRec class_ =                                    \
00205   {                                                                          \
00206     reset_face_, get_global_hints_, done_global_hints_, load_glyph_          \
00207   };
00208 
00209 #else /* FT_CONFIG_OPTION_PIC */ 
00210 
00211 #define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
00212                                      done_global_hints_, load_glyph_)        \
00213   void                                                                       \
00214   FT_Init_Class_##class_( FT_Library library,                                \
00215                           FT_AutoHinter_ServiceRec* clazz)                   \
00216   {                                                                          \
00217     FT_UNUSED(library);                                                      \
00218     clazz->reset_face = reset_face_;                                         \
00219     clazz->get_global_hints = get_global_hints_;                             \
00220     clazz->done_global_hints = done_global_hints_;                           \
00221     clazz->load_glyph = load_glyph_;                                         \
00222   } 
00223 
00224 #endif /* FT_CONFIG_OPTION_PIC */ 
00225 
00226 FT_END_HEADER
00227 
00228 #endif /* __AUTOHINT_H__ */
00229 
00230 
00231 /* END */

Generated on Tue Jul 5 14:13:38 2011 for ROOT_528-00b_version by  doxygen 1.5.1