src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h
changeset 54876 da3834261f0c
parent 49234 3375a8039fde
equal deleted inserted replaced
54875:bcfedddcf4ce 54876:da3834261f0c
     1 /***************************************************************************/
     1 /****************************************************************************
     2 /*                                                                         */
     2  *
     3 /*  ftglyph.h                                                              */
     3  * ftglyph.h
     4 /*                                                                         */
     4  *
     5 /*    FreeType convenience functions to handle glyphs (specification).     */
     5  *   FreeType convenience functions to handle glyphs (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   /* This file contains the definition of several convenience functions    */
    21    * This file contains the definition of several convenience functions that
    22   /* that can be used by client applications to easily retrieve glyph      */
    22    * can be used by client applications to easily retrieve glyph bitmaps and
    23   /* bitmaps and outlines from a given face.                               */
    23    * outlines from a given face.
    24   /*                                                                       */
    24    *
    25   /* These functions should be optional if you are writing a font server   */
    25    * These functions should be optional if you are writing a font server or
    26   /* or text layout engine on top of FreeType.  However, they are pretty   */
    26    * text layout engine on top of FreeType.  However, they are pretty handy
    27   /* handy for many other simple uses of the library.                      */
    27    * for many other simple uses of the library.
    28   /*                                                                       */
    28    *
    29   /*************************************************************************/
    29    */
    30 
    30 
    31 
    31 
    32 #ifndef FTGLYPH_H_
    32 #ifndef FTGLYPH_H_
    33 #define FTGLYPH_H_
    33 #define FTGLYPH_H_
    34 
    34 
    44 
    44 
    45 
    45 
    46 FT_BEGIN_HEADER
    46 FT_BEGIN_HEADER
    47 
    47 
    48 
    48 
    49   /*************************************************************************/
    49   /**************************************************************************
    50   /*                                                                       */
    50    *
    51   /* <Section>                                                             */
    51    * @section:
    52   /*    glyph_management                                                   */
    52    *   glyph_management
    53   /*                                                                       */
    53    *
    54   /* <Title>                                                               */
    54    * @title:
    55   /*    Glyph Management                                                   */
    55    *   Glyph Management
    56   /*                                                                       */
    56    *
    57   /* <Abstract>                                                            */
    57    * @abstract:
    58   /*    Generic interface to manage individual glyph data.                 */
    58    *   Generic interface to manage individual glyph data.
    59   /*                                                                       */
    59    *
    60   /* <Description>                                                         */
    60    * @description:
    61   /*    This section contains definitions used to manage glyph data        */
    61    *   This section contains definitions used to manage glyph data through
    62   /*    through generic FT_Glyph objects.  Each of them can contain a      */
    62    *   generic @FT_Glyph objects.  Each of them can contain a bitmap,
    63   /*    bitmap, a vector outline, or even images in other formats.         */
    63    *   a vector outline, or even images in other formats.  These objects are
    64   /*                                                                       */
    64    *   detached from @FT_Face, contrary to @FT_GlyphSlot.
    65   /*************************************************************************/
    65    *
       
    66    */
    66 
    67 
    67 
    68 
    68   /* forward declaration to a private type */
    69   /* forward declaration to a private type */
    69   typedef struct FT_Glyph_Class_  FT_Glyph_Class;
    70   typedef struct FT_Glyph_Class_  FT_Glyph_Class;
    70 
    71 
    71 
    72 
    72   /*************************************************************************/
    73   /**************************************************************************
    73   /*                                                                       */
    74    *
    74   /* <Type>                                                                */
    75    * @type:
    75   /*    FT_Glyph                                                           */
    76    *   FT_Glyph
    76   /*                                                                       */
    77    *
    77   /* <Description>                                                         */
    78    * @description:
    78   /*    Handle to an object used to model generic glyph images.  It is a   */
    79    *   Handle to an object used to model generic glyph images.  It is a
    79   /*    pointer to the @FT_GlyphRec structure and can contain a glyph      */
    80    *   pointer to the @FT_GlyphRec structure and can contain a glyph bitmap
    80   /*    bitmap or pointer.                                                 */
    81    *   or pointer.
    81   /*                                                                       */
    82    *
    82   /* <Note>                                                                */
    83    * @note:
    83   /*    Glyph objects are not owned by the library.  You must thus release */
    84    *   Glyph objects are not owned by the library.  You must thus release
    84   /*    them manually (through @FT_Done_Glyph) _before_ calling            */
    85    *   them manually (through @FT_Done_Glyph) _before_ calling
    85   /*    @FT_Done_FreeType.                                                 */
    86    *   @FT_Done_FreeType.
    86   /*                                                                       */
    87    */
    87   typedef struct FT_GlyphRec_*  FT_Glyph;
    88   typedef struct FT_GlyphRec_*  FT_Glyph;
    88 
    89 
    89 
    90 
    90   /*************************************************************************/
    91   /**************************************************************************
    91   /*                                                                       */
    92    *
    92   /* <Struct>                                                              */
    93    * @struct:
    93   /*    FT_GlyphRec                                                        */
    94    *   FT_GlyphRec
    94   /*                                                                       */
    95    *
    95   /* <Description>                                                         */
    96    * @description:
    96   /*    The root glyph structure contains a given glyph image plus its     */
    97    *   The root glyph structure contains a given glyph image plus its advance
    97   /*    advance width in 16.16 fixed-point format.                         */
    98    *   width in 16.16 fixed-point format.
    98   /*                                                                       */
    99    *
    99   /* <Fields>                                                              */
   100    * @fields:
   100   /*    library :: A handle to the FreeType library object.                */
   101    *   library ::
   101   /*                                                                       */
   102    *     A handle to the FreeType library object.
   102   /*    clazz   :: A pointer to the glyph's class.  Private.               */
   103    *
   103   /*                                                                       */
   104    *   clazz ::
   104   /*    format  :: The format of the glyph's image.                        */
   105    *     A pointer to the glyph's class.  Private.
   105   /*                                                                       */
   106    *
   106   /*    advance :: A 16.16 vector that gives the glyph's advance width.    */
   107    *   format ::
   107   /*                                                                       */
   108    *     The format of the glyph's image.
       
   109    *
       
   110    *   advance ::
       
   111    *     A 16.16 vector that gives the glyph's advance width.
       
   112    */
   108   typedef struct  FT_GlyphRec_
   113   typedef struct  FT_GlyphRec_
   109   {
   114   {
   110     FT_Library             library;
   115     FT_Library             library;
   111     const FT_Glyph_Class*  clazz;
   116     const FT_Glyph_Class*  clazz;
   112     FT_Glyph_Format        format;
   117     FT_Glyph_Format        format;
   113     FT_Vector              advance;
   118     FT_Vector              advance;
   114 
   119 
   115   } FT_GlyphRec;
   120   } FT_GlyphRec;
   116 
   121 
   117 
   122 
   118   /*************************************************************************/
   123   /**************************************************************************
   119   /*                                                                       */
   124    *
   120   /* <Type>                                                                */
   125    * @type:
   121   /*    FT_BitmapGlyph                                                     */
   126    *   FT_BitmapGlyph
   122   /*                                                                       */
   127    *
   123   /* <Description>                                                         */
   128    * @description:
   124   /*    A handle to an object used to model a bitmap glyph image.  This is */
   129    *   A handle to an object used to model a bitmap glyph image.  This is a
   125   /*    a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec.     */
   130    *   sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec.
   126   /*                                                                       */
   131    */
   127   typedef struct FT_BitmapGlyphRec_*  FT_BitmapGlyph;
   132   typedef struct FT_BitmapGlyphRec_*  FT_BitmapGlyph;
   128 
   133 
   129 
   134 
   130   /*************************************************************************/
   135   /**************************************************************************
   131   /*                                                                       */
   136    *
   132   /* <Struct>                                                              */
   137    * @struct:
   133   /*    FT_BitmapGlyphRec                                                  */
   138    *   FT_BitmapGlyphRec
   134   /*                                                                       */
   139    *
   135   /* <Description>                                                         */
   140    * @description:
   136   /*    A structure used for bitmap glyph images.  This really is a        */
   141    *   A structure used for bitmap glyph images.  This really is a
   137   /*    `sub-class' of @FT_GlyphRec.                                       */
   142    *   'sub-class' of @FT_GlyphRec.
   138   /*                                                                       */
   143    *
   139   /* <Fields>                                                              */
   144    * @fields:
   140   /*    root   :: The root @FT_Glyph fields.                               */
   145    *   root ::
   141   /*                                                                       */
   146    *     The root @FT_Glyph fields.
   142   /*    left   :: The left-side bearing, i.e., the horizontal distance     */
   147    *
   143   /*              from the current pen position to the left border of the  */
   148    *   left ::
   144   /*              glyph bitmap.                                            */
   149    *     The left-side bearing, i.e., the horizontal distance from the
   145   /*                                                                       */
   150    *     current pen position to the left border of the glyph bitmap.
   146   /*    top    :: The top-side bearing, i.e., the vertical distance from   */
   151    *
   147   /*              the current pen position to the top border of the glyph  */
   152    *   top ::
   148   /*              bitmap.  This distance is positive for upwards~y!        */
   153    *     The top-side bearing, i.e., the vertical distance from the current
   149   /*                                                                       */
   154    *     pen position to the top border of the glyph bitmap.  This distance
   150   /*    bitmap :: A descriptor for the bitmap.                             */
   155    *     is positive for upwards~y!
   151   /*                                                                       */
   156    *
   152   /* <Note>                                                                */
   157    *   bitmap ::
   153   /*    You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have       */
   158    *     A descriptor for the bitmap.
   154   /*    `glyph->format == FT_GLYPH_FORMAT_BITMAP'.  This lets you access   */
   159    *
   155   /*    the bitmap's contents easily.                                      */
   160    * @note:
   156   /*                                                                       */
   161    *   You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have
   157   /*    The corresponding pixel buffer is always owned by @FT_BitmapGlyph  */
   162    *   `glyph->format == FT_GLYPH_FORMAT_BITMAP`.  This lets you access the
   158   /*    and is thus created and destroyed with it.                         */
   163    *   bitmap's contents easily.
   159   /*                                                                       */
   164    *
       
   165    *   The corresponding pixel buffer is always owned by @FT_BitmapGlyph and
       
   166    *   is thus created and destroyed with it.
       
   167    */
   160   typedef struct  FT_BitmapGlyphRec_
   168   typedef struct  FT_BitmapGlyphRec_
   161   {
   169   {
   162     FT_GlyphRec  root;
   170     FT_GlyphRec  root;
   163     FT_Int       left;
   171     FT_Int       left;
   164     FT_Int       top;
   172     FT_Int       top;
   165     FT_Bitmap    bitmap;
   173     FT_Bitmap    bitmap;
   166 
   174 
   167   } FT_BitmapGlyphRec;
   175   } FT_BitmapGlyphRec;
   168 
   176 
   169 
   177 
   170   /*************************************************************************/
   178   /**************************************************************************
   171   /*                                                                       */
   179    *
   172   /* <Type>                                                                */
   180    * @type:
   173   /*    FT_OutlineGlyph                                                    */
   181    *   FT_OutlineGlyph
   174   /*                                                                       */
   182    *
   175   /* <Description>                                                         */
   183    * @description:
   176   /*    A handle to an object used to model an outline glyph image.  This  */
   184    *   A handle to an object used to model an outline glyph image.  This is a
   177   /*    is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */
   185    *   sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec.
   178   /*                                                                       */
   186    */
   179   typedef struct FT_OutlineGlyphRec_*  FT_OutlineGlyph;
   187   typedef struct FT_OutlineGlyphRec_*  FT_OutlineGlyph;
   180 
   188 
   181 
   189 
   182   /*************************************************************************/
   190   /**************************************************************************
   183   /*                                                                       */
   191    *
   184   /* <Struct>                                                              */
   192    * @struct:
   185   /*    FT_OutlineGlyphRec                                                 */
   193    *   FT_OutlineGlyphRec
   186   /*                                                                       */
   194    *
   187   /* <Description>                                                         */
   195    * @description:
   188   /*    A structure used for outline (vectorial) glyph images.  This       */
   196    *   A structure used for outline (vectorial) glyph images.  This really is
   189   /*    really is a `sub-class' of @FT_GlyphRec.                           */
   197    *   a 'sub-class' of @FT_GlyphRec.
   190   /*                                                                       */
   198    *
   191   /* <Fields>                                                              */
   199    * @fields:
   192   /*    root    :: The root @FT_Glyph fields.                              */
   200    *   root ::
   193   /*                                                                       */
   201    *     The root @FT_Glyph fields.
   194   /*    outline :: A descriptor for the outline.                           */
   202    *
   195   /*                                                                       */
   203    *   outline ::
   196   /* <Note>                                                                */
   204    *     A descriptor for the outline.
   197   /*    You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have      */
   205    *
   198   /*    `glyph->format == FT_GLYPH_FORMAT_OUTLINE'.  This lets you access  */
   206    * @note:
   199   /*    the outline's content easily.                                      */
   207    *   You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have
   200   /*                                                                       */
   208    *   `glyph->format == FT_GLYPH_FORMAT_OUTLINE`.  This lets you access the
   201   /*    As the outline is extracted from a glyph slot, its coordinates are */
   209    *   outline's content easily.
   202   /*    expressed normally in 26.6 pixels, unless the flag                 */
   210    *
   203   /*    @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */
   211    *   As the outline is extracted from a glyph slot, its coordinates are
   204   /*                                                                       */
   212    *   expressed normally in 26.6 pixels, unless the flag @FT_LOAD_NO_SCALE
   205   /*    The outline's tables are always owned by the object and are        */
   213    *   was used in @FT_Load_Glyph() or @FT_Load_Char().
   206   /*    destroyed with it.                                                 */
   214    *
   207   /*                                                                       */
   215    *   The outline's tables are always owned by the object and are destroyed
       
   216    *   with it.
       
   217    */
   208   typedef struct  FT_OutlineGlyphRec_
   218   typedef struct  FT_OutlineGlyphRec_
   209   {
   219   {
   210     FT_GlyphRec  root;
   220     FT_GlyphRec  root;
   211     FT_Outline   outline;
   221     FT_Outline   outline;
   212 
   222 
   213   } FT_OutlineGlyphRec;
   223   } FT_OutlineGlyphRec;
   214 
   224 
   215 
   225 
   216   /*************************************************************************/
   226   /**************************************************************************
   217   /*                                                                       */
   227    *
   218   /* <Function>                                                            */
   228    * @function:
   219   /*    FT_Get_Glyph                                                       */
   229    *   FT_New_Glyph
   220   /*                                                                       */
   230    *
   221   /* <Description>                                                         */
   231    * @description:
   222   /*    A function used to extract a glyph image from a slot.  Note that   */
   232    *   A function used to create a new empty glyph image.  Note that the
   223   /*    the created @FT_Glyph object must be released with @FT_Done_Glyph. */
   233    *   created @FT_Glyph object must be released with @FT_Done_Glyph.
   224   /*                                                                       */
   234    *
   225   /* <Input>                                                               */
   235    * @input:
   226   /*    slot   :: A handle to the source glyph slot.                       */
   236    *   library ::
   227   /*                                                                       */
   237    *     A handle to the FreeType library object.
   228   /* <Output>                                                              */
   238    *
   229   /*    aglyph :: A handle to the glyph object.                            */
   239    *   format ::
   230   /*                                                                       */
   240    *     The format of the glyph's image.
   231   /* <Return>                                                              */
   241    *
   232   /*    FreeType error code.  0~means success.                             */
   242    * @output:
   233   /*                                                                       */
   243    *   aglyph ::
   234   /* <Note>                                                                */
   244    *     A handle to the glyph object.
   235   /*    Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16    */
   245    *
   236   /*    fixed-point numbers, `slot->advance.x' and `slot->advance.y'       */
   246    * @return:
   237   /*    (which are in 26.6 fixed-point format) must be in the range        */
   247    *   FreeType error code.  0~means success.
   238   /*    ]-32768;32768[.                                                    */
   248    *
   239   /*                                                                       */
   249    * @since:
       
   250    *   2.10
       
   251    */
       
   252   FT_EXPORT( FT_Error )
       
   253   FT_New_Glyph( FT_Library       library,
       
   254                 FT_Glyph_Format  format,
       
   255                 FT_Glyph         *aglyph );
       
   256 
       
   257 
       
   258   /**************************************************************************
       
   259    *
       
   260    * @function:
       
   261    *   FT_Get_Glyph
       
   262    *
       
   263    * @description:
       
   264    *   A function used to extract a glyph image from a slot.  Note that the
       
   265    *   created @FT_Glyph object must be released with @FT_Done_Glyph.
       
   266    *
       
   267    * @input:
       
   268    *   slot ::
       
   269    *     A handle to the source glyph slot.
       
   270    *
       
   271    * @output:
       
   272    *   aglyph ::
       
   273    *     A handle to the glyph object.
       
   274    *
       
   275    * @return:
       
   276    *   FreeType error code.  0~means success.
       
   277    *
       
   278    * @note:
       
   279    *   Because `*aglyph->advance.x` and `*aglyph->advance.y` are 16.16
       
   280    *   fixed-point numbers, `slot->advance.x` and `slot->advance.y` (which
       
   281    *   are in 26.6 fixed-point format) must be in the range ]-32768;32768[.
       
   282    */
   240   FT_EXPORT( FT_Error )
   283   FT_EXPORT( FT_Error )
   241   FT_Get_Glyph( FT_GlyphSlot  slot,
   284   FT_Get_Glyph( FT_GlyphSlot  slot,
   242                 FT_Glyph     *aglyph );
   285                 FT_Glyph     *aglyph );
   243 
   286 
   244 
   287 
   245   /*************************************************************************/
   288   /**************************************************************************
   246   /*                                                                       */
   289    *
   247   /* <Function>                                                            */
   290    * @function:
   248   /*    FT_Glyph_Copy                                                      */
   291    *   FT_Glyph_Copy
   249   /*                                                                       */
   292    *
   250   /* <Description>                                                         */
   293    * @description:
   251   /*    A function used to copy a glyph image.  Note that the created      */
   294    *   A function used to copy a glyph image.  Note that the created
   252   /*    @FT_Glyph object must be released with @FT_Done_Glyph.             */
   295    *   @FT_Glyph object must be released with @FT_Done_Glyph.
   253   /*                                                                       */
   296    *
   254   /* <Input>                                                               */
   297    * @input:
   255   /*    source :: A handle to the source glyph object.                     */
   298    *   source ::
   256   /*                                                                       */
   299    *     A handle to the source glyph object.
   257   /* <Output>                                                              */
   300    *
   258   /*    target :: A handle to the target glyph object.  0~in case of       */
   301    * @output:
   259   /*              error.                                                   */
   302    *   target ::
   260   /*                                                                       */
   303    *     A handle to the target glyph object.  0~in case of error.
   261   /* <Return>                                                              */
   304    *
   262   /*    FreeType error code.  0~means success.                             */
   305    * @return:
   263   /*                                                                       */
   306    *   FreeType error code.  0~means success.
       
   307    */
   264   FT_EXPORT( FT_Error )
   308   FT_EXPORT( FT_Error )
   265   FT_Glyph_Copy( FT_Glyph   source,
   309   FT_Glyph_Copy( FT_Glyph   source,
   266                  FT_Glyph  *target );
   310                  FT_Glyph  *target );
   267 
   311 
   268 
   312 
   269   /*************************************************************************/
   313   /**************************************************************************
   270   /*                                                                       */
   314    *
   271   /* <Function>                                                            */
   315    * @function:
   272   /*    FT_Glyph_Transform                                                 */
   316    *   FT_Glyph_Transform
   273   /*                                                                       */
   317    *
   274   /* <Description>                                                         */
   318    * @description:
   275   /*    Transform a glyph image if its format is scalable.                 */
   319    *   Transform a glyph image if its format is scalable.
   276   /*                                                                       */
   320    *
   277   /* <InOut>                                                               */
   321    * @inout:
   278   /*    glyph  :: A handle to the target glyph object.                     */
   322    *   glyph ::
   279   /*                                                                       */
   323    *     A handle to the target glyph object.
   280   /* <Input>                                                               */
   324    *
   281   /*    matrix :: A pointer to a 2x2 matrix to apply.                      */
   325    * @input:
   282   /*                                                                       */
   326    *   matrix ::
   283   /*    delta  :: A pointer to a 2d vector to apply.  Coordinates are      */
   327    *     A pointer to a 2x2 matrix to apply.
   284   /*              expressed in 1/64th of a pixel.                          */
   328    *
   285   /*                                                                       */
   329    *   delta ::
   286   /* <Return>                                                              */
   330    *     A pointer to a 2d vector to apply.  Coordinates are expressed in
   287   /*    FreeType error code (if not 0, the glyph format is not scalable).  */
   331    *     1/64th of a pixel.
   288   /*                                                                       */
   332    *
   289   /* <Note>                                                                */
   333    * @return:
   290   /*    The 2x2 transformation matrix is also applied to the glyph's       */
   334    *   FreeType error code (if not 0, the glyph format is not scalable).
   291   /*    advance vector.                                                    */
   335    *
   292   /*                                                                       */
   336    * @note:
       
   337    *   The 2x2 transformation matrix is also applied to the glyph's advance
       
   338    *   vector.
       
   339    */
   293   FT_EXPORT( FT_Error )
   340   FT_EXPORT( FT_Error )
   294   FT_Glyph_Transform( FT_Glyph    glyph,
   341   FT_Glyph_Transform( FT_Glyph    glyph,
   295                       FT_Matrix*  matrix,
   342                       FT_Matrix*  matrix,
   296                       FT_Vector*  delta );
   343                       FT_Vector*  delta );
   297 
   344 
   298 
   345 
   299   /*************************************************************************/
   346   /**************************************************************************
   300   /*                                                                       */
   347    *
   301   /* <Enum>                                                                */
   348    * @enum:
   302   /*    FT_Glyph_BBox_Mode                                                 */
   349    *   FT_Glyph_BBox_Mode
   303   /*                                                                       */
   350    *
   304   /* <Description>                                                         */
   351    * @description:
   305   /*    The mode how the values of @FT_Glyph_Get_CBox are returned.        */
   352    *   The mode how the values of @FT_Glyph_Get_CBox are returned.
   306   /*                                                                       */
   353    *
   307   /* <Values>                                                              */
   354    * @values:
   308   /*    FT_GLYPH_BBOX_UNSCALED ::                                          */
   355    *   FT_GLYPH_BBOX_UNSCALED ::
   309   /*      Return unscaled font units.                                      */
   356    *     Return unscaled font units.
   310   /*                                                                       */
   357    *
   311   /*    FT_GLYPH_BBOX_SUBPIXELS ::                                         */
   358    *   FT_GLYPH_BBOX_SUBPIXELS ::
   312   /*      Return unfitted 26.6 coordinates.                                */
   359    *     Return unfitted 26.6 coordinates.
   313   /*                                                                       */
   360    *
   314   /*    FT_GLYPH_BBOX_GRIDFIT ::                                           */
   361    *   FT_GLYPH_BBOX_GRIDFIT ::
   315   /*      Return grid-fitted 26.6 coordinates.                             */
   362    *     Return grid-fitted 26.6 coordinates.
   316   /*                                                                       */
   363    *
   317   /*    FT_GLYPH_BBOX_TRUNCATE ::                                          */
   364    *   FT_GLYPH_BBOX_TRUNCATE ::
   318   /*      Return coordinates in integer pixels.                            */
   365    *     Return coordinates in integer pixels.
   319   /*                                                                       */
   366    *
   320   /*    FT_GLYPH_BBOX_PIXELS ::                                            */
   367    *   FT_GLYPH_BBOX_PIXELS ::
   321   /*      Return grid-fitted pixel coordinates.                            */
   368    *     Return grid-fitted pixel coordinates.
   322   /*                                                                       */
   369    */
   323   typedef enum  FT_Glyph_BBox_Mode_
   370   typedef enum  FT_Glyph_BBox_Mode_
   324   {
   371   {
   325     FT_GLYPH_BBOX_UNSCALED  = 0,
   372     FT_GLYPH_BBOX_UNSCALED  = 0,
   326     FT_GLYPH_BBOX_SUBPIXELS = 0,
   373     FT_GLYPH_BBOX_SUBPIXELS = 0,
   327     FT_GLYPH_BBOX_GRIDFIT   = 1,
   374     FT_GLYPH_BBOX_GRIDFIT   = 1,
   330 
   377 
   331   } FT_Glyph_BBox_Mode;
   378   } FT_Glyph_BBox_Mode;
   332 
   379 
   333 
   380 
   334   /* these constants are deprecated; use the corresponding */
   381   /* these constants are deprecated; use the corresponding */
   335   /* `FT_Glyph_BBox_Mode' values instead                   */
   382   /* `FT_Glyph_BBox_Mode` values instead                   */
   336 #define ft_glyph_bbox_unscaled   FT_GLYPH_BBOX_UNSCALED
   383 #define ft_glyph_bbox_unscaled   FT_GLYPH_BBOX_UNSCALED
   337 #define ft_glyph_bbox_subpixels  FT_GLYPH_BBOX_SUBPIXELS
   384 #define ft_glyph_bbox_subpixels  FT_GLYPH_BBOX_SUBPIXELS
   338 #define ft_glyph_bbox_gridfit    FT_GLYPH_BBOX_GRIDFIT
   385 #define ft_glyph_bbox_gridfit    FT_GLYPH_BBOX_GRIDFIT
   339 #define ft_glyph_bbox_truncate   FT_GLYPH_BBOX_TRUNCATE
   386 #define ft_glyph_bbox_truncate   FT_GLYPH_BBOX_TRUNCATE
   340 #define ft_glyph_bbox_pixels     FT_GLYPH_BBOX_PIXELS
   387 #define ft_glyph_bbox_pixels     FT_GLYPH_BBOX_PIXELS
   341 
   388 
   342 
   389 
   343   /*************************************************************************/
   390   /**************************************************************************
   344   /*                                                                       */
   391    *
   345   /* <Function>                                                            */
   392    * @function:
   346   /*    FT_Glyph_Get_CBox                                                  */
   393    *   FT_Glyph_Get_CBox
   347   /*                                                                       */
   394    *
   348   /* <Description>                                                         */
   395    * @description:
   349   /*    Return a glyph's `control box'.  The control box encloses all the  */
   396    *   Return a glyph's 'control box'.  The control box encloses all the
   350   /*    outline's points, including Bezier control points.  Though it      */
   397    *   outline's points, including Bezier control points.  Though it
   351   /*    coincides with the exact bounding box for most glyphs, it can be   */
   398    *   coincides with the exact bounding box for most glyphs, it can be
   352   /*    slightly larger in some situations (like when rotating an outline  */
   399    *   slightly larger in some situations (like when rotating an outline that
   353   /*    that contains Bezier outside arcs).                                */
   400    *   contains Bezier outside arcs).
   354   /*                                                                       */
   401    *
   355   /*    Computing the control box is very fast, while getting the bounding */
   402    *   Computing the control box is very fast, while getting the bounding box
   356   /*    box can take much more time as it needs to walk over all segments  */
   403    *   can take much more time as it needs to walk over all segments and arcs
   357   /*    and arcs in the outline.  To get the latter, you can use the       */
   404    *   in the outline.  To get the latter, you can use the 'ftbbox'
   358   /*    `ftbbox' component, which is dedicated to this single task.        */
   405    *   component, which is dedicated to this single task.
   359   /*                                                                       */
   406    *
   360   /* <Input>                                                               */
   407    * @input:
   361   /*    glyph :: A handle to the source glyph object.                      */
   408    *   glyph ::
   362   /*                                                                       */
   409    *     A handle to the source glyph object.
   363   /*    mode  :: The mode that indicates how to interpret the returned     */
   410    *
   364   /*             bounding box values.                                      */
   411    *   mode ::
   365   /*                                                                       */
   412    *     The mode that indicates how to interpret the returned bounding box
   366   /* <Output>                                                              */
   413    *     values.
   367   /*    acbox :: The glyph coordinate bounding box.  Coordinates are       */
   414    *
   368   /*             expressed in 1/64th of pixels if it is grid-fitted.       */
   415    * @output:
   369   /*                                                                       */
   416    *   acbox ::
   370   /* <Note>                                                                */
   417    *     The glyph coordinate bounding box.  Coordinates are expressed in
   371   /*    Coordinates are relative to the glyph origin, using the y~upwards  */
   418    *     1/64th of pixels if it is grid-fitted.
   372   /*    convention.                                                        */
   419    *
   373   /*                                                                       */
   420    * @note:
   374   /*    If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode'   */
   421    *   Coordinates are relative to the glyph origin, using the y~upwards
   375   /*    must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font        */
   422    *   convention.
   376   /*    units in 26.6 pixel format.  The value @FT_GLYPH_BBOX_SUBPIXELS    */
   423    *
   377   /*    is another name for this constant.                                 */
   424    *   If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode` must
   378   /*                                                                       */
   425    *   be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6
   379   /*    If the font is tricky and the glyph has been loaded with           */
   426    *   pixel format.  The value @FT_GLYPH_BBOX_SUBPIXELS is another name for
   380   /*    @FT_LOAD_NO_SCALE, the resulting CBox is meaningless.  To get      */
   427    *   this constant.
   381   /*    reasonable values for the CBox it is necessary to load the glyph   */
   428    *
   382   /*    at a large ppem value (so that the hinting instructions can        */
   429    *   If the font is tricky and the glyph has been loaded with
   383   /*    properly shift and scale the subglyphs), then extracting the CBox, */
   430    *   @FT_LOAD_NO_SCALE, the resulting CBox is meaningless.  To get
   384   /*    which can be eventually converted back to font units.              */
   431    *   reasonable values for the CBox it is necessary to load the glyph at a
   385   /*                                                                       */
   432    *   large ppem value (so that the hinting instructions can properly shift
   386   /*    Note that the maximum coordinates are exclusive, which means that  */
   433    *   and scale the subglyphs), then extracting the CBox, which can be
   387   /*    one can compute the width and height of the glyph image (be it in  */
   434    *   eventually converted back to font units.
   388   /*    integer or 26.6 pixels) as:                                        */
   435    *
   389   /*                                                                       */
   436    *   Note that the maximum coordinates are exclusive, which means that one
   390   /*    {                                                                  */
   437    *   can compute the width and height of the glyph image (be it in integer
   391   /*      width  = bbox.xMax - bbox.xMin;                                  */
   438    *   or 26.6 pixels) as:
   392   /*      height = bbox.yMax - bbox.yMin;                                  */
   439    *
   393   /*    }                                                                  */
   440    *   ```
   394   /*                                                                       */
   441    *     width  = bbox.xMax - bbox.xMin;
   395   /*    Note also that for 26.6 coordinates, if `bbox_mode' is set to      */
   442    *     height = bbox.yMax - bbox.yMin;
   396   /*    @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted,  */
   443    *   ```
   397   /*    which corresponds to:                                              */
   444    *
   398   /*                                                                       */
   445    *   Note also that for 26.6 coordinates, if `bbox_mode` is set to
   399   /*    {                                                                  */
   446    *   @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted,
   400   /*      bbox.xMin = FLOOR(bbox.xMin);                                    */
   447    *   which corresponds to:
   401   /*      bbox.yMin = FLOOR(bbox.yMin);                                    */
   448    *
   402   /*      bbox.xMax = CEILING(bbox.xMax);                                  */
   449    *   ```
   403   /*      bbox.yMax = CEILING(bbox.yMax);                                  */
   450    *     bbox.xMin = FLOOR(bbox.xMin);
   404   /*    }                                                                  */
   451    *     bbox.yMin = FLOOR(bbox.yMin);
   405   /*                                                                       */
   452    *     bbox.xMax = CEILING(bbox.xMax);
   406   /*    To get the bbox in pixel coordinates, set `bbox_mode' to           */
   453    *     bbox.yMax = CEILING(bbox.yMax);
   407   /*    @FT_GLYPH_BBOX_TRUNCATE.                                           */
   454    *   ```
   408   /*                                                                       */
   455    *
   409   /*    To get the bbox in grid-fitted pixel coordinates, set `bbox_mode'  */
   456    *   To get the bbox in pixel coordinates, set `bbox_mode` to
   410   /*    to @FT_GLYPH_BBOX_PIXELS.                                          */
   457    *   @FT_GLYPH_BBOX_TRUNCATE.
   411   /*                                                                       */
   458    *
       
   459    *   To get the bbox in grid-fitted pixel coordinates, set `bbox_mode` to
       
   460    *   @FT_GLYPH_BBOX_PIXELS.
       
   461    */
   412   FT_EXPORT( void )
   462   FT_EXPORT( void )
   413   FT_Glyph_Get_CBox( FT_Glyph  glyph,
   463   FT_Glyph_Get_CBox( FT_Glyph  glyph,
   414                      FT_UInt   bbox_mode,
   464                      FT_UInt   bbox_mode,
   415                      FT_BBox  *acbox );
   465                      FT_BBox  *acbox );
   416 
   466 
   417 
   467 
   418   /*************************************************************************/
   468   /**************************************************************************
   419   /*                                                                       */
   469    *
   420   /* <Function>                                                            */
   470    * @function:
   421   /*    FT_Glyph_To_Bitmap                                                 */
   471    *   FT_Glyph_To_Bitmap
   422   /*                                                                       */
   472    *
   423   /* <Description>                                                         */
   473    * @description:
   424   /*    Convert a given glyph object to a bitmap glyph object.             */
   474    *   Convert a given glyph object to a bitmap glyph object.
   425   /*                                                                       */
   475    *
   426   /* <InOut>                                                               */
   476    * @inout:
   427   /*    the_glyph   :: A pointer to a handle to the target glyph.          */
   477    *   the_glyph ::
   428   /*                                                                       */
   478    *     A pointer to a handle to the target glyph.
   429   /* <Input>                                                               */
   479    *
   430   /*    render_mode :: An enumeration that describes how the data is       */
   480    * @input:
   431   /*                   rendered.                                           */
   481    *   render_mode ::
   432   /*                                                                       */
   482    *     An enumeration that describes how the data is rendered.
   433   /*    origin      :: A pointer to a vector used to translate the glyph   */
   483    *
   434   /*                   image before rendering.  Can be~0 (if no            */
   484    *   origin ::
   435   /*                   translation).  The origin is expressed in           */
   485    *     A pointer to a vector used to translate the glyph image before
   436   /*                   26.6 pixels.                                        */
   486    *     rendering.  Can be~0 (if no translation).  The origin is expressed
   437   /*                                                                       */
   487    *     in 26.6 pixels.
   438   /*    destroy     :: A boolean that indicates that the original glyph    */
   488    *
   439   /*                   image should be destroyed by this function.  It is  */
   489    *   destroy ::
   440   /*                   never destroyed in case of error.                   */
   490    *     A boolean that indicates that the original glyph image should be
   441   /*                                                                       */
   491    *     destroyed by this function.  It is never destroyed in case of error.
   442   /* <Return>                                                              */
   492    *
   443   /*    FreeType error code.  0~means success.                             */
   493    * @return:
   444   /*                                                                       */
   494    *   FreeType error code.  0~means success.
   445   /* <Note>                                                                */
   495    *
   446   /*    This function does nothing if the glyph format isn't scalable.     */
   496    * @note:
   447   /*                                                                       */
   497    *   This function does nothing if the glyph format isn't scalable.
   448   /*    The glyph image is translated with the `origin' vector before      */
   498    *
   449   /*    rendering.                                                         */
   499    *   The glyph image is translated with the `origin` vector before
   450   /*                                                                       */
   500    *   rendering.
   451   /*    The first parameter is a pointer to an @FT_Glyph handle, that will */
   501    *
   452   /*    be _replaced_ by this function (with newly allocated data).        */
   502    *   The first parameter is a pointer to an @FT_Glyph handle, that will be
   453   /*    Typically, you would use (omitting error handling):                */
   503    *   _replaced_ by this function (with newly allocated data).  Typically,
   454   /*                                                                       */
   504    *   you would use (omitting error handling):
   455   /*                                                                       */
   505    *
   456   /*      {                                                                */
   506    *   ```
   457   /*        FT_Glyph        glyph;                                         */
   507    *     FT_Glyph        glyph;
   458   /*        FT_BitmapGlyph  glyph_bitmap;                                  */
   508    *     FT_BitmapGlyph  glyph_bitmap;
   459   /*                                                                       */
   509    *
   460   /*                                                                       */
   510    *
   461   /*        // load glyph                                                  */
   511    *     // load glyph
   462   /*        error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT );    */
   512    *     error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT );
   463   /*                                                                       */
   513    *
   464   /*        // extract glyph image                                         */
   514    *     // extract glyph image
   465   /*        error = FT_Get_Glyph( face->glyph, &glyph );                   */
   515    *     error = FT_Get_Glyph( face->glyph, &glyph );
   466   /*                                                                       */
   516    *
   467   /*        // convert to a bitmap (default render mode + destroying old)  */
   517    *     // convert to a bitmap (default render mode + destroying old)
   468   /*        if ( glyph->format != FT_GLYPH_FORMAT_BITMAP )                 */
   518    *     if ( glyph->format != FT_GLYPH_FORMAT_BITMAP )
   469   /*        {                                                              */
   519    *     {
   470   /*          error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL,   */
   520    *       error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL,
   471   /*                                      0, 1 );                          */
   521    *                                     0, 1 );
   472   /*          if ( error ) // `glyph' unchanged                            */
   522    *       if ( error ) // `glyph' unchanged
   473   /*            ...                                                        */
   523    *         ...
   474   /*        }                                                              */
   524    *     }
   475   /*                                                                       */
   525    *
   476   /*        // access bitmap content by typecasting                        */
   526    *     // access bitmap content by typecasting
   477   /*        glyph_bitmap = (FT_BitmapGlyph)glyph;                          */
   527    *     glyph_bitmap = (FT_BitmapGlyph)glyph;
   478   /*                                                                       */
   528    *
   479   /*        // do funny stuff with it, like blitting/drawing               */
   529    *     // do funny stuff with it, like blitting/drawing
   480   /*        ...                                                            */
   530    *     ...
   481   /*                                                                       */
   531    *
   482   /*        // discard glyph image (bitmap or not)                         */
   532    *     // discard glyph image (bitmap or not)
   483   /*        FT_Done_Glyph( glyph );                                        */
   533    *     FT_Done_Glyph( glyph );
   484   /*      }                                                                */
   534    *   ```
   485   /*                                                                       */
   535    *
   486   /*                                                                       */
   536    *   Here is another example, again without error handling:
   487   /*    Here another example, again without error handling:                */
   537    *
   488   /*                                                                       */
   538    *   ```
   489   /*                                                                       */
   539    *     FT_Glyph  glyphs[MAX_GLYPHS]
   490   /*      {                                                                */
   540    *
   491   /*        FT_Glyph  glyphs[MAX_GLYPHS]                                   */
   541    *
   492   /*                                                                       */
   542    *     ...
   493   /*                                                                       */
   543    *
   494   /*        ...                                                            */
   544    *     for ( idx = 0; i < MAX_GLYPHS; i++ )
   495   /*                                                                       */
   545    *       error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) ||
   496   /*        for ( idx = 0; i < MAX_GLYPHS; i++ )                           */
   546    *               FT_Get_Glyph ( face->glyph, &glyphs[idx] );
   497   /*          error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) ||       */
   547    *
   498   /*                  FT_Get_Glyph ( face->glyph, &glyph[idx] );           */
   548    *     ...
   499   /*                                                                       */
   549    *
   500   /*        ...                                                            */
   550    *     for ( idx = 0; i < MAX_GLYPHS; i++ )
   501   /*                                                                       */
   551    *     {
   502   /*        for ( idx = 0; i < MAX_GLYPHS; i++ )                           */
   552    *       FT_Glyph  bitmap = glyphs[idx];
   503   /*        {                                                              */
   553    *
   504   /*          FT_Glyph  bitmap = glyphs[idx];                              */
   554    *
   505   /*                                                                       */
   555    *       ...
   506   /*                                                                       */
   556    *
   507   /*          ...                                                          */
   557    *       // after this call, `bitmap' no longer points into
   508   /*                                                                       */
   558    *       // the `glyphs' array (and the old value isn't destroyed)
   509   /*          // after this call, `bitmap' no longer points into           */
   559    *       FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 );
   510   /*          // the `glyphs' array (and the old value isn't destroyed)    */
   560    *
   511   /*          FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 );    */
   561    *       ...
   512   /*                                                                       */
   562    *
   513   /*          ...                                                          */
   563    *       FT_Done_Glyph( bitmap );
   514   /*                                                                       */
   564    *     }
   515   /*          FT_Done_Glyph( bitmap );                                     */
   565    *
   516   /*        }                                                              */
   566    *     ...
   517   /*                                                                       */
   567    *
   518   /*        ...                                                            */
   568    *     for ( idx = 0; i < MAX_GLYPHS; i++ )
   519   /*                                                                       */
   569    *       FT_Done_Glyph( glyphs[idx] );
   520   /*        for ( idx = 0; i < MAX_GLYPHS; i++ )                           */
   570    *   ```
   521   /*          FT_Done_Glyph( glyphs[idx] );                                */
   571    */
   522   /*      }                                                                */
       
   523   /*                                                                       */
       
   524   FT_EXPORT( FT_Error )
   572   FT_EXPORT( FT_Error )
   525   FT_Glyph_To_Bitmap( FT_Glyph*       the_glyph,
   573   FT_Glyph_To_Bitmap( FT_Glyph*       the_glyph,
   526                       FT_Render_Mode  render_mode,
   574                       FT_Render_Mode  render_mode,
   527                       FT_Vector*      origin,
   575                       FT_Vector*      origin,
   528                       FT_Bool         destroy );
   576                       FT_Bool         destroy );
   529 
   577 
   530 
   578 
   531   /*************************************************************************/
   579   /**************************************************************************
   532   /*                                                                       */
   580    *
   533   /* <Function>                                                            */
   581    * @function:
   534   /*    FT_Done_Glyph                                                      */
   582    *   FT_Done_Glyph
   535   /*                                                                       */
   583    *
   536   /* <Description>                                                         */
   584    * @description:
   537   /*    Destroy a given glyph.                                             */
   585    *   Destroy a given glyph.
   538   /*                                                                       */
   586    *
   539   /* <Input>                                                               */
   587    * @input:
   540   /*    glyph :: A handle to the target glyph object.                      */
   588    *   glyph ::
   541   /*                                                                       */
   589    *     A handle to the target glyph object.
       
   590    */
   542   FT_EXPORT( void )
   591   FT_EXPORT( void )
   543   FT_Done_Glyph( FT_Glyph  glyph );
   592   FT_Done_Glyph( FT_Glyph  glyph );
   544 
   593 
   545   /* */
   594   /* */
   546 
   595 
   547 
   596 
   548   /* other helpful functions */
   597   /* other helpful functions */
   549 
   598 
   550   /*************************************************************************/
   599   /**************************************************************************
   551   /*                                                                       */
   600    *
   552   /* <Section>                                                             */
   601    * @section:
   553   /*    computations                                                       */
   602    *   computations
   554   /*                                                                       */
   603    *
   555   /*************************************************************************/
   604    */
   556 
   605 
   557 
   606 
   558   /*************************************************************************/
   607   /**************************************************************************
   559   /*                                                                       */
   608    *
   560   /* <Function>                                                            */
   609    * @function:
   561   /*    FT_Matrix_Multiply                                                 */
   610    *   FT_Matrix_Multiply
   562   /*                                                                       */
   611    *
   563   /* <Description>                                                         */
   612    * @description:
   564   /*    Perform the matrix operation `b = a*b'.                            */
   613    *   Perform the matrix operation `b = a*b`.
   565   /*                                                                       */
   614    *
   566   /* <Input>                                                               */
   615    * @input:
   567   /*    a :: A pointer to matrix `a'.                                      */
   616    *   a ::
   568   /*                                                                       */
   617    *     A pointer to matrix `a`.
   569   /* <InOut>                                                               */
   618    *
   570   /*    b :: A pointer to matrix `b'.                                      */
   619    * @inout:
   571   /*                                                                       */
   620    *   b ::
   572   /* <Note>                                                                */
   621    *     A pointer to matrix `b`.
   573   /*    The result is undefined if either `a' or `b' is zero.              */
   622    *
   574   /*                                                                       */
   623    * @note:
   575   /*    Since the function uses wrap-around arithmetic, results become     */
   624    *   The result is undefined if either `a` or `b` is zero.
   576   /*    meaningless if the arguments are very large.                       */
   625    *
   577   /*                                                                       */
   626    *   Since the function uses wrap-around arithmetic, results become
       
   627    *   meaningless if the arguments are very large.
       
   628    */
   578   FT_EXPORT( void )
   629   FT_EXPORT( void )
   579   FT_Matrix_Multiply( const FT_Matrix*  a,
   630   FT_Matrix_Multiply( const FT_Matrix*  a,
   580                       FT_Matrix*        b );
   631                       FT_Matrix*        b );
   581 
   632 
   582 
   633 
   583   /*************************************************************************/
   634   /**************************************************************************
   584   /*                                                                       */
   635    *
   585   /* <Function>                                                            */
   636    * @function:
   586   /*    FT_Matrix_Invert                                                   */
   637    *   FT_Matrix_Invert
   587   /*                                                                       */
   638    *
   588   /* <Description>                                                         */
   639    * @description:
   589   /*    Invert a 2x2 matrix.  Return an error if it can't be inverted.     */
   640    *   Invert a 2x2 matrix.  Return an error if it can't be inverted.
   590   /*                                                                       */
   641    *
   591   /* <InOut>                                                               */
   642    * @inout:
   592   /*    matrix :: A pointer to the target matrix.  Remains untouched in    */
   643    *   matrix ::
   593   /*              case of error.                                           */
   644    *     A pointer to the target matrix.  Remains untouched in case of error.
   594   /*                                                                       */
   645    *
   595   /* <Return>                                                              */
   646    * @return:
   596   /*    FreeType error code.  0~means success.                             */
   647    *   FreeType error code.  0~means success.
   597   /*                                                                       */
   648    */
   598   FT_EXPORT( FT_Error )
   649   FT_EXPORT( FT_Error )
   599   FT_Matrix_Invert( FT_Matrix*  matrix );
   650   FT_Matrix_Invert( FT_Matrix*  matrix );
   600 
   651 
   601   /* */
   652   /* */
   602 
   653