misc/libfreetype/src/base/ftglyph.c
author unc0rr
Wed, 05 Dec 2012 23:51:04 +0400
branchflibqtfrontend
changeset 8230 bd4b8f9488a4
parent 5172 88f2e05288ba
permissions -rw-r--r--
Show who's in game to spectators
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftglyph.c                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    FreeType convenience functions to handle glyphs (body).              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010 by       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
  /*  This file contains the definition of several convenience functions   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
  /*  that can be used by client applications to easily retrieve glyph     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
  /*  bitmaps and outlines from a given face.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
  /*  These functions should be optional if you are writing a font server  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
  /*  or text layout engine on top of FreeType.  However, they are pretty  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  /*  handy for many other simple uses of the library.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#include FT_GLYPH_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
#include FT_BITMAP_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#include "basepic.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
#define FT_COMPONENT  trace_glyph
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  /****   FT_BitmapGlyph support                                        ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  ft_bitmap_glyph_init( FT_Glyph      bitmap_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
                        FT_GlyphSlot  slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    FT_BitmapGlyph  glyph   = (FT_BitmapGlyph)bitmap_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    FT_Error        error   = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    FT_Library      library = FT_GLYPH( glyph )->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
      error = FT_Err_Invalid_Glyph_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    glyph->left = slot->bitmap_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    glyph->top  = slot->bitmap_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    /* do lazy copying whenever possible */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
      glyph->bitmap = slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
      FT_Bitmap_New( &glyph->bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  ft_bitmap_glyph_copy( FT_Glyph  bitmap_source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
                        FT_Glyph  bitmap_target )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    FT_Library      library = bitmap_source->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    FT_BitmapGlyph  source  = (FT_BitmapGlyph)bitmap_source;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    FT_BitmapGlyph  target  = (FT_BitmapGlyph)bitmap_target;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    target->left = source->left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    target->top  = source->top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
  ft_bitmap_glyph_done( FT_Glyph  bitmap_glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FT_BitmapGlyph  glyph   = (FT_BitmapGlyph)bitmap_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    FT_Library      library = FT_GLYPH( glyph )->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    FT_Bitmap_Done( library, &glyph->bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  ft_bitmap_glyph_bbox( FT_Glyph  bitmap_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
                        FT_BBox*  cbox )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    FT_BitmapGlyph  glyph = (FT_BitmapGlyph)bitmap_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    cbox->xMin = glyph->left << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    cbox->yMax = glyph->top << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    cbox->yMin = cbox->yMax - ( glyph->bitmap.rows << 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  FT_DEFINE_GLYPH(ft_bitmap_glyph_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    sizeof ( FT_BitmapGlyphRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    FT_GLYPH_FORMAT_BITMAP,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    ft_bitmap_glyph_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    ft_bitmap_glyph_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    ft_bitmap_glyph_copy,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    0,                          /* FT_Glyph_TransformFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    ft_bitmap_glyph_bbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    0                           /* FT_Glyph_PrepareFunc   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
  /****   FT_OutlineGlyph support                                       ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
  ft_outline_glyph_init( FT_Glyph      outline_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
                         FT_GlyphSlot  slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    FT_OutlineGlyph  glyph   = (FT_OutlineGlyph)outline_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    FT_Error         error   = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    FT_Library       library = FT_GLYPH( glyph )->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    FT_Outline*      source  = &slot->outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    FT_Outline*      target  = &glyph->outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    /* check format in glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      error = FT_Err_Invalid_Glyph_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    /* allocate new outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    error = FT_Outline_New( library, source->n_points, source->n_contours,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
                            &glyph->outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    FT_Outline_Copy( source, target );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
  ft_outline_glyph_done( FT_Glyph  outline_glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    FT_OutlineGlyph  glyph = (FT_OutlineGlyph)outline_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
  ft_outline_glyph_copy( FT_Glyph  outline_source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
                         FT_Glyph  outline_target )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    FT_OutlineGlyph  source  = (FT_OutlineGlyph)outline_source;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_OutlineGlyph  target  = (FT_OutlineGlyph)outline_target;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    FT_Library       library = FT_GLYPH( source )->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    error = FT_Outline_New( library, source->outline.n_points,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
                            source->outline.n_contours, &target->outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
      FT_Outline_Copy( &source->outline, &target->outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
  ft_outline_glyph_transform( FT_Glyph          outline_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
                              const FT_Matrix*  matrix,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
                              const FT_Vector*  delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    FT_OutlineGlyph  glyph = (FT_OutlineGlyph)outline_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    if ( matrix )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      FT_Outline_Transform( &glyph->outline, matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    if ( delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  ft_outline_glyph_bbox( FT_Glyph  outline_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
                         FT_BBox*  bbox )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    FT_OutlineGlyph  glyph = (FT_OutlineGlyph)outline_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    FT_Outline_Get_CBox( &glyph->outline, bbox );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
  ft_outline_glyph_prepare( FT_Glyph      outline_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
                            FT_GlyphSlot  slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    FT_OutlineGlyph  glyph = (FT_OutlineGlyph)outline_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    slot->format         = FT_GLYPH_FORMAT_OUTLINE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    slot->outline        = glyph->outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    slot->outline.flags &= ~FT_OUTLINE_OWNER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
  FT_DEFINE_GLYPH( ft_outline_glyph_class, 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    sizeof ( FT_OutlineGlyphRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
    FT_GLYPH_FORMAT_OUTLINE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    ft_outline_glyph_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
    ft_outline_glyph_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    ft_outline_glyph_copy,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    ft_outline_glyph_transform,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    ft_outline_glyph_bbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    ft_outline_glyph_prepare
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
  /****   FT_Glyph class and API                                        ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
   static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
   ft_new_glyph( FT_Library             library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
                 const FT_Glyph_Class*  clazz,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
                 FT_Glyph*              aglyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
   {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
     FT_Memory  memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
     FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
     FT_Glyph   glyph  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
     *aglyph = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
     if ( !FT_ALLOC( glyph, clazz->glyph_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
     {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
       glyph->library = library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
       glyph->clazz   = clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
       glyph->format  = clazz->glyph_format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
       *aglyph = glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
     }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
     return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
   }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
  /* documentation is in ftglyph.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
  FT_Glyph_Copy( FT_Glyph   source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
                 FT_Glyph  *target )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    FT_Glyph               copy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    FT_Error               error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
    const FT_Glyph_Class*  clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    /* check arguments */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    if ( !target )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
      error = FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    *target = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    if ( !source || !source->clazz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
      error = FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
    clazz = source->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    error = ft_new_glyph( source->library, clazz, &copy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    copy->advance = source->advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    copy->format  = source->format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    if ( clazz->glyph_copy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
      error = clazz->glyph_copy( source, copy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
      FT_Done_Glyph( copy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
      *target = copy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
  /* documentation is in ftglyph.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
  FT_Get_Glyph( FT_GlyphSlot  slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
                FT_Glyph     *aglyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    FT_Library  library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
    FT_Error    error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
    FT_Glyph    glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
    const FT_Glyph_Class*  clazz = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    if ( !slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
      return FT_Err_Invalid_Slot_Handle;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
    library = slot->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
    if ( !aglyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
    /* if it is a bitmap, that's easy :-) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
      clazz = FT_BITMAP_GLYPH_CLASS_GET;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    /* if it is an outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
      clazz = FT_OUTLINE_GLYPH_CLASS_GET;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
      /* try to find a renderer that supports the glyph image format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
      FT_Renderer  render = FT_Lookup_Renderer( library, slot->format, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
      if ( render )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
        clazz = &render->glyph_class;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
    if ( !clazz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
      error = FT_Err_Invalid_Glyph_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
    /* create FT_Glyph object */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    error = ft_new_glyph( library, clazz, &glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
    /* copy advance while converting it to 16.16 format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
    glyph->advance.x = slot->advance.x << 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
    glyph->advance.y = slot->advance.y << 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    /* now import the image from the glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    error = clazz->glyph_init( glyph, slot );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
    /* if an error occurred, destroy the glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
      FT_Done_Glyph( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
      *aglyph = glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
  /* documentation is in ftglyph.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
  FT_Glyph_Transform( FT_Glyph    glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
                      FT_Matrix*  matrix,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
                      FT_Vector*  delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
    const FT_Glyph_Class*  clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
    FT_Error               error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    if ( !glyph || !glyph->clazz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
      error = FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
      clazz = glyph->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
      if ( clazz->glyph_transform )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
        /* transform glyph image */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        clazz->glyph_transform( glyph, matrix, delta );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
        /* transform advance vector */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        if ( matrix )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
          FT_Vector_Transform( &glyph->advance, matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
        error = FT_Err_Invalid_Glyph_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
  /* documentation is in ftglyph.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
  FT_EXPORT_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
  FT_Glyph_Get_CBox( FT_Glyph  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
                     FT_UInt   bbox_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
                     FT_BBox  *acbox )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
    const FT_Glyph_Class*  clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
    if ( !acbox )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
    acbox->xMin = acbox->yMin = acbox->xMax = acbox->yMax = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
    if ( !glyph || !glyph->clazz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
      clazz = glyph->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
      if ( !clazz->glyph_bbox )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
        /* retrieve bbox in 26.6 coordinates */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
        clazz->glyph_bbox( glyph, acbox );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
        /* perform grid fitting if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
        if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
             bbox_mode == FT_GLYPH_BBOX_PIXELS  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
          acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
          acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
          acbox->xMax = FT_PIX_CEIL( acbox->xMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
          acbox->yMax = FT_PIX_CEIL( acbox->yMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
        /* convert to integer pixels if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
        if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
             bbox_mode == FT_GLYPH_BBOX_PIXELS   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
          acbox->xMin >>= 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
          acbox->yMin >>= 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
          acbox->xMax >>= 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
          acbox->yMax >>= 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
  /* documentation is in ftglyph.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
  FT_Glyph_To_Bitmap( FT_Glyph*       the_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
                      FT_Render_Mode  render_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
                      FT_Vector*      origin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
                      FT_Bool         destroy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    FT_GlyphSlotRec           dummy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    FT_GlyphSlot_InternalRec  dummy_internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    FT_Error                  error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
    FT_Glyph                  glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
    FT_BitmapGlyph            bitmap = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
    const FT_Glyph_Class*     clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
#ifdef FT_CONFIG_OPTION_PIC
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
    FT_Library                library = FT_GLYPH( glyph )->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
    /* check argument */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
    if ( !the_glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
      goto Bad;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
    /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
    /* then calling FT_Render_Glyph_Internal()                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
    glyph = *the_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    if ( !glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
      goto Bad;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
    clazz = glyph->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    /* when called with a bitmap glyph, do nothing and return successfully */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
    if ( clazz == FT_BITMAP_GLYPH_CLASS_GET )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
    if ( !clazz || !clazz->glyph_prepare )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
      goto Bad;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
    FT_MEM_ZERO( &dummy, sizeof ( dummy ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
    FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    dummy.internal = &dummy_internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
    dummy.library  = glyph->library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
    dummy.format   = clazz->glyph_format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    /* create result bitmap glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
    error = ft_new_glyph( glyph->library, FT_BITMAP_GLYPH_CLASS_GET,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
                          (FT_Glyph*)(void*)&bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
    /* if `origin' is set, translate the glyph image */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
    if ( origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
      FT_Glyph_Transform( glyph, 0, origin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
    FT_UNUSED( origin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    /* prepare dummy slot for rendering */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    error = clazz->glyph_prepare( glyph, &dummy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
      error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    if ( !destroy && origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
      FT_Vector  v;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
      v.x = -origin->x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
      v.y = -origin->y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
      FT_Glyph_Transform( glyph, 0, &v );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
    /* in case of success, copy the bitmap to the glyph bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
    error = ft_bitmap_glyph_init( (FT_Glyph)bitmap, &dummy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    /* copy advance */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    bitmap->root.advance = glyph->advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
    if ( destroy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
      FT_Done_Glyph( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    *the_glyph = FT_GLYPH( bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
    if ( error && bitmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
      FT_Done_Glyph( FT_GLYPH( bitmap ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
  Bad:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
    error = FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
  /* documentation is in ftglyph.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
  FT_EXPORT_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
  FT_Done_Glyph( FT_Glyph  glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
    if ( glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
      FT_Memory              memory = glyph->library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
      const FT_Glyph_Class*  clazz  = glyph->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
      if ( clazz->glyph_done )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
        clazz->glyph_done( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
      FT_FREE( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
/* END */