autohint.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:12k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*  autohint.h                                                             */
  4. /*                                                                         */
  5. /*    High-level `autohint' module-specific interface (specification).     */
  6. /*                                                                         */
  7. /*  Copyright 1996-2001, 2002, 2007 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.   /* The auto-hinter is used to load and automatically hint glyphs if a    */
  20.   /* format-specific hinter isn't available.                               */
  21.   /*                                                                       */
  22.   /*************************************************************************/
  23. #ifndef __AUTOHINT_H__
  24. #define __AUTOHINT_H__
  25.   /*************************************************************************/
  26.   /*                                                                       */
  27.   /* A small technical note regarding automatic hinting in order to        */
  28.   /* clarify this module interface.                                        */
  29.   /*                                                                       */
  30.   /* An automatic hinter might compute two kinds of data for a given face: */
  31.   /*                                                                       */
  32.   /* - global hints: Usually some metrics that describe global properties  */
  33.   /*                 of the face.  It is computed by scanning more or less */
  34.   /*                 aggressively the glyphs in the face, and thus can be  */
  35.   /*                 very slow to compute (even if the size of global      */
  36.   /*                 hints is really small).                               */
  37.   /*                                                                       */
  38.   /* - glyph hints:  These describe some important features of the glyph   */
  39.   /*                 outline, as well as how to align them.  They are      */
  40.   /*                 generally much faster to compute than global hints.   */
  41.   /*                                                                       */
  42.   /* The current FreeType auto-hinter does a pretty good job while         */
  43.   /* performing fast computations for both global and glyph hints.         */
  44.   /* However, we might be interested in introducing more complex and       */
  45.   /* powerful algorithms in the future, like the one described in the John */
  46.   /* D. Hobby paper, which unfortunately requires a lot more horsepower.   */
  47.   /*                                                                       */
  48.   /* Because a sufficiently sophisticated font management system would     */
  49.   /* typically implement an LRU cache of opened face objects to reduce     */
  50.   /* memory usage, it is a good idea to be able to avoid recomputing       */
  51.   /* global hints every time the same face is re-opened.                   */
  52.   /*                                                                       */
  53.   /* We thus provide the ability to cache global hints outside of the face */
  54.   /* object, in order to speed up font re-opening time.  Of course, this   */
  55.   /* feature is purely optional, so most client programs won't even notice */
  56.   /* it.                                                                   */
  57.   /*                                                                       */
  58.   /* I initially thought that it would be a good idea to cache the glyph   */
  59.   /* hints too.  However, my general idea now is that if you really need   */
  60.   /* to cache these too, you are simply in need of a new font format,      */
  61.   /* where all this information could be stored within the font file and   */
  62.   /* decoded on the fly.                                                   */
  63.   /*                                                                       */
  64.   /*************************************************************************/
  65. #include <ft2build.h>
  66. #include FT_FREETYPE_H
  67. FT_BEGIN_HEADER
  68.   typedef struct FT_AutoHinterRec_  *FT_AutoHinter;
  69.   /*************************************************************************/
  70.   /*                                                                       */
  71.   /* <FuncType>                                                            */
  72.   /*    FT_AutoHinter_GlobalGetFunc                                        */
  73.   /*                                                                       */
  74.   /* <Description>                                                         */
  75.   /*    Retrieves the global hints computed for a given face object the    */
  76.   /*    resulting data is dissociated from the face and will survive a     */
  77.   /*    call to FT_Done_Face().  It must be discarded through the API      */
  78.   /*    FT_AutoHinter_GlobalDoneFunc().                                    */
  79.   /*                                                                       */
  80.   /* <Input>                                                               */
  81.   /*    hinter        :: A handle to the source auto-hinter.               */
  82.   /*                                                                       */
  83.   /*    face          :: A handle to the source face object.               */
  84.   /*                                                                       */
  85.   /* <Output>                                                              */
  86.   /*    global_hints  :: A typeless pointer to the global hints.           */
  87.   /*                                                                       */
  88.   /*    global_len    :: The size in bytes of the global hints.            */
  89.   /*                                                                       */
  90.   typedef void
  91.   (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter  hinter,
  92.                                   FT_Face        face,
  93.                                   void**         global_hints,
  94.                                   long*          global_len );
  95.   /*************************************************************************/
  96.   /*                                                                       */
  97.   /* <FuncType>                                                            */
  98.   /*    FT_AutoHinter_GlobalDoneFunc                                       */
  99.   /*                                                                       */
  100.   /* <Description>                                                         */
  101.   /*    Discards the global hints retrieved through                        */
  102.   /*    FT_AutoHinter_GlobalGetFunc().  This is the only way these hints   */
  103.   /*    are freed from memory.                                             */
  104.   /*                                                                       */
  105.   /* <Input>                                                               */
  106.   /*    hinter :: A handle to the auto-hinter module.                      */
  107.   /*                                                                       */
  108.   /*    global :: A pointer to retrieved global hints to discard.          */
  109.   /*                                                                       */
  110.   typedef void
  111.   (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter  hinter,
  112.                                    void*          global );
  113.   /*************************************************************************/
  114.   /*                                                                       */
  115.   /* <FuncType>                                                            */
  116.   /*    FT_AutoHinter_GlobalResetFunc                                      */
  117.   /*                                                                       */
  118.   /* <Description>                                                         */
  119.   /*    This function is used to recompute the global metrics in a given   */
  120.   /*    font.  This is useful when global font data changes (e.g. Multiple */
  121.   /*    Masters fonts where blend coordinates change).                     */
  122.   /*                                                                       */
  123.   /* <Input>                                                               */
  124.   /*    hinter :: A handle to the source auto-hinter.                      */
  125.   /*                                                                       */
  126.   /*    face   :: A handle to the face.                                    */
  127.   /*                                                                       */
  128.   typedef void
  129.   (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter  hinter,
  130.                                     FT_Face        face );
  131.   /*************************************************************************/
  132.   /*                                                                       */
  133.   /* <FuncType>                                                            */
  134.   /*    FT_AutoHinter_GlyphLoadFunc                                        */
  135.   /*                                                                       */
  136.   /* <Description>                                                         */
  137.   /*    This function is used to load, scale, and automatically hint a     */
  138.   /*    glyph from a given face.                                           */
  139.   /*                                                                       */
  140.   /* <Input>                                                               */
  141.   /*    face        :: A handle to the face.                               */
  142.   /*                                                                       */
  143.   /*    glyph_index :: The glyph index.                                    */
  144.   /*                                                                       */
  145.   /*    load_flags  :: The load flags.                                     */
  146.   /*                                                                       */
  147.   /* <Note>                                                                */
  148.   /*    This function is capable of loading composite glyphs by hinting    */
  149.   /*    each sub-glyph independently (which improves quality).             */
  150.   /*                                                                       */
  151.   /*    It will call the font driver with FT_Load_Glyph(), with            */
  152.   /*    FT_LOAD_NO_SCALE set.                                              */
  153.   /*                                                                       */
  154.   typedef FT_Error
  155.   (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter  hinter,
  156.                                   FT_GlyphSlot   slot,
  157.                                   FT_Size        size,
  158.                                   FT_UInt        glyph_index,
  159.                                   FT_Int32       load_flags );
  160.   /*************************************************************************/
  161.   /*                                                                       */
  162.   /* <Struct>                                                              */
  163.   /*    FT_AutoHinter_ServiceRec                                           */
  164.   /*                                                                       */
  165.   /* <Description>                                                         */
  166.   /*    The auto-hinter module's interface.                                */
  167.   /*                                                                       */
  168.   typedef struct  FT_AutoHinter_ServiceRec_
  169.   {
  170.     FT_AutoHinter_GlobalResetFunc  reset_face;
  171.     FT_AutoHinter_GlobalGetFunc    get_global_hints;
  172.     FT_AutoHinter_GlobalDoneFunc   done_global_hints;
  173.     FT_AutoHinter_GlyphLoadFunc    load_glyph;
  174.   } FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service;
  175. FT_END_HEADER
  176. #endif /* __AUTOHINT_H__ */
  177. /* END */