misc/libfreetype/src/type1/t1afm.c
author c_korn
Mon, 03 Jun 2013 23:25:15 +0200
branch0.9.19
changeset 9112 cefab5ac8f0f
parent 5172 88f2e05288ba
permissions -rw-r--r--
http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#deprecated-items - The Encoding key is deprecated.
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
/*  t1afm.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
/*    AFM support for Type 1 fonts (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, 2007, 2008, 2009,   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*            2010 by                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  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
    12
/*  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
    13
/*  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
    14
/*  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
    15
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "t1afm.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include "t1errors.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_INTERNAL_POSTSCRIPT_AUX_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
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
  /*************************************************************************/
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
  /* 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
    30
  /* 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
    31
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
#define FT_COMPONENT  trace_t1afm
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  T1_Done_Metrics( FT_Memory     memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
                   AFM_FontInfo  fi )
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
    FT_FREE( fi->KernPairs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
    fi->NumKernPair = 0;
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
    FT_FREE( fi->TrackKerns );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    fi->NumTrackKern = 0;
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
    FT_FREE( fi );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  /* read a glyph name and return the equivalent glyph index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  static FT_Int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  t1_get_index( const char*  name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
                FT_Offset    len,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
                void*        user_data )
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
    T1_Font  type1 = (T1_Font)user_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    FT_Int   n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    /* PS string/name length must be < 16-bit */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    if ( len > 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      return 0;
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
    for ( n = 0; n < type1->num_glyphs; n++ )
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
      char*  gname = (char*)type1->glyph_names[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
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
      if ( gname && gname[0] == name[0]        &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
           ft_strlen( gname ) == len           &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
           ft_strncmp( gname, name, len ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
        return n;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    return 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
#undef  KERN_INDEX
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
#define KERN_INDEX( g1, g2 )  ( ( (FT_ULong)(g1) << 16 ) | (g2) )
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
  /* compare two kerning pairs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  FT_CALLBACK_DEF( int )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  compare_kern_pairs( const void*  a,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
                      const void*  b )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    AFM_KernPair  pair1 = (AFM_KernPair)a;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    AFM_KernPair  pair2 = (AFM_KernPair)b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    FT_ULong  index1 = KERN_INDEX( pair1->index1, pair1->index2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    FT_ULong  index2 = KERN_INDEX( pair2->index1, pair2->index2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    if ( index1 > index2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      return 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    else if ( index1 < index2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
  }
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
  /* parse a PFM file -- for now, only read the kerning pairs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  T1_Read_PFM( FT_Face       t1_face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
               FT_Stream     stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
               AFM_FontInfo  fi )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FT_Error      error = T1_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    FT_Memory     memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    FT_Byte*      start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    FT_Byte*      limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    FT_Byte*      p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    AFM_KernPair  kp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    FT_Int        width_table_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
    FT_CharMap    oldcharmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    FT_CharMap    charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    FT_Int        n;
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
    start = (FT_Byte*)stream->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    limit = (FT_Byte*)stream->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    p     = start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    /* Figure out how long the width table is.          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    /* This info is a little-endian short at offset 99. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    p = start + 99;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    if ( p + 2 > limit )
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
      error = T1_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
      goto Exit;
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
    width_table_length = FT_PEEK_USHORT_LE( p );
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
    p += 18 + width_table_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    if ( p + 0x12 > limit || FT_PEEK_USHORT_LE( p ) < 0x12 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      /* extension table is probably optional */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    /* Kerning offset is 14 bytes from start of extensions table. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    p += 14;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    p = start + FT_PEEK_ULONG_LE( p );
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
    if ( p == start )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      /* zero offset means no table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      goto Exit;
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
    if ( p + 2 > limit )
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
      error = T1_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    fi->NumKernPair = FT_PEEK_USHORT_LE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    p += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    if ( p + 4 * fi->NumKernPair > limit )
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
      error = T1_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    /* Actually, kerning pairs are simply optional! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    if ( fi->NumKernPair == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      goto Exit;
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
    /* allocate the pairs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    /* now, read each kern pair */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    kp             = fi->KernPairs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    limit          = p + 4 * fi->NumKernPair;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    /* PFM kerning data are stored by encoding rather than glyph index, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    /* so find the PostScript charmap of this font and install it       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    /* temporarily.  If we find no PostScript charmap, then just use    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    /* the default and hope it is the right one.                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    oldcharmap = t1_face->charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    charmap    = NULL;
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
    for ( n = 0; n < t1_face->num_charmaps; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
      charmap = t1_face->charmaps[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      /* check against PostScript pseudo platform */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
      if ( charmap->platform_id == 7 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
        error = FT_Set_Charmap( t1_face, charmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    /* Kerning info is stored as:             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    /*                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    /*   encoding of first glyph (1 byte)     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    /*   encoding of second glyph (1 byte)    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    /*   offset (little-endian short)         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    for ( ; p < limit ; p += 4 )
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
      kp->index1 = FT_Get_Char_Index( t1_face, p[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
      kp->index2 = FT_Get_Char_Index( t1_face, p[1] );
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
      kp->x = (FT_Int)FT_PEEK_SHORT_LE(p + 2);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
      kp->y = 0;
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
      kp++;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    if ( oldcharmap != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
      error = FT_Set_Charmap( t1_face, oldcharmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      goto Exit;
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
    /* now, sort the kern pairs according to their glyph indices */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    ft_qsort( fi->KernPairs, fi->NumKernPair, sizeof ( AFM_KernPairRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
              compare_kern_pairs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
    if ( error )
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
      FT_FREE( fi->KernPairs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
      fi->NumKernPair = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    }
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  /* parse a metrics file -- either AFM or PFM depending on what */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
  /* it turns out to be                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
  T1_Read_Metrics( FT_Face    t1_face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
                   FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    PSAux_Service  psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    FT_Memory      memory  = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
    AFM_ParserRec  parser;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    AFM_FontInfo   fi      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    FT_Error       error   = T1_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    T1_Font        t1_font = &( (T1_Face)t1_face )->type1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    if ( FT_NEW( fi )                   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
         FT_FRAME_ENTER( stream->size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    fi->FontBBox  = t1_font->font_bbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    fi->Ascender  = t1_font->font_bbox.yMax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    fi->Descender = t1_font->font_bbox.yMin;
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
    psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
    if ( psaux && psaux->afm_parser_funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
      error = psaux->afm_parser_funcs->init( &parser,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
                                             stream->memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
                                             stream->cursor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
                                             stream->limit );
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
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
        parser.FontInfo  = fi;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
        parser.get_index = t1_get_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
        parser.user_data = t1_font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
        error = psaux->afm_parser_funcs->parse( &parser );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
        psaux->afm_parser_funcs->done( &parser );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    if ( error == T1_Err_Unknown_File_Format )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
      FT_Byte*  start = stream->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
      /* MS Windows allows versions up to 0x3FF without complaining */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
      if ( stream->size > 6                              &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
           start[1] < 4                                  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
           FT_PEEK_ULONG_LE( start + 2 ) == stream->size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
        error = T1_Read_PFM( t1_face, stream, fi );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
      t1_font->font_bbox = fi->FontBBox;
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
      t1_face->bbox.xMin =   fi->FontBBox.xMin            >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
      t1_face->bbox.yMin =   fi->FontBBox.yMin            >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
      /* no `U' suffix here to 0xFFFF! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
      t1_face->bbox.xMax = ( fi->FontBBox.xMax + 0xFFFF ) >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
      t1_face->bbox.yMax = ( fi->FontBBox.yMax + 0xFFFF ) >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
      /* no `U' suffix here to 0x8000! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
      t1_face->ascender  = (FT_Short)( ( fi->Ascender  + 0x8000 ) >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      t1_face->descender = (FT_Short)( ( fi->Descender + 0x8000 ) >> 16 );
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
      if ( fi->NumKernPair )
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
        t1_face->face_flags |= FT_FACE_FLAG_KERNING;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
        ( (T1_Face)t1_face )->afm_data = fi;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
        fi = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    FT_FRAME_EXIT();
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    if ( fi != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
      T1_Done_Metrics( memory, fi );
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
    return error;
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
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
  /* find the kerning for a given glyph pair */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
  T1_Get_Kerning( AFM_FontInfo  fi,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
                  FT_UInt       glyph1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
                  FT_UInt       glyph2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
                  FT_Vector*    kerning )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    AFM_KernPair  min, mid, max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    FT_ULong      idx = KERN_INDEX( glyph1, glyph2 );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    /* simple binary search */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
    min = fi->KernPairs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    max = min + fi->NumKernPair - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
    while ( min <= max )
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_ULong  midi;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
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
      mid  = min + ( max - min ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
      midi = KERN_INDEX( mid->index1, mid->index2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
      if ( midi == idx )
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
        kerning->x = mid->x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
        kerning->y = mid->y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
      if ( midi < idx )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
        min = mid + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
        max = mid - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    kerning->x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
    kerning->y = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
  T1_Get_Track_Kerning( FT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
                        FT_Fixed   ptsize,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
                        FT_Int     degree,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
                        FT_Fixed*  kerning )
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
    AFM_FontInfo  fi = (AFM_FontInfo)( (T1_Face)face )->afm_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
    FT_Int        i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
    if ( !fi )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
      return T1_Err_Invalid_Argument;
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
    for ( i = 0; i < fi->NumTrackKern; i++ )
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
      AFM_TrackKern  tk = fi->TrackKerns + i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
      if ( tk->degree != degree )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
        continue;
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
      if ( ptsize < tk->min_ptsize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        *kerning = tk->min_kern;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
      else if ( ptsize > tk->max_ptsize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
        *kerning = tk->max_kern;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
      else
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
        *kerning = FT_MulDiv( ptsize - tk->min_ptsize,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
                              tk->max_kern - tk->min_kern,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
                              tk->max_ptsize - tk->min_ptsize ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
                   tk->min_kern;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
    return T1_Err_Ok;
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
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
/* END */