misc/libfreetype/src/type1/t1gload.c
author vitiv <nikita.utiu@gmail.com>
Sun, 30 Dec 2012 16:04:28 +0200
changeset 8345 9d9b498cfb03
parent 5172 88f2e05288ba
permissions -rw-r--r--
Preserve windowed resolution after manual resize
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
/*  t1gload.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
/*    Type 1 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-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include "t1gload.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_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include FT_INTERNAL_POSTSCRIPT_AUX_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 "t1errors.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /* 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
    33
  /* 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
    34
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#define FT_COMPONENT  trace_t1gload
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /*************************************************************************/
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
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /**********            COMPUTE THE MAXIMUM ADVANCE WIDTH         *********/
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
  /**********    The following code is in charge of computing      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /**********    the maximum advance width of the font.  It        *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  /**********    quickly processes each glyph charstring to        *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  /**********    extract the value from either a `sbw' or `seac'   *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  /**********    operator.                                         *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  T1_Parse_Glyph_And_Get_Char_String( T1_Decoder  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
                                      FT_UInt     glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
                                      FT_Data*    char_string )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    T1_Face   face  = (T1_Face)decoder->builder.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    T1_Font   type1 = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    FT_Error  error = T1_Err_Ok;
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
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    FT_Incremental_InterfaceRec *inc =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
                      face->root.internal->incremental_interface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    decoder->font_matrix = type1->font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    decoder->font_offset = type1->font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    /* For incremental fonts get the character data using the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    /* callback function.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    if ( inc )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
      error = inc->funcs->get_glyph_data( inc->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
                                          glyph_index, char_string );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    else
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
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    /* For ordinary fonts get the character data stored in the face record. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
      char_string->pointer = type1->charstrings[glyph_index];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
      char_string->length  = (FT_Int)type1->charstrings_len[glyph_index];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      error = decoder->funcs.parse_charstrings(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
                decoder, (FT_Byte*)char_string->pointer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
                char_string->length );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
#ifdef FT_CONFIG_OPTION_INCREMENTAL
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
    /* Incremental fonts can optionally override the metrics. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    if ( !error && inc && inc->funcs->get_glyph_metrics )
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
      FT_Incremental_MetricsRec  metrics;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
      metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
      metrics.bearing_y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      metrics.advance   = FIXED_TO_INT( decoder->builder.advance.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
      metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y );
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
      error = inc->funcs->get_glyph_metrics( inc->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
                                             glyph_index, FALSE, &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
      decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
      decoder->builder.advance.x      = INT_TO_FIXED( metrics.advance );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
      decoder->builder.advance.y      = INT_TO_FIXED( metrics.advance_v );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
  T1_Parse_Glyph( T1_Decoder  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
                  FT_UInt     glyph_index )
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
    FT_Data   glyph_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    FT_Error  error = T1_Parse_Glyph_And_Get_Char_String(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
                        decoder, glyph_index, &glyph_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      T1_Face  face = (T1_Face)decoder->builder.face;
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
      if ( face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
        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
   142
          face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
          &glyph_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
  T1_Compute_Max_Advance( T1_Face  face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
                          FT_Pos*  max_advance )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    FT_Error       error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    T1_DecoderRec  decoder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    FT_Int         glyph_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    T1_Font        type1 = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    PSAux_Service  psaux = (PSAux_Service)face->psaux;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    *max_advance = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    /* initialize load decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    error = psaux->t1_decoder_funcs->init( &decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
                                           (FT_Face)face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
                                           0, /* size       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
                                           0, /* glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
                                           (FT_Byte**)type1->glyph_names,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
                                           face->blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
                                           0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
                                           FT_RENDER_MODE_NORMAL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
                                           T1_Parse_Glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
      return 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
    decoder.builder.metrics_only = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    decoder.builder.load_points  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    decoder.num_subrs     = type1->num_subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    decoder.subrs         = type1->subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    decoder.subrs_len     = type1->subrs_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    decoder.buildchar     = face->buildchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
    decoder.len_buildchar = face->len_buildchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    *max_advance = 0;
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
    /* for each glyph, parse the glyph charstring and extract */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    /* the advance width                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      /* now get load the unscaled outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      error = T1_Parse_Glyph( &decoder, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
      if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
        *max_advance = decoder.builder.advance.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
      /* ignore the error if one occurred - skip to next glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    psaux->t1_decoder_funcs->done( &decoder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    return T1_Err_Ok;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
  T1_Get_Advances( T1_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
                   FT_UInt    first,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
                   FT_UInt    count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
                   FT_ULong   load_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
                   FT_Fixed*  advances )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    T1_DecoderRec  decoder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    T1_Font        type1 = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    PSAux_Service  psaux = (PSAux_Service)face->psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    FT_UInt        nn;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    FT_Error       error;
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
    if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
      for ( nn = 0; nn < count; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
        advances[nn] = 0;
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
      return T1_Err_Ok;
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
    error = psaux->t1_decoder_funcs->init( &decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
                                           (FT_Face)face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
                                           0, /* size       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
                                           0, /* glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
                                           (FT_Byte**)type1->glyph_names,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
                                           face->blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
                                           0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
                                           FT_RENDER_MODE_NORMAL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
                                           T1_Parse_Glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
      return error;
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
    decoder.builder.metrics_only = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    decoder.builder.load_points  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    decoder.num_subrs = type1->num_subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
    decoder.subrs     = type1->subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    decoder.subrs_len = type1->subrs_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    decoder.buildchar     = face->buildchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    decoder.len_buildchar = face->len_buildchar;
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
    for ( nn = 0; nn < count; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
      error = T1_Parse_Glyph( &decoder, first + nn );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
        advances[nn] = FIXED_TO_INT( decoder.builder.advance.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
        advances[nn] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    return T1_Err_Ok;
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_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
  T1_Load_Glyph( T1_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
                 T1_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
                 FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
                 FT_Int32      load_flags )
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
    T1_DecoderRec           decoder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
    T1_Face                 face = (T1_Face)glyph->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
    FT_Bool                 hinting;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    T1_Font                 type1         = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    PSAux_Service           psaux         = (PSAux_Service)face->psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    const T1_Decoder_Funcs  decoder_funcs = psaux->t1_decoder_funcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
    FT_Matrix               font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
    FT_Vector               font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    FT_Data                 glyph_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    FT_Bool                 must_finish_decoder = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    FT_Bool                 glyph_data_loaded = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
#endif
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    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
   292
         !face->root.internal->incremental_interface   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    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
   295
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      error = T1_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    }
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
    FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
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
    if ( load_flags & FT_LOAD_NO_RECURSE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
      load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
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
    if ( size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
      glyph->x_scale = size->root.metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
      glyph->y_scale = size->root.metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
    else
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
      glyph->x_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
      glyph->y_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    glyph->root.outline.n_points   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    glyph->root.outline.n_contours = 0;
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
    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
                       ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    error = decoder_funcs->init( &decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
                                 (FT_Face)face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
                                 (FT_Size)size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
                                 (FT_GlyphSlot)glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
                                 (FT_Byte**)type1->glyph_names,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
                                 face->blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
                                 FT_BOOL( hinting ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
                                 FT_LOAD_TARGET_MODE( load_flags ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
                                 T1_Parse_Glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    must_finish_decoder = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    decoder.builder.no_recurse = FT_BOOL(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
                                   ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    decoder.num_subrs     = type1->num_subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
    decoder.subrs         = type1->subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
    decoder.subrs_len     = type1->subrs_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
    decoder.buildchar     = face->buildchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
    decoder.len_buildchar = face->len_buildchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    /* now load the unscaled outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
                                                &glyph_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
    glyph_data_loaded = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
    font_matrix = decoder.font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    font_offset = decoder.font_offset;
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
    /* save new glyph tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    decoder_funcs->done( &decoder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    must_finish_decoder = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
    /* now, set the metrics -- this is rather simple, as   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    /* the left side bearing is the xMin, and the top side */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
    /* bearing the yMax                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
      glyph->root.outline.flags &= FT_OUTLINE_OWNER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
      glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
      /* for composite glyphs, return only left side bearing and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
      /* advance width                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
      if ( load_flags & FT_LOAD_NO_RECURSE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
        FT_Slot_Internal  internal = glyph->root.internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
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
        glyph->root.metrics.horiBearingX =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
          FIXED_TO_INT( decoder.builder.left_bearing.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
        glyph->root.metrics.horiAdvance  =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
          FIXED_TO_INT( decoder.builder.advance.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
        internal->glyph_matrix      = font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
        internal->glyph_delta       = font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
        internal->glyph_transformed = 1;
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
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
        FT_BBox            cbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
        FT_Glyph_Metrics*  metrics = &glyph->root.metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
        FT_Vector          advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
        /* copy the _unscaled_ advance width */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
        metrics->horiAdvance =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
          FIXED_TO_INT( decoder.builder.advance.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
        glyph->root.linearHoriAdvance =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
          FIXED_TO_INT( decoder.builder.advance.x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
        glyph->root.internal->glyph_transformed = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
        if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) 
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
          /* make up vertical ones */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
          metrics->vertAdvance = ( face->type1.font_bbox.yMax -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
                                   face->type1.font_bbox.yMin ) >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
          glyph->root.linearVertAdvance = metrics->vertAdvance;
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
        else
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
          metrics->vertAdvance =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
            FIXED_TO_INT( decoder.builder.advance.y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
          glyph->root.linearVertAdvance =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
            FIXED_TO_INT( decoder.builder.advance.y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
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 ( size && size->root.metrics.y_ppem < 24 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
          glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
        /* apply the font matrix, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
        if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
             font_matrix.xy != 0        || font_matrix.yx != 0              )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
          FT_Outline_Transform( &glyph->root.outline, &font_matrix );
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 ( font_offset.x || font_offset.y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
          FT_Outline_Translate( &glyph->root.outline,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
                                font_offset.x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
                                font_offset.y );
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
        advance.x = metrics->horiAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
        advance.y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        FT_Vector_Transform( &advance, &font_matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
        metrics->horiAdvance = advance.x + font_offset.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
        advance.x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        advance.y = metrics->vertAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
        FT_Vector_Transform( &advance, &font_matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
        metrics->vertAdvance = advance.y + font_offset.y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
        if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
          /* scale the outline and the metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
          FT_Int       n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
          FT_Outline*  cur = decoder.builder.base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
          FT_Vector*   vec = cur->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
          FT_Fixed     x_scale = glyph->x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
          FT_Fixed     y_scale = glyph->y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
          /* First of all, scale the points, if we are not hinting */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
          if ( !hinting || ! decoder.builder.hints_funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
            for ( n = cur->n_points; n > 0; n--, vec++ )
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
              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
   460
              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
   461
            }
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
          /* Then scale the metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
          metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
          metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
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
        /* compute the other metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
        metrics->width  = cbox.xMax - cbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
        metrics->height = cbox.yMax - cbox.yMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
        metrics->horiBearingX = cbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
        metrics->horiBearingY = cbox.yMax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
        if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
          /* make up vertical ones */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
          ft_synthesize_vertical_metrics( metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
                                          metrics->vertAdvance );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
      /* Set control data to the glyph charstrings.  Note that this is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
      /* _not_ zero-terminated.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
      glyph->root.control_data = (FT_Byte*)glyph_data.pointer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
      glyph->root.control_len  = glyph_data.length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
    if ( glyph_data_loaded && face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
      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
   498
        face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
        &glyph_data );
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
      /* Set the control data to null - it is no longer available if   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
      /* loaded incrementally.                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
      glyph->root.control_data = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
      glyph->root.control_len  = 0;
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
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
    if ( must_finish_decoder )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
      decoder_funcs->done( &decoder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
/* END */