vrshoot

diff libs/ft2static/freetype/internal/autohint.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/ft2static/freetype/internal/autohint.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,231 @@
     1.4 +/***************************************************************************/
     1.5 +/*                                                                         */
     1.6 +/*  autohint.h                                                             */
     1.7 +/*                                                                         */
     1.8 +/*    High-level `autohint' module-specific interface (specification).     */
     1.9 +/*                                                                         */
    1.10 +/*  Copyright 1996-2001, 2002, 2007 by                                     */
    1.11 +/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
    1.12 +/*                                                                         */
    1.13 +/*  This file is part of the FreeType project, and may only be used,       */
    1.14 +/*  modified, and distributed under the terms of the FreeType project      */
    1.15 +/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    1.16 +/*  this file you indicate that you have read the license and              */
    1.17 +/*  understand and accept it fully.                                        */
    1.18 +/*                                                                         */
    1.19 +/***************************************************************************/
    1.20 +
    1.21 +
    1.22 +  /*************************************************************************/
    1.23 +  /*                                                                       */
    1.24 +  /* The auto-hinter is used to load and automatically hint glyphs if a    */
    1.25 +  /* format-specific hinter isn't available.                               */
    1.26 +  /*                                                                       */
    1.27 +  /*************************************************************************/
    1.28 +
    1.29 +
    1.30 +#ifndef __AUTOHINT_H__
    1.31 +#define __AUTOHINT_H__
    1.32 +
    1.33 +
    1.34 +  /*************************************************************************/
    1.35 +  /*                                                                       */
    1.36 +  /* A small technical note regarding automatic hinting in order to        */
    1.37 +  /* clarify this module interface.                                        */
    1.38 +  /*                                                                       */
    1.39 +  /* An automatic hinter might compute two kinds of data for a given face: */
    1.40 +  /*                                                                       */
    1.41 +  /* - global hints: Usually some metrics that describe global properties  */
    1.42 +  /*                 of the face.  It is computed by scanning more or less */
    1.43 +  /*                 aggressively the glyphs in the face, and thus can be  */
    1.44 +  /*                 very slow to compute (even if the size of global      */
    1.45 +  /*                 hints is really small).                               */
    1.46 +  /*                                                                       */
    1.47 +  /* - glyph hints:  These describe some important features of the glyph   */
    1.48 +  /*                 outline, as well as how to align them.  They are      */
    1.49 +  /*                 generally much faster to compute than global hints.   */
    1.50 +  /*                                                                       */
    1.51 +  /* The current FreeType auto-hinter does a pretty good job while         */
    1.52 +  /* performing fast computations for both global and glyph hints.         */
    1.53 +  /* However, we might be interested in introducing more complex and       */
    1.54 +  /* powerful algorithms in the future, like the one described in the John */
    1.55 +  /* D. Hobby paper, which unfortunately requires a lot more horsepower.   */
    1.56 +  /*                                                                       */
    1.57 +  /* Because a sufficiently sophisticated font management system would     */
    1.58 +  /* typically implement an LRU cache of opened face objects to reduce     */
    1.59 +  /* memory usage, it is a good idea to be able to avoid recomputing       */
    1.60 +  /* global hints every time the same face is re-opened.                   */
    1.61 +  /*                                                                       */
    1.62 +  /* We thus provide the ability to cache global hints outside of the face */
    1.63 +  /* object, in order to speed up font re-opening time.  Of course, this   */
    1.64 +  /* feature is purely optional, so most client programs won't even notice */
    1.65 +  /* it.                                                                   */
    1.66 +  /*                                                                       */
    1.67 +  /* I initially thought that it would be a good idea to cache the glyph   */
    1.68 +  /* hints too.  However, my general idea now is that if you really need   */
    1.69 +  /* to cache these too, you are simply in need of a new font format,      */
    1.70 +  /* where all this information could be stored within the font file and   */
    1.71 +  /* decoded on the fly.                                                   */
    1.72 +  /*                                                                       */
    1.73 +  /*************************************************************************/
    1.74 +
    1.75 +
    1.76 +#include <ft2build.h>
    1.77 +#include FT_FREETYPE_H
    1.78 +
    1.79 +
    1.80 +FT_BEGIN_HEADER
    1.81 +
    1.82 +
    1.83 +  typedef struct FT_AutoHinterRec_  *FT_AutoHinter;
    1.84 +
    1.85 +
    1.86 +  /*************************************************************************/
    1.87 +  /*                                                                       */
    1.88 +  /* <FuncType>                                                            */
    1.89 +  /*    FT_AutoHinter_GlobalGetFunc                                        */
    1.90 +  /*                                                                       */
    1.91 +  /* <Description>                                                         */
    1.92 +  /*    Retrieves the global hints computed for a given face object the    */
    1.93 +  /*    resulting data is dissociated from the face and will survive a     */
    1.94 +  /*    call to FT_Done_Face().  It must be discarded through the API      */
    1.95 +  /*    FT_AutoHinter_GlobalDoneFunc().                                    */
    1.96 +  /*                                                                       */
    1.97 +  /* <Input>                                                               */
    1.98 +  /*    hinter        :: A handle to the source auto-hinter.               */
    1.99 +  /*                                                                       */
   1.100 +  /*    face          :: A handle to the source face object.               */
   1.101 +  /*                                                                       */
   1.102 +  /* <Output>                                                              */
   1.103 +  /*    global_hints  :: A typeless pointer to the global hints.           */
   1.104 +  /*                                                                       */
   1.105 +  /*    global_len    :: The size in bytes of the global hints.            */
   1.106 +  /*                                                                       */
   1.107 +  typedef void
   1.108 +  (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter  hinter,
   1.109 +                                  FT_Face        face,
   1.110 +                                  void**         global_hints,
   1.111 +                                  long*          global_len );
   1.112 +
   1.113 +
   1.114 +  /*************************************************************************/
   1.115 +  /*                                                                       */
   1.116 +  /* <FuncType>                                                            */
   1.117 +  /*    FT_AutoHinter_GlobalDoneFunc                                       */
   1.118 +  /*                                                                       */
   1.119 +  /* <Description>                                                         */
   1.120 +  /*    Discards the global hints retrieved through                        */
   1.121 +  /*    FT_AutoHinter_GlobalGetFunc().  This is the only way these hints   */
   1.122 +  /*    are freed from memory.                                             */
   1.123 +  /*                                                                       */
   1.124 +  /* <Input>                                                               */
   1.125 +  /*    hinter :: A handle to the auto-hinter module.                      */
   1.126 +  /*                                                                       */
   1.127 +  /*    global :: A pointer to retrieved global hints to discard.          */
   1.128 +  /*                                                                       */
   1.129 +  typedef void
   1.130 +  (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter  hinter,
   1.131 +                                   void*          global );
   1.132 +
   1.133 +
   1.134 +  /*************************************************************************/
   1.135 +  /*                                                                       */
   1.136 +  /* <FuncType>                                                            */
   1.137 +  /*    FT_AutoHinter_GlobalResetFunc                                      */
   1.138 +  /*                                                                       */
   1.139 +  /* <Description>                                                         */
   1.140 +  /*    This function is used to recompute the global metrics in a given   */
   1.141 +  /*    font.  This is useful when global font data changes (e.g. Multiple */
   1.142 +  /*    Masters fonts where blend coordinates change).                     */
   1.143 +  /*                                                                       */
   1.144 +  /* <Input>                                                               */
   1.145 +  /*    hinter :: A handle to the source auto-hinter.                      */
   1.146 +  /*                                                                       */
   1.147 +  /*    face   :: A handle to the face.                                    */
   1.148 +  /*                                                                       */
   1.149 +  typedef void
   1.150 +  (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter  hinter,
   1.151 +                                    FT_Face        face );
   1.152 +
   1.153 +
   1.154 +  /*************************************************************************/
   1.155 +  /*                                                                       */
   1.156 +  /* <FuncType>                                                            */
   1.157 +  /*    FT_AutoHinter_GlyphLoadFunc                                        */
   1.158 +  /*                                                                       */
   1.159 +  /* <Description>                                                         */
   1.160 +  /*    This function is used to load, scale, and automatically hint a     */
   1.161 +  /*    glyph from a given face.                                           */
   1.162 +  /*                                                                       */
   1.163 +  /* <Input>                                                               */
   1.164 +  /*    face        :: A handle to the face.                               */
   1.165 +  /*                                                                       */
   1.166 +  /*    glyph_index :: The glyph index.                                    */
   1.167 +  /*                                                                       */
   1.168 +  /*    load_flags  :: The load flags.                                     */
   1.169 +  /*                                                                       */
   1.170 +  /* <Note>                                                                */
   1.171 +  /*    This function is capable of loading composite glyphs by hinting    */
   1.172 +  /*    each sub-glyph independently (which improves quality).             */
   1.173 +  /*                                                                       */
   1.174 +  /*    It will call the font driver with FT_Load_Glyph(), with            */
   1.175 +  /*    FT_LOAD_NO_SCALE set.                                              */
   1.176 +  /*                                                                       */
   1.177 +  typedef FT_Error
   1.178 +  (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter  hinter,
   1.179 +                                  FT_GlyphSlot   slot,
   1.180 +                                  FT_Size        size,
   1.181 +                                  FT_UInt        glyph_index,
   1.182 +                                  FT_Int32       load_flags );
   1.183 +
   1.184 +
   1.185 +  /*************************************************************************/
   1.186 +  /*                                                                       */
   1.187 +  /* <Struct>                                                              */
   1.188 +  /*    FT_AutoHinter_ServiceRec                                           */
   1.189 +  /*                                                                       */
   1.190 +  /* <Description>                                                         */
   1.191 +  /*    The auto-hinter module's interface.                                */
   1.192 +  /*                                                                       */
   1.193 +  typedef struct  FT_AutoHinter_ServiceRec_
   1.194 +  {
   1.195 +    FT_AutoHinter_GlobalResetFunc  reset_face;
   1.196 +    FT_AutoHinter_GlobalGetFunc    get_global_hints;
   1.197 +    FT_AutoHinter_GlobalDoneFunc   done_global_hints;
   1.198 +    FT_AutoHinter_GlyphLoadFunc    load_glyph;
   1.199 +
   1.200 +  } FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service;
   1.201 +
   1.202 +#ifndef FT_CONFIG_OPTION_PIC
   1.203 +
   1.204 +#define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
   1.205 +                                     done_global_hints_, load_glyph_)        \
   1.206 +  FT_CALLBACK_TABLE_DEF                                                      \
   1.207 +  const FT_AutoHinter_ServiceRec class_ =                                    \
   1.208 +  {                                                                          \
   1.209 +    reset_face_, get_global_hints_, done_global_hints_, load_glyph_          \
   1.210 +  };
   1.211 +
   1.212 +#else /* FT_CONFIG_OPTION_PIC */ 
   1.213 +
   1.214 +#define FT_DEFINE_AUTOHINTER_SERVICE(class_, reset_face_, get_global_hints_, \
   1.215 +                                     done_global_hints_, load_glyph_)        \
   1.216 +  void                                                                       \
   1.217 +  FT_Init_Class_##class_( FT_Library library,                                \
   1.218 +                          FT_AutoHinter_ServiceRec* clazz)                   \
   1.219 +  {                                                                          \
   1.220 +    FT_UNUSED(library);                                                      \
   1.221 +    clazz->reset_face = reset_face_;                                         \
   1.222 +    clazz->get_global_hints = get_global_hints_;                             \
   1.223 +    clazz->done_global_hints = done_global_hints_;                           \
   1.224 +    clazz->load_glyph = load_glyph_;                                         \
   1.225 +  } 
   1.226 +
   1.227 +#endif /* FT_CONFIG_OPTION_PIC */ 
   1.228 +
   1.229 +FT_END_HEADER
   1.230 +
   1.231 +#endif /* __AUTOHINT_H__ */
   1.232 +
   1.233 +
   1.234 +/* END */