misc/libfreetype/src/truetype/ttgload.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
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
/*  ttgload.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
/*    TrueType Glyph Loader (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-2011                                                    */
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
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_CALC_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_SFNT_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "ttgload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "ttpload.h"
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
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include "ttgxvar.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
#include "tterrors.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
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
  /*************************************************************************/
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
  /* 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
    40
  /* 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
    41
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
#define FT_COMPONENT  trace_ttgload
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
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
  /* Composite glyph flags.                                                */
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
#define ARGS_ARE_WORDS             0x0001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
#define ARGS_ARE_XY_VALUES         0x0002
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
#define ROUND_XY_TO_GRID           0x0004
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
#define WE_HAVE_A_SCALE            0x0008
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
/* reserved                        0x0010 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
#define MORE_COMPONENTS            0x0020
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
#define WE_HAVE_AN_XY_SCALE        0x0040
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
#define WE_HAVE_A_2X2              0x0080
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
#define WE_HAVE_INSTR              0x0100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
#define USE_MY_METRICS             0x0200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
#define OVERLAP_COMPOUND           0x0400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
#define SCALED_COMPONENT_OFFSET    0x0800
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
#define UNSCALED_COMPONENT_OFFSET  0x1000
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
  /*************************************************************************/
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
  /* Return the horizontal metrics in font units for a given glyph.        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
  TT_Get_HMetrics( TT_Face     face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
                   FT_UInt     idx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
                   FT_Short*   lsb,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                   FT_UShort*  aw )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
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
    FT_TRACE5(( "  advance width (font units): %d\n", *aw ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    FT_TRACE5(( "  left side bearing (font units): %d\n", *lsb ));
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
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  /* Return the vertical metrics in font units for a given glyph.          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  /* Greg Hitchcock from Microsoft told us that if there were no `vmtx'    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  /* table, typoAscender/Descender from the `OS/2' table would be used     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  /* instead, and if there were no `OS/2' table, use ascender/descender    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
  /* from the `hhea' table.  But that is not what Microsoft's rasterizer   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
  /* apparently does: It uses the ppem value as the advance height, and    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  /* sets the top side bearing to be zero.                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
  TT_Get_VMetrics( TT_Face     face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
                   FT_UInt     idx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
                   FT_Short*   tsb,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
                   FT_UShort*  ah )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    if ( face->vertical_info )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
#if 1             /* Empirically determined, at variance with what MS said */
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
    else
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
      *tsb = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      *ah  = face->root.units_per_EM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
#else      /* This is what MS said to do.  It isn't what they do, however. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    else if ( face->os2.version != 0xFFFFU )
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
      *tsb = face->os2.sTypoAscender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
      *ah  = face->os2.sTypoAscender - face->os2.sTypoDescender;
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
    else
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
      *tsb = face->horizontal.Ascender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
      *ah  = face->horizontal.Ascender - face->horizontal.Descender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
    }
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
#endif
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
    FT_TRACE5(( "  advance height (font units): %d\n", *ah ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    FT_TRACE5(( "  top side bearing (font units): %d\n", *tsb ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  tt_get_metrics( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
                  FT_UInt    glyph_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    TT_Face  face = (TT_Face)loader->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    FT_Short   left_bearing = 0, top_bearing = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    FT_UShort  advance_width = 0, advance_height = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    TT_Get_HMetrics( face, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
                     &left_bearing,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
                     &advance_width );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    TT_Get_VMetrics( face, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
                     &top_bearing,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
                     &advance_height );
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
    loader->left_bearing = left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    loader->advance      = advance_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    loader->top_bearing  = top_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    loader->vadvance     = advance_height;
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
    if ( !loader->linear_def )
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
      loader->linear_def = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
      loader->linear     = advance_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
  tt_get_metrics_incr_overrides( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
                                 FT_UInt    glyph_index )
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
    TT_Face  face = (TT_Face)loader->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    FT_Short   left_bearing = 0, top_bearing = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    FT_UShort  advance_width = 0, advance_height = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
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
    /* If this is an incrementally loaded font check whether there are */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    /* overriding metrics for this glyph.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    if ( face->root.internal->incremental_interface                           &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
         face->root.internal->incremental_interface->funcs->get_glyph_metrics )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      FT_Incremental_MetricsRec  metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
      FT_Error                   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
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
      metrics.bearing_x = loader->left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
      metrics.bearing_y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      metrics.advance   = loader->advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      metrics.advance_v = 0;
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
      error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
                face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
                glyph_index, FALSE, &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        goto Exit;
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
      left_bearing  = (FT_Short)metrics.bearing_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
      advance_width = (FT_UShort)metrics.advance;
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
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      /* GWW: Do I do the same for vertical metrics? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
      metrics.bearing_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
      metrics.bearing_y = loader->top_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
      metrics.advance   = loader->vadvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
      error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
                face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
                glyph_index, TRUE, &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
      top_bearing    = (FT_Short)metrics.bearing_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
      advance_height = (FT_UShort)metrics.advance;
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
#endif /* 0 */
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
      loader->left_bearing = left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
      loader->advance      = advance_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      loader->top_bearing  = top_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
      loader->vadvance     = advance_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
      if ( !loader->linear_def )
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
        loader->linear_def = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
        loader->linear     = advance_width;
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
  }
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
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  /* Translates an array of coordinates.                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  translate_array( FT_UInt     n,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
                   FT_Vector*  coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
                   FT_Pos      delta_x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
                   FT_Pos      delta_y )
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_UInt  k;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    if ( delta_x )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
      for ( k = 0; k < n; k++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
        coords[k].x += delta_x;
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
    if ( delta_y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
      for ( k = 0; k < n; k++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
        coords[k].y += delta_y;
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
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
#undef  IS_HINTED
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
#define IS_HINTED( flags )  ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
  /*************************************************************************/
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
  /* The following functions are used by default with TrueType fonts.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
  /* However, they can be replaced by alternatives if we need to support   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
  /* TrueType-compressed formats (like MicroType) in the future.           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
  TT_Access_Glyph_Frame( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
                         FT_UInt    glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
                         FT_ULong   offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
                         FT_UInt    byte_count )
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_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
    FT_Stream  stream = loader->stream;
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
    /* for non-debug mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    FT_UNUSED( glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
    FT_TRACE4(( "Glyph %ld\n", glyph_index ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
    /* the following line sets the `error' variable through macros! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    loader->cursor = stream->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    loader->limit  = stream->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
    return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
  TT_Forget_Glyph_Frame( TT_Loader  loader )
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
    FT_Stream  stream = loader->stream;
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
    FT_FRAME_EXIT();
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
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  TT_Load_Glyph_Header( TT_Loader  loader )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    FT_Byte*  p     = loader->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    FT_Byte*  limit = loader->limit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    if ( p + 10 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
      return TT_Err_Invalid_Outline;
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
    loader->n_contours = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    loader->bbox.xMin = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
    loader->bbox.yMin = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    loader->bbox.xMax = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    loader->bbox.yMax = FT_NEXT_SHORT( p );
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
    FT_TRACE5(( "  # of contours: %d\n", loader->n_contours ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    FT_TRACE5(( "  xMin: %4d  xMax: %4d\n", loader->bbox.xMin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
                                            loader->bbox.xMax ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    FT_TRACE5(( "  yMin: %4d  yMax: %4d\n", loader->bbox.yMin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
                                            loader->bbox.yMax ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    loader->cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    return TT_Err_Ok;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
  TT_Load_Simple_Glyph( TT_Loader  load )
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
    FT_Error        error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    FT_Byte*        p          = load->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
    FT_Byte*        limit      = load->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    FT_GlyphLoader  gloader    = load->gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
    FT_Int          n_contours = load->n_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    FT_Outline*     outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
    TT_Face         face       = (TT_Face)load->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    FT_UShort       n_ins;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    FT_Int          n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
    FT_Byte         *flag, *flag_limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
    FT_Byte         c, count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
    FT_Vector       *vec, *vec_limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
    FT_Pos          x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
    FT_Short        *cont, *cont_limit, prev_cont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    FT_Int          xy_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
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
    /* check that we can add the contours to the glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
    error = FT_GLYPHLOADER_CHECK_POINTS( gloader, 0, n_contours );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
    /* reading the contours' endpoints & number of points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
    cont       = gloader->current.outline.contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    cont_limit = cont + n_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    /* check space for contours array + instructions count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
      goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    prev_cont = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    if ( n_contours > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
      cont[0] = prev_cont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
    for ( cont++; cont < cont_limit; cont++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
      cont[0] = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
      if ( cont[0] <= prev_cont )
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
        /* unordered contours: this is invalid */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
        error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
        goto Fail;
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
      prev_cont = cont[0];
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    n_points = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
    if ( n_contours > 0 )
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
      n_points = cont[-1] + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
      if ( n_points < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
        goto Invalid_Outline;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    /* note that we will add four phantom points later */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
    error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
      goto Fail;
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
    /* we'd better check the contours table right now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    outline = &gloader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
    for ( cont = outline->contours + 1; cont < cont_limit; cont++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
      if ( cont[-1] >= cont[0] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
        goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
    /* reading the bytecode instructions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
    load->glyph->control_len  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    load->glyph->control_data = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
    if ( p + 2 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
      goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
    n_ins = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    FT_TRACE5(( "  Instructions size: %u\n", n_ins ));
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
    if ( n_ins > face->max_profile.maxSizeOfInstructions )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
      FT_TRACE0(( "TT_Load_Simple_Glyph: too many instructions (%d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
                  n_ins ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
      error = TT_Err_Too_Many_Hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
      goto Fail;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
    if ( ( limit - p ) < n_ins )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
      FT_TRACE0(( "TT_Load_Simple_Glyph: instruction count mismatch\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
      error = TT_Err_Too_Many_Hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
    }
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
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
    if ( IS_HINTED( load->load_flags ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
      load->glyph->control_len  = n_ins;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
      load->glyph->control_data = load->exec->glyphIns;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
#endif /* TT_USE_BYTECODE_INTERPRETER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    p += n_ins;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    /* reading the point tags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
    flag       = (FT_Byte*)outline->tags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
    flag_limit = flag + n_points;
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
    FT_ASSERT( flag != NULL );
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
    while ( flag < flag_limit )
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
      if ( p + 1 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
        goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
      *flag++ = c = FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
      if ( c & 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
        if ( p + 1 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
          goto Invalid_Outline;
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
        count = FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
        if ( flag + (FT_Int)count > flag_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
          goto Invalid_Outline;
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
        for ( ; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
          *flag++ = c;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    /* reading the X coordinates */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
    vec       = outline->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
    vec_limit = vec + n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
    flag      = (FT_Byte*)outline->tags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
    x         = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
    if ( p + xy_size > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
      goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
    for ( ; vec < vec_limit; vec++, flag++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
      FT_Pos   y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
      FT_Byte  f = *flag;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
      if ( f & 2 )
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
        if ( p + 1 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
          goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
        y = (FT_Pos)FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
        if ( ( f & 16 ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
          y = -y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
      else if ( ( f & 16 ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
        if ( p + 2 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
          goto Invalid_Outline;
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
        y = (FT_Pos)FT_NEXT_SHORT( p );
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
      x     += y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
      vec->x = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
      /* the cast is for stupid compilers */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
      *flag  = (FT_Byte)( f & ~( 2 | 16 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
    /* reading the Y coordinates */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
    vec       = gloader->current.outline.points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    vec_limit = vec + n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    flag      = (FT_Byte*)outline->tags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    x         = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
    for ( ; vec < vec_limit; vec++, flag++ )
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
      FT_Pos   y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
      FT_Byte  f = *flag;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
      if ( f & 4 )
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
        if ( p + 1 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
          goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
        y = (FT_Pos)FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
        if ( ( f & 32 ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
          y = -y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
      else if ( ( f & 32 ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
        if ( p + 2 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
          goto Invalid_Outline;
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
        y = (FT_Pos)FT_NEXT_SHORT( p );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
      x     += y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
      vec->y = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
      /* the cast is for stupid compilers */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
      *flag  = (FT_Byte)( f & FT_CURVE_TAG_ON );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
    }
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
    outline->n_points   = (FT_UShort)n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
    outline->n_contours = (FT_Short) n_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
    load->cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
  Invalid_Outline:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    error = TT_Err_Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
    goto Fail;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
  TT_Load_Composite_Glyph( TT_Loader  loader )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
    FT_Error        error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
    FT_Byte*        p       = loader->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    FT_Byte*        limit   = loader->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    FT_GlyphLoader  gloader = loader->gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    FT_SubGlyph     subglyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    FT_UInt         num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
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
    num_subglyphs = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
      FT_Fixed  xx, xy, yy, yx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
      FT_UInt   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
      /* check that we can load a new subglyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
      error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
      /* check space */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
      if ( p + 4 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
        goto Invalid_Composite;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
      subglyph = gloader->current.subglyphs + num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
      subglyph->arg1 = subglyph->arg2 = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
      subglyph->flags = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
      subglyph->index = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
      /* check space */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
      count = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
      if ( subglyph->flags & ARGS_ARE_WORDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
        count += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
      if ( subglyph->flags & WE_HAVE_A_SCALE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
        count += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
      else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
        count += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
      else if ( subglyph->flags & WE_HAVE_A_2X2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
        count += 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
      if ( p + count > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
        goto Invalid_Composite;
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
      /* read arguments */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
      if ( subglyph->flags & ARGS_ARE_WORDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
        subglyph->arg1 = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
        subglyph->arg2 = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
        subglyph->arg1 = FT_NEXT_CHAR( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
        subglyph->arg2 = FT_NEXT_CHAR( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
      }
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
      /* read transform */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
      xx = yy = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
      xy = yx = 0;
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
      if ( subglyph->flags & WE_HAVE_A_SCALE )
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
        xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
        yy = xx;
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
      else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
        xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
        yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
      else if ( subglyph->flags & WE_HAVE_A_2X2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
        xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
        yx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
        xy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
        yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
      subglyph->transform.xx = xx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
      subglyph->transform.xy = xy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
      subglyph->transform.yx = yx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
      subglyph->transform.yy = yy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
      num_subglyphs++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
    } while ( subglyph->flags & MORE_COMPONENTS );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
    gloader->current.num_subglyphs = num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
      FT_Stream  stream = loader->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
      /* we must undo the FT_FRAME_ENTER in order to point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
      /* to the composite instructions, if we find some.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
      /* We will process them later.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
      /*                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
      loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
                                    p - limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
    loader->cursor = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
  Invalid_Composite:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
    error = TT_Err_Invalid_Composite;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
    goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
  TT_Init_Glyph_Loading( TT_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    face->access_glyph_frame   = TT_Access_Glyph_Frame;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    face->read_glyph_header    = TT_Load_Glyph_Header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
    face->read_simple_glyph    = TT_Load_Simple_Glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
    face->read_composite_glyph = TT_Load_Composite_Glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
    face->forget_glyph_frame   = TT_Forget_Glyph_Frame;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
  tt_prepare_zone( TT_GlyphZone  zone,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
                   FT_GlyphLoad  load,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
                   FT_UInt       start_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
                   FT_UInt       start_contour )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
    zone->n_points    = (FT_UShort)( load->outline.n_points - start_point );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
    zone->n_contours  = (FT_Short) ( load->outline.n_contours -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
                                       start_contour );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
    zone->org         = load->extra_points + start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
    zone->cur         = load->outline.points + start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
    zone->orus        = load->extra_points2 + start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
    zone->tags        = (FT_Byte*)load->outline.tags + start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
    zone->contours    = (FT_UShort*)load->outline.contours + start_contour;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
    zone->first_point = (FT_UShort)start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
  /*    TT_Hint_Glyph                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
  /*    Hint the glyph using the zone prepared by the caller.  Note that   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
  /*    the zone is supposed to include four phantom points.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
  TT_Hint_Glyph( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
                 FT_Bool    is_composite )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
    TT_GlyphZone  zone = &loader->zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
    FT_Pos        origin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
    FT_UInt       n_ins;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    FT_UNUSED( is_composite );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
    if ( loader->glyph->control_len > 0xFFFFL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
      FT_TRACE1(( "TT_Hint_Glyph: too long instructions " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
      FT_TRACE1(( "(0x%lx byte) is truncated\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
                 loader->glyph->control_len ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    n_ins = (FT_UInt)( loader->glyph->control_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
    origin = zone->cur[zone->n_points - 4].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
    origin = FT_PIX_ROUND( origin ) - origin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
    if ( origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
      translate_array( zone->n_points, zone->cur, origin, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
    /* save original point position in org */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
    if ( n_ins > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
      FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
    /* Reset graphics state. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
    loader->exec->GS = ((TT_Size)loader->size)->GS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
    /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
    /*      completely refer to the (already) hinted subglyphs.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
    if ( is_composite )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
      loader->exec->metrics.x_scale = 1 << 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
      loader->exec->metrics.y_scale = 1 << 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
      loader->exec->metrics.x_scale =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
        ((TT_Size)loader->size)->metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
      loader->exec->metrics.y_scale =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
        ((TT_Size)loader->size)->metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
    /* round pp2 and pp4 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
    zone->cur[zone->n_points - 3].x =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
      FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
    zone->cur[zone->n_points - 1].y =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
      FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
    if ( n_ins > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
      FT_Bool   debug;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
      FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
      FT_GlyphLoader  gloader         = loader->gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
      FT_Outline      current_outline = gloader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
      error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
                                loader->exec->glyphIns, n_ins );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
      loader->exec->is_composite = is_composite;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
      loader->exec->pts          = *zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
      debug = FT_BOOL( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
                       ((TT_Size)loader->size)->debug             );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
      error = TT_Run_Context( loader->exec, debug );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
      if ( error && loader->exec->pedantic_hinting )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
      /* store drop-out mode in bits 5-7; set bit 2 also as a marker */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
      current_outline.tags[0] |=
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
        ( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
    /* save glyph phantom points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
    if ( !loader->preserve_pps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
      loader->pp1 = zone->cur[zone->n_points - 4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
      loader->pp2 = zone->cur[zone->n_points - 3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
      loader->pp3 = zone->cur[zone->n_points - 2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
      loader->pp4 = zone->cur[zone->n_points - 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
    return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
  /*    TT_Process_Simple_Glyph                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
  /*    Once a simple glyph has been loaded, it needs to be processed.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
  /*    Usually, this means scaling and hinting through bytecode           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
  /*    interpretation.                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
  TT_Process_Simple_Glyph( TT_Loader  loader )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
    FT_GlyphLoader  gloader = loader->gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
    FT_Error        error   = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
    FT_Outline*     outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
    FT_Int          n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
    outline  = &gloader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
    n_points = outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
    /* set phantom points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
    outline->points[n_points    ] = loader->pp1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
    outline->points[n_points + 1] = loader->pp2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
    outline->points[n_points + 2] = loader->pp3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
    outline->points[n_points + 3] = loader->pp4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
    outline->tags[n_points    ] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
    outline->tags[n_points + 1] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
    outline->tags[n_points + 2] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
    outline->tags[n_points + 3] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
    n_points += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
    if ( ((TT_Face)loader->face)->doblend )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
      /* Deltas apply to the unscaled data. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
      FT_Vector*  deltas;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
      FT_Memory   memory = loader->face->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
      FT_Int      i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
      error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
                                        loader->glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
                                        &deltas,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
                                        n_points );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
      for ( i = 0; i < n_points; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
        outline->points[i].x += deltas[i].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
        outline->points[i].y += deltas[i].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
      FT_FREE( deltas );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
    if ( IS_HINTED( loader->load_flags ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
      tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
      FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
                     loader->zone.n_points + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
    /* scale the glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
    if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
      FT_Vector*  vec     = outline->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
      FT_Vector*  limit   = outline->points + n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
      FT_Fixed    x_scale = ((TT_Size)loader->size)->metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
      FT_Fixed    y_scale = ((TT_Size)loader->size)->metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
      for ( ; vec < limit; vec++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
        vec->x = FT_MulFix( vec->x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
        vec->y = FT_MulFix( vec->y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
      loader->pp1 = outline->points[n_points - 4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
      loader->pp2 = outline->points[n_points - 3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
      loader->pp3 = outline->points[n_points - 2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
      loader->pp4 = outline->points[n_points - 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
    if ( IS_HINTED( loader->load_flags ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
      loader->zone.n_points += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
      error = TT_Hint_Glyph( loader, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
  /*    TT_Process_Composite_Component                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
  /*    Once a composite component has been loaded, it needs to be         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
  /*    processed.  Usually, this means transforming and translating.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
  TT_Process_Composite_Component( TT_Loader    loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
                                  FT_SubGlyph  subglyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
                                  FT_UInt      start_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
                                  FT_UInt      num_base_points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
    FT_GlyphLoader  gloader    = loader->gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
    FT_Vector*      base_vec   = gloader->base.outline.points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
    FT_UInt         num_points = gloader->base.outline.n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
    FT_Bool         have_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
    FT_Pos          x, y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
    have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE     |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
                                              WE_HAVE_AN_XY_SCALE |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
                                              WE_HAVE_A_2X2       ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
    /* perform the transform required for this subglyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
    if ( have_scale )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
      FT_UInt  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
      for ( i = num_base_points; i < num_points; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
        FT_Vector_Transform( base_vec + i, &subglyph->transform );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
    /* get offset */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
    if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
      FT_UInt     k = subglyph->arg1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
      FT_UInt     l = subglyph->arg2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
      FT_Vector*  p1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
      FT_Vector*  p2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
      /* match l-th point of the newly loaded component to the k-th point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
      /* of the previously loaded components.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
      /* change to the point numbers used by our outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
      k += start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
      l += num_base_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
      if ( k >= num_base_points ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
           l >= num_points      )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
        return TT_Err_Invalid_Composite;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
      p1 = gloader->base.outline.points + k;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
      p2 = gloader->base.outline.points + l;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
      x = p1->x - p2->x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
      y = p1->y - p2->y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
      x = subglyph->arg1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
      y = subglyph->arg2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
      if ( !x && !y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
        return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
  /* Use a default value dependent on                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
  /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED.  This is useful for old TT */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
  /* fonts which don't set the xxx_COMPONENT_OFFSET bit.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
      if ( have_scale &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
           !( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
            ( subglyph->flags & SCALED_COMPONENT_OFFSET ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
  /* This algorithm is what Apple documents.  But it doesn't work.         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
        int  a = subglyph->transform.xx > 0 ?  subglyph->transform.xx
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
                                            : -subglyph->transform.xx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
        int  b = subglyph->transform.yx > 0 ?  subglyph->transform.yx
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
                                            : -subglyph->transform.yx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
        int  c = subglyph->transform.xy > 0 ?  subglyph->transform.xy
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
                                            : -subglyph->transform.xy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
        int  d = subglyph->transform.yy > 0 ? subglyph->transform.yy
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
                                            : -subglyph->transform.yy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
        int  m = a > b ? a : b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
        int  n = c > d ? c : d;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
        if ( a - b <= 33 && a - b >= -33 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
          m *= 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
        if ( c - d <= 33 && c - d >= -33 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
          n *= 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
        x = FT_MulFix( x, m );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
        y = FT_MulFix( y, n );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
#else /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
  /* This algorithm is a guess and works much better than the above.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
        FT_Fixed  mac_xscale = FT_SqrtFixed(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
                                 (FT_Int32)FT_MulFix( subglyph->transform.xx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
                                                      subglyph->transform.xx ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
                                 (FT_Int32)FT_MulFix( subglyph->transform.xy,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
                                                      subglyph->transform.xy ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
        FT_Fixed  mac_yscale = FT_SqrtFixed(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
                                 (FT_Int32)FT_MulFix( subglyph->transform.yy,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
                                                      subglyph->transform.yy ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
                                 (FT_Int32)FT_MulFix( subglyph->transform.yx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
                                                      subglyph->transform.yx ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
        x = FT_MulFix( x, mac_xscale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
        y = FT_MulFix( y, mac_yscale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
      if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
        FT_Fixed  x_scale = ((TT_Size)loader->size)->metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
        FT_Fixed  y_scale = ((TT_Size)loader->size)->metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
        x = FT_MulFix( x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
        y = FT_MulFix( y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
        if ( subglyph->flags & ROUND_XY_TO_GRID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
          x = FT_PIX_ROUND( x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
          y = FT_PIX_ROUND( y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
    if ( x || y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
      translate_array( num_points - num_base_points,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
                       base_vec + num_base_points,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
                       x, y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
    return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
  /*    TT_Process_Composite_Glyph                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
  /*    This is slightly different from TT_Process_Simple_Glyph, in that   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
  /*    its sole purpose is to hint the glyph.  Thus this function is      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
  /*    only available when bytecode interpreter is enabled.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
  TT_Process_Composite_Glyph( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
                              FT_UInt    start_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
                              FT_UInt    start_contour )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
    FT_Outline*  outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
    FT_UInt      i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
    outline = &loader->gloader->base.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
    /* make room for phantom points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
    error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
                                         outline->n_points + 4,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
                                         0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
    outline->points[outline->n_points    ] = loader->pp1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
    outline->points[outline->n_points + 1] = loader->pp2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
    outline->points[outline->n_points + 2] = loader->pp3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
    outline->points[outline->n_points + 3] = loader->pp4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
    outline->tags[outline->n_points    ] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
    outline->tags[outline->n_points + 1] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
    outline->tags[outline->n_points + 2] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
    outline->tags[outline->n_points + 3] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
      FT_Stream  stream = loader->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
      FT_UShort  n_ins, max_ins;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
      FT_ULong   tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
      /* TT_Load_Composite_Glyph only gives us the offset of instructions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
      /* so we read them here                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
      if ( FT_STREAM_SEEK( loader->ins_pos ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
           FT_READ_USHORT( n_ins )           )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
      FT_TRACE5(( "  Instructions size = %d\n", n_ins ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
      /* check it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
      max_ins = ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
      if ( n_ins > max_ins )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
        /* acroread ignores this field, so we only do a rough safety check */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
        if ( (FT_Int)n_ins > loader->byte_len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
          FT_TRACE1(( "TT_Process_Composite_Glyph: "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
                      "too many instructions (%d) for glyph with length %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
                      n_ins, loader->byte_len ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
          return TT_Err_Too_Many_Hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
        tmp = loader->exec->glyphSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
        error = Update_Max( loader->exec->memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
                            &tmp,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
                            sizeof ( FT_Byte ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
                            (void*)&loader->exec->glyphIns,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
                            n_ins );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
        loader->exec->glyphSize = (FT_UShort)tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
      else if ( n_ins == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
        return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
      if ( FT_STREAM_READ( loader->exec->glyphIns, n_ins ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
      loader->glyph->control_data = loader->exec->glyphIns;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
      loader->glyph->control_len  = n_ins;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
    tt_prepare_zone( &loader->zone, &loader->gloader->base,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
                     start_point, start_contour );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
    /* Some points are likely touched during execution of  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
    /* instructions on components.  So let's untouch them. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
    for ( i = start_point; i < loader->zone.n_points; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
      loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
    loader->zone.n_points += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
    return TT_Hint_Glyph( loader, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
  /* Calculate the four phantom points.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
  /* The first two stand for horizontal origin and advance. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
  /* The last two stand for vertical origin and advance.    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
#define TT_LOADER_SET_PP( loader )                                          \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
          do {                                                              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
            (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
            (loader)->pp1.y = 0;                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
            (loader)->pp2.x = (loader)->pp1.x + (loader)->advance;          \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
            (loader)->pp2.y = 0;                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
            (loader)->pp3.x = 0;                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
            (loader)->pp3.y = (loader)->top_bearing + (loader)->bbox.yMax;  \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
            (loader)->pp4.x = 0;                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
            (loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance;         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
          } while ( 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
  /*    load_truetype_glyph                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
  /*    Loads a given truetype glyph.  Handles composites and uses a       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
  /*    TT_Loader object.                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
  load_truetype_glyph( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
                       FT_UInt    glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
                       FT_UInt    recurse_count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
                       FT_Bool    header_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
    FT_Error        error        = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
    FT_Fixed        x_scale, y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
    FT_ULong        offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
    TT_Face         face         = (TT_Face)loader->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
    FT_GlyphLoader  gloader      = loader->gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
    FT_Bool         opened_frame = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
    FT_Vector*      deltas       = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
    FT_StreamRec    inc_stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
    FT_Data         glyph_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
    FT_Bool         glyph_data_loaded = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1235
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
    /* some fonts have an incorrect value of `maxComponentDepth', */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
    /* thus we allow depth 1 to catch the majority of them        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
    if ( recurse_count > 1                                   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
         recurse_count > face->max_profile.maxComponentDepth )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
      error = TT_Err_Invalid_Composite;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1244
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1246
    /* check glyph index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
    if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
      error = TT_Err_Invalid_Glyph_Index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
    loader->glyph_index = glyph_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
    if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
      x_scale = ((TT_Size)loader->size)->metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
      y_scale = ((TT_Size)loader->size)->metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
      x_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
      y_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
    tt_get_metrics( loader, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
    /* Set `offset' to the start of the glyph relative to the start of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
    /* the `glyf' table, and `byte_len' to the length of the glyph in  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
    /* bytes.                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
    /* If we are loading glyph data via the incremental interface, set */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
    /* the loader stream to a memory stream reading the data returned  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1276
    /* by the interface.                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1277
    if ( face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
      error = face->root.internal->incremental_interface->funcs->get_glyph_data(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
                face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
                glyph_index, &glyph_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1285
      glyph_data_loaded = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1286
      offset            = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
      loader->byte_len  = glyph_data.length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
      FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
      FT_Stream_OpenMemory( &inc_stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
                            glyph_data.pointer, glyph_data.length );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1293
      loader->stream = &inc_stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
      offset = tt_face_get_location( face, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
                                     (FT_UInt*)&loader->byte_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
    if ( loader->byte_len > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
      /* for the incremental interface, `glyf_offset' is always zero */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1306
      if ( !loader->glyf_offset                        &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
           !face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
      if ( !loader->glyf_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
        FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
        error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
      error = face->access_glyph_frame( loader, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
                                        loader->glyf_offset + offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
                                        loader->byte_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
      opened_frame = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
      /* read glyph header first */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1326
      error = face->read_glyph_header( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1327
      if ( error || header_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
    if ( loader->byte_len == 0 || loader->n_contours == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
      loader->bbox.xMin = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
      loader->bbox.xMax = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
      loader->bbox.yMin = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
      loader->bbox.yMax = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
      if ( header_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1341
      /* must initialize points before (possibly) overriding */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1342
      /* glyph metrics from the incremental interface        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
      TT_LOADER_SET_PP( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
      tt_get_metrics_incr_overrides( loader, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
      if ( ((TT_Face)(loader->face))->doblend )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
        /* this must be done before scaling */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
        FT_Memory  memory = loader->face->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
        error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
                                          glyph_index, &deltas, 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
        loader->pp1.x += deltas[0].x; loader->pp1.y += deltas[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
        loader->pp2.x += deltas[1].x; loader->pp2.y += deltas[1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1364
        loader->pp3.x += deltas[2].x; loader->pp3.y += deltas[2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1365
        loader->pp4.x += deltas[3].x; loader->pp4.y += deltas[3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
        FT_FREE( deltas );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1370
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
      if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1374
        loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1375
        loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
        loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
        loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
      error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
    /* must initialize points before (possibly) overriding */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1385
    /* glyph metrics from the incremental interface        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1386
    TT_LOADER_SET_PP( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
    tt_get_metrics_incr_overrides( loader, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1392
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1393
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
    /* if it is a simple glyph, load it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
    if ( loader->n_contours > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
      error = face->read_simple_glyph( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1401
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1402
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
      /* all data have been read */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
      face->forget_glyph_frame( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
      opened_frame = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
      error = TT_Process_Simple_Glyph( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
      FT_GlyphLoader_Add( gloader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1417
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
    /* otherwise, load a composite! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1420
    else if ( loader->n_contours == -1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1421
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
      FT_UInt   start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1423
      FT_UInt   start_contour;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1424
      FT_ULong  ins_pos;  /* position of composite instructions, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
      start_point   = gloader->base.outline.n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1428
      start_contour = gloader->base.outline.n_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
      /* for each subglyph, read composite header */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1431
      error = face->read_composite_glyph( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1432
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
      /* store the offset of instructions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1436
      ins_pos = loader->ins_pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
      /* all data we need are read */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
      face->forget_glyph_frame( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
      opened_frame = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
      if ( face->doblend )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
        FT_Int       i, limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
        FT_SubGlyph  subglyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
        FT_Memory    memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
        /* this provides additional offsets */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
        /* for each component's translation */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
        if ( ( error = TT_Vary_Get_Glyph_Deltas(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1455
                         face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1456
                         glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
                         &deltas,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
                         gloader->current.num_subglyphs + 4 )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
        subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
        limit    = gloader->current.num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1464
        for ( i = 0; i < limit; ++i, ++subglyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1466
          if ( subglyph->flags & ARGS_ARE_XY_VALUES )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1467
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1468
            /* XXX: overflow check for subglyph->{arg1,arg2}.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1469
            /* deltas[i].{x,y} must be within signed 16-bit,    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
            /* but the restriction of summed delta is not clear */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
            subglyph->arg1 += (FT_Int16)deltas[i].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
            subglyph->arg2 += (FT_Int16)deltas[i].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1474
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1475
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
        loader->pp1.x += deltas[i + 0].x; loader->pp1.y += deltas[i + 0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
        loader->pp2.x += deltas[i + 1].x; loader->pp2.y += deltas[i + 1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
        loader->pp3.x += deltas[i + 2].x; loader->pp3.y += deltas[i + 2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
        loader->pp4.x += deltas[i + 3].x; loader->pp4.y += deltas[i + 3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1481
        FT_FREE( deltas );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1482
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1483
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1486
      if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1487
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
        loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
        loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
        loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
        loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
      /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
      /* `as is' in the glyph slot (the client application will be     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
      /* responsible for interpreting these data)...                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
      if ( loader->load_flags & FT_LOAD_NO_RECURSE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
        FT_GlyphLoader_Add( gloader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1500
        loader->glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1501
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1506
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1507
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
        FT_UInt      n, num_base_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1511
        FT_SubGlyph  subglyph       = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1512
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
        FT_UInt      num_points     = start_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
        FT_UInt      num_subglyphs  = gloader->current.num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
        FT_UInt      num_base_subgs = gloader->base.num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
        FT_Stream    old_stream     = loader->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
        FT_Int       old_byte_len   = loader->byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
        FT_GlyphLoader_Add( gloader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
        /* read each subglyph independently */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1524
        for ( n = 0; n < num_subglyphs; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1525
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
          FT_Vector  pp[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
          /* Each time we call load_truetype_glyph in this loop, the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
          /* value of `gloader.base.subglyphs' can change due to table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
          /* reallocations.  We thus need to recompute the subglyph    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1532
          /* pointer on each iteration.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1533
          subglyph = gloader->base.subglyphs + num_base_subgs + n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1534
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1535
          pp[0] = loader->pp1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1536
          pp[1] = loader->pp2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1537
          pp[2] = loader->pp3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1538
          pp[3] = loader->pp4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1540
          num_base_points = gloader->base.outline.n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1542
          error = load_truetype_glyph( loader, subglyph->index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1543
                                       recurse_count + 1, FALSE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1544
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1545
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1547
          /* restore subglyph pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1548
          subglyph = gloader->base.subglyphs + num_base_subgs + n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1549
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1550
          if ( !( subglyph->flags & USE_MY_METRICS ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1551
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1552
            loader->pp1 = pp[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1553
            loader->pp2 = pp[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1554
            loader->pp3 = pp[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1555
            loader->pp4 = pp[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1556
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1557
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1558
          num_points = gloader->base.outline.n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1559
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1560
          if ( num_points == num_base_points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1561
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1563
          /* gloader->base.outline consists of three parts:               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1564
          /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1565
          /*                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1566
          /* (1): exists from the beginning                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1567
          /* (2): components that have been loaded so far                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1568
          /* (3): the newly loaded component                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1569
          TT_Process_Composite_Component( loader, subglyph, start_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1570
                                          num_base_points );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1571
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1572
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1573
        loader->stream   = old_stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1574
        loader->byte_len = old_byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1576
        /* process the glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1577
        loader->ins_pos = ins_pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1578
        if ( IS_HINTED( loader->load_flags ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1580
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1581
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1582
             subglyph->flags & WE_HAVE_INSTR &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1584
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1585
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1586
             num_points > start_point )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1587
          TT_Process_Composite_Glyph( loader, start_point, start_contour );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1588
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1589
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1590
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1591
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1592
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1593
      /* invalid composite count (negative but not -1) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1594
      error = TT_Err_Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1595
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1596
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1597
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1598
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1599
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1600
    /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1601
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1602
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1603
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1604
    if ( opened_frame )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1605
      face->forget_glyph_frame( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1607
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1608
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1609
    if ( glyph_data_loaded )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1610
      face->root.internal->incremental_interface->funcs->free_glyph_data(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1611
        face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1612
        &glyph_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1614
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1615
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1616
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1617
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1618
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1619
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1620
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1621
  compute_glyph_metrics( TT_Loader  loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1622
                         FT_UInt    glyph_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1623
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1624
    FT_BBox       bbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1625
    TT_Face       face = (TT_Face)loader->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1626
    FT_Fixed      y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1627
    TT_GlyphSlot  glyph = loader->glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1628
    TT_Size       size = (TT_Size)loader->size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1631
    y_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1632
    if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1633
      y_scale = size->root.metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1635
    if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1636
      FT_Outline_Get_CBox( &glyph->outline, &bbox );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1637
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1638
      bbox = loader->bbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1639
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1640
    /* get the device-independent horizontal advance; it is scaled later */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1641
    /* by the base layer.                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1642
    glyph->linearHoriAdvance = loader->linear;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1643
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1644
    glyph->metrics.horiBearingX = bbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1645
    glyph->metrics.horiBearingY = bbox.yMax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1646
    glyph->metrics.horiAdvance  = loader->pp2.x - loader->pp1.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1647
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1648
    /* adjust advance width to the value contained in the hdmx table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1649
    if ( !face->postscript.isFixedPitch  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1650
         IS_HINTED( loader->load_flags ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1651
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1652
      FT_Byte*  widthp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1653
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1654
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1655
      widthp = tt_face_get_device_metrics( face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1656
                                           size->root.metrics.x_ppem,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1657
                                           glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1658
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1659
      if ( widthp )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1660
        glyph->metrics.horiAdvance = *widthp << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1661
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1662
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1663
    /* set glyph dimensions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1664
    glyph->metrics.width  = bbox.xMax - bbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1665
    glyph->metrics.height = bbox.yMax - bbox.yMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1667
    /* Now take care of vertical metrics.  In the case where there is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1668
    /* no vertical information within the font (relatively common),   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1669
    /* create some metrics manually                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1670
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1671
      FT_Pos  top;      /* scaled vertical top side bearing  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1672
      FT_Pos  advance;  /* scaled vertical advance height    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1673
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1674
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1675
      /* Get the unscaled top bearing and advance height. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1676
      if ( face->vertical_info                   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1677
           face->vertical.number_Of_VMetrics > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1678
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1679
        top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1680
                                   y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1681
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1682
        if ( loader->pp3.y <= loader->pp4.y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1683
          advance = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1684
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1685
          advance = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1686
                                          y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1687
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1688
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1689
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1690
        FT_Pos  height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1691
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1692
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1693
        /* XXX Compute top side bearing and advance height in  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1694
        /*     Get_VMetrics instead of here.                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1695
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1696
        /* NOTE: The OS/2 values are the only `portable' ones, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1697
        /*       which is why we use them, if there is an OS/2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1698
        /*       table in the font.  Otherwise, we use the     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1699
        /*       values defined in the horizontal header.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1700
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1701
        height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1702
                                      y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1703
        if ( face->os2.version != 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1704
          advance = (FT_Pos)( face->os2.sTypoAscender -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1705
                              face->os2.sTypoDescender );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1706
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1707
          advance = (FT_Pos)( face->horizontal.Ascender -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1708
                              face->horizontal.Descender );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1709
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1710
        top = ( advance - height ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1711
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1712
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1713
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1714
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1715
        FT_Incremental_InterfaceRec*  incr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1716
        FT_Incremental_MetricsRec     metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1717
        FT_Error                      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1718
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1719
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1720
        incr = face->root.internal->incremental_interface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1721
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1722
        /* If this is an incrementally loaded font see if there are */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1723
        /* overriding metrics for this glyph.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1724
        if ( incr && incr->funcs->get_glyph_metrics )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1725
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1726
          metrics.bearing_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1727
          metrics.bearing_y = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1728
          metrics.advance   = advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1729
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1730
          error = incr->funcs->get_glyph_metrics( incr->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1731
                                                  glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1732
                                                  TRUE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1733
                                                  &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1734
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1735
            return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1736
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1737
          top     = metrics.bearing_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1738
          advance = metrics.advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1739
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1740
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1741
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1742
      /* GWW: Do vertical metrics get loaded incrementally too? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1743
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1744
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1745
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1746
      glyph->linearVertAdvance = advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1748
      /* scale the metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1749
      if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1750
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1751
        top     = FT_MulFix( top,     y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1752
        advance = FT_MulFix( advance, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1753
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1754
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1755
      /* XXX: for now, we have no better algorithm for the lsb, but it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1756
      /*      should work fine.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1757
      /*                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1758
      glyph->metrics.vertBearingX = glyph->metrics.horiBearingX -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1759
                                      glyph->metrics.horiAdvance / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1760
      glyph->metrics.vertBearingY = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1761
      glyph->metrics.vertAdvance  = advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1762
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1764
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1765
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1766
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1767
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1768
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1770
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1771
  load_sbit_image( TT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1772
                   TT_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1773
                   FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1774
                   FT_Int32      load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1775
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1776
    TT_Face             face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1777
    SFNT_Service        sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1778
    FT_Stream           stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1779
    FT_Error            error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1780
    TT_SBit_MetricsRec  metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1781
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1782
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1783
    face   = (TT_Face)glyph->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1784
    sfnt   = (SFNT_Service)face->sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1785
    stream = face->root.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1786
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1787
    error = sfnt->load_sbit_image( face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1788
                                   size->strike_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1789
                                   glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1790
                                   (FT_Int)load_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1791
                                   stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1792
                                   &glyph->bitmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1793
                                   &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1794
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1795
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1796
      glyph->outline.n_points   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1797
      glyph->outline.n_contours = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1799
      glyph->metrics.width  = (FT_Pos)metrics.width  << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1800
      glyph->metrics.height = (FT_Pos)metrics.height << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1801
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1802
      glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1803
      glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1804
      glyph->metrics.horiAdvance  = (FT_Pos)metrics.horiAdvance  << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1805
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1806
      glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1807
      glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1808
      glyph->metrics.vertAdvance  = (FT_Pos)metrics.vertAdvance  << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1810
      glyph->format = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1811
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1812
      if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1813
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1814
        glyph->bitmap_left = metrics.vertBearingX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1815
        glyph->bitmap_top  = metrics.vertBearingY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1816
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1817
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1818
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1819
        glyph->bitmap_left = metrics.horiBearingX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1820
        glyph->bitmap_top  = metrics.horiBearingY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1821
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1822
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1823
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1824
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1825
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1826
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1827
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1828
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1830
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1831
  tt_loader_init( TT_Loader     loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1832
                  TT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1833
                  TT_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1834
                  FT_Int32      load_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1835
                  FT_Bool       glyf_table_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1836
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1837
    TT_Face    face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1838
    FT_Stream  stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1839
    FT_Bool    pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1840
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1841
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1842
    face   = (TT_Face)glyph->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1843
    stream = face->root.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1845
    FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1846
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1847
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1848
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1849
    /* load execution context */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1850
    if ( IS_HINTED( load_flags ) && !glyf_table_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1851
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1852
      TT_ExecContext  exec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1853
      FT_Bool         grayscale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1854
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1855
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1856
      if ( !size->cvt_ready )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1857
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1858
        FT_Error  error = tt_size_ready_bytecode( size, pedantic );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1859
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1861
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1862
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1863
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1864
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1865
      /* query new execution context */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1866
      exec = size->debug ? size->context
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1867
                         : ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1868
      if ( !exec )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1869
        return TT_Err_Could_Not_Find_Context;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1871
      grayscale =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1872
        FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1873
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1874
      TT_Load_Context( exec, face, size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1875
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1876
      /* a change from mono to grayscale rendering (and vice versa) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1877
      /* requires a re-execution of the CVT program                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1878
      if ( grayscale != exec->grayscale )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1879
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1880
        FT_UInt  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1882
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1883
        FT_TRACE4(( "tt_loader_init: grayscale change,"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1884
                    " re-executing `prep' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1885
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1886
        exec->grayscale = grayscale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1887
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1888
        for ( i = 0; i < size->cvt_size; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1889
          size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1890
        tt_size_run_prep( size, pedantic );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1891
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1892
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1893
      /* see whether the cvt program has disabled hinting */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1894
      if ( exec->GS.instruct_control & 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1895
        load_flags |= FT_LOAD_NO_HINTING;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1896
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1897
      /* load default graphics state -- if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1898
      if ( exec->GS.instruct_control & 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1899
        exec->GS = tt_default_graphics_state;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1900
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1901
      exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1902
      loader->exec = exec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1903
      loader->instructions = exec->glyphIns;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1904
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1905
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1906
#endif /* TT_USE_BYTECODE_INTERPRETER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1907
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1908
    /* seek to the beginning of the glyph table -- for Type 42 fonts     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1909
    /* the table might be accessed from a Postscript stream or something */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1910
    /* else...                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1911
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1912
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1913
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1914
    if ( face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1915
      loader->glyf_offset = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1916
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1917
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1918
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1919
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1920
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1921
      FT_Error  error = face->goto_table( face, TTAG_glyf, stream, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1922
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1923
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1924
      if ( error == TT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1925
        loader->glyf_offset = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1926
      else if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1927
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1928
        FT_ERROR(( "tt_loader_init: could not access glyph table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1929
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1930
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1931
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1932
        loader->glyf_offset = FT_STREAM_POS();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1933
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1934
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1935
    /* get face's glyph loader */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1936
    if ( !glyf_table_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1937
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1938
      FT_GlyphLoader  gloader = glyph->internal->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1939
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1940
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1941
      FT_GlyphLoader_Rewind( gloader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1942
      loader->gloader = gloader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1943
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1944
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1945
    loader->load_flags = load_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1946
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1947
    loader->face   = (FT_Face)face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1948
    loader->size   = (FT_Size)size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1949
    loader->glyph  = (FT_GlyphSlot)glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1950
    loader->stream = stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1951
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1952
    return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1953
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1954
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1955
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1956
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1957
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1958
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1959
  /*    TT_Load_Glyph                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1960
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1961
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1962
  /*    A function used to load a single glyph within a given glyph slot,  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1963
  /*    for a given size.                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1964
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1965
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1966
  /*    glyph       :: A handle to a target slot object where the glyph    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1967
  /*                   will be loaded.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1968
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1969
  /*    size        :: A handle to the source face size at which the glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1970
  /*                   must be scaled/loaded.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1971
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1972
  /*    glyph_index :: The index of the glyph in the font file.            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1973
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1974
  /*    load_flags  :: A flag indicating what to load for this glyph.  The */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1975
  /*                   FT_LOAD_XXX constants can be used to control the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1976
  /*                   glyph loading process (e.g., whether the outline    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1977
  /*                   should be scaled, whether to load bitmaps or not,   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1978
  /*                   whether to hint the outline, etc).                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1979
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1980
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1981
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1982
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1983
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1984
  TT_Load_Glyph( TT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1985
                 TT_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1986
                 FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1987
                 FT_Int32      load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1988
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1989
    TT_Face       face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1990
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1991
    TT_LoaderRec  loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1992
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1993
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1994
    face   = (TT_Face)glyph->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1995
    error  = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1996
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1997
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1998
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1999
    /* try to load embedded bitmap if any              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2000
    /*                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2001
    /* XXX: The convention should be emphasized in     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2002
    /*      the documents because it can be confusing. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2003
    if ( size->strike_index != 0xFFFFFFFFUL      &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2004
         ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2005
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2006
      error = load_sbit_image( size, glyph, glyph_index, load_flags );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2007
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2008
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2009
        FT_Face  root = &face->root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2010
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2011
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2012
        if ( FT_IS_SCALABLE( root ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2013
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2014
          /* for the bbox we need the header only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2015
          (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2016
          (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2017
          glyph->linearHoriAdvance = loader.linear;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2018
          glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2019
                                       loader.vadvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2020
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2021
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2022
        return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2023
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2024
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2025
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2026
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2027
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2028
    /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2029
    if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2030
      return TT_Err_Invalid_Size_Handle;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2031
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2032
    if ( load_flags & FT_LOAD_SBITS_ONLY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2033
      return TT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2034
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2035
    error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2036
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2037
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2038
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2039
    glyph->format        = FT_GLYPH_FORMAT_OUTLINE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2040
    glyph->num_subglyphs = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2041
    glyph->outline.flags = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2042
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2043
    /* main loading loop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2044
    error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2045
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2046
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2047
      if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2048
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2049
        glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2050
        glyph->subglyphs     = loader.gloader->base.subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2051
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2052
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2053
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2054
        glyph->outline        = loader.gloader->base.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2055
        glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2056
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2057
        /* Translate array so that (0,0) is the glyph's origin.  Note  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2058
        /* that this behaviour is independent on the value of bit 1 of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2059
        /* the `flags' field in the `head' table -- at least major     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2060
        /* applications like Acroread indicate that.                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2061
        if ( loader.pp1.x )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2062
          FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2063
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2064
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2065
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2067
      if ( IS_HINTED( load_flags ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2068
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2069
        if ( loader.exec->GS.scan_control )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2070
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2071
          /* convert scan conversion mode to FT_OUTLINE_XXX flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2072
          switch ( loader.exec->GS.scan_type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2073
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2074
          case 0: /* simple drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2075
            glyph->outline.flags |= FT_OUTLINE_INCLUDE_STUBS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2076
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2077
          case 1: /* simple drop-outs excluding stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2078
            /* nothing; it's the default rendering mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2079
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2080
          case 4: /* smart drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2081
            glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2082
                                    FT_OUTLINE_INCLUDE_STUBS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2083
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2084
          case 5: /* smart drop-outs excluding stubs  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2085
            glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2086
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2087
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2088
          default: /* no drop-out control */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2089
            glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2090
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2091
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2092
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2093
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2094
          glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2095
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2096
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2097
#endif /* TT_USE_BYTECODE_INTERPRETER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2098
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2099
      compute_glyph_metrics( &loader, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2100
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2102
    /* Set the `high precision' bit flag.                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2103
    /* This is _critical_ to get correct output for monochrome      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2104
    /* TrueType glyphs at all sizes using the bytecode interpreter. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2105
    /*                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2106
    if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2107
         size->root.metrics.y_ppem < 24     )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2108
      glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2110
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2111
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2114
/* END */