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