misc/libfreetype/src/sfnt/sfobjs.c
author unc0rr
Fri, 25 Jan 2013 12:59:06 +0400
changeset 8431 74c2c95ab07b
parent 5172 88f2e05288ba
permissions -rw-r--r--
Fix finding player's another clan
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
/*  sfobjs.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
/*    SFNT object management (base).                                       */
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-2008, 2010-2011 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 "sfobjs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "ttload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include "ttcmap.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "ttkern.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_INTERNAL_SFNT_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include FT_TRUETYPE_IDS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include FT_SFNT_NAMES_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#include "sferrors.h"
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
#ifdef TT_CONFIG_OPTION_BDF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
#include "ttbdf.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
#define FT_COMPONENT  trace_sfobjs
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  /* convert a UTF-16 name entry to ASCII */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  static FT_String*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  tt_name_entry_ascii_from_utf16( TT_NameEntry  entry,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
                                  FT_Memory     memory )
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
    FT_String*  string = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    FT_UInt     len, code, n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    FT_Byte*    read   = (FT_Byte*)entry->string;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    FT_Error    error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    len = (FT_UInt)entry->stringLength / 2;
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
    if ( FT_NEW_ARRAY( string, len + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
      return NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    for ( n = 0; n < len; n++ )
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
      code = FT_NEXT_USHORT( read );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
      if ( code < 32 || code > 127 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
        code = '?';
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
      string[n] = (char)code;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    string[len] = 0;
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
    return string;
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
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
  /* convert an Apple Roman or symbol name entry to ASCII */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  static FT_String*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  tt_name_entry_ascii_from_other( TT_NameEntry  entry,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
                                  FT_Memory     memory )
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
    FT_String*  string = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    FT_UInt     len, code, n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    FT_Byte*    read   = (FT_Byte*)entry->string;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    FT_Error    error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    len = (FT_UInt)entry->stringLength;
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 ( FT_NEW_ARRAY( string, len + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      return NULL;
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
    for ( n = 0; n < len; n++ )
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
      code = *read++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      if ( code < 32 || code > 127 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
        code = '?';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
      string[n] = (char)code;
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
    string[len] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    return string;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
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
  typedef FT_String*  (*TT_NameEntry_ConvertFunc)( TT_NameEntry  entry,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
                                                   FT_Memory     memory );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  /*    tt_face_get_name                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  /*    Returns a given ENGLISH name record in ASCII.                      */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  /*    face   :: A handle to the source face object.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
  /*    nameid :: The name id of the name record to return.                */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
  /*    name   :: The address of a string pointer.  NULL if no name is     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  /*              present.                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  tt_face_get_name( TT_Face      face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
                    FT_UShort    nameid,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
                    FT_String**  name )
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
    FT_Memory         memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    FT_Error          error  = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    FT_String*        result = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    FT_UShort         n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    TT_NameEntryRec*  rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    FT_Int            found_apple         = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    FT_Int            found_apple_roman   = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    FT_Int            found_apple_english = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_Int            found_win           = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    FT_Int            found_unicode       = -1;
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
    FT_Bool           is_english = 0;
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
    TT_NameEntry_ConvertFunc  convert;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
    FT_ASSERT( name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    rec = face->name_table.names;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    for ( n = 0; n < face->num_names; n++, rec++ )
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
      /* According to the OpenType 1.3 specification, only Microsoft or  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      /* Apple platform IDs might be used in the `name' table.  The      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      /* `Unicode' platform is reserved for the `cmap' table, and the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      /* `ISO' one is deprecated.                                        */
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
      /* However, the Apple TrueType specification doesn't say the same  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      /* thing and goes to suggest that all Unicode `name' table entries */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      /* should be coded in UTF-16 (in big-endian format I suppose).     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
      /*                                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      if ( rec->nameID == nameid && rec->stringLength > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
        switch ( rec->platformID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
        case TT_PLATFORM_APPLE_UNICODE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
        case TT_PLATFORM_ISO:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
          /* there is `languageID' to check there.  We should use this */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
          /* field only as a last solution when nothing else is        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
          /* available.                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
          /*                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
          found_unicode = n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
        case TT_PLATFORM_MACINTOSH:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
          /* This is a bit special because some fonts will use either    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
          /* an English language id, or a Roman encoding id, to indicate */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
          /* the English version of its font name.                       */
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
          if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
            found_apple_english = n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
          else if ( rec->encodingID == TT_MAC_ID_ROMAN )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
            found_apple_roman = n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
        case TT_PLATFORM_MICROSOFT:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
          /* we only take a non-English name when there is nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
          /* else available in the font                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
          /*                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
          if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
            switch ( rec->encodingID )
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
            case TT_MS_ID_SYMBOL_CS:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
            case TT_MS_ID_UNICODE_CS:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
            case TT_MS_ID_UCS_4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
              is_english = FT_BOOL( ( rec->languageID & 0x3FF ) == 0x009 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
              found_win  = n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
              break;
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
            default:
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
            }
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
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
          ;
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
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    found_apple = found_apple_roman;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    if ( found_apple_english >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      found_apple = found_apple_english;
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
    /* some fonts contain invalid Unicode or Macintosh formatted entries; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    /* we will thus favor names encoded in Windows formats if available   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    /* (provided it is an English name)                                   */
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
    convert = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
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
      rec = face->name_table.names + found_win;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
      switch ( rec->encodingID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
        /* all Unicode strings are encoded using UTF-16BE */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
      case TT_MS_ID_UNICODE_CS:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
      case TT_MS_ID_SYMBOL_CS:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
        convert = tt_name_entry_ascii_from_utf16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
      case TT_MS_ID_UCS_4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
        /* Apparently, if this value is found in a name table entry, it is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
        /* documented as `full Unicode repertoire'.  Experience with the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
        /* MsGothic font shipped with Windows Vista shows that this really */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
        /* means UTF-16 encoded names (UCS-4 values are only used within   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
        /* charmaps).                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
        convert = tt_name_entry_ascii_from_utf16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
      default:
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
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    else if ( found_apple >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      rec     = face->name_table.names + found_apple;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
      convert = tt_name_entry_ascii_from_other;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    else if ( found_unicode >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
      rec     = face->name_table.names + found_unicode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      convert = tt_name_entry_ascii_from_utf16;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    if ( rec && convert )
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
      if ( rec->string == NULL )
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
        FT_Stream  stream = face->name_table.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
        if ( FT_QNEW_ARRAY ( rec->string, rec->stringLength ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
             FT_STREAM_SEEK( rec->stringOffset )              ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
             FT_STREAM_READ( rec->string, rec->stringLength ) )
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_FREE( rec->string );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
          rec->stringLength = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
          result            = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
      result = convert( rec, memory );
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    *name = result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
  static FT_Encoding
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
  sfnt_find_encoding( int  platform_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
                      int  encoding_id )
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
    typedef struct  TEncoding_
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
      int          platform_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      int          encoding_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
      FT_Encoding  encoding;
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
    } TEncoding;
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
    static
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
    const TEncoding  tt_encodings[] =
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
      { TT_PLATFORM_ISO,           -1,                  FT_ENCODING_UNICODE },
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
      { TT_PLATFORM_APPLE_UNICODE, -1,                  FT_ENCODING_UNICODE },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
      { TT_PLATFORM_MACINTOSH,     TT_MAC_ID_ROMAN,     FT_ENCODING_APPLE_ROMAN },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SYMBOL_CS,  FT_ENCODING_MS_SYMBOL },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_UCS_4,      FT_ENCODING_UNICODE },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SJIS,       FT_ENCODING_SJIS },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_GB2312,     FT_ENCODING_GB2312 },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_BIG_5,      FT_ENCODING_BIG5 },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_WANSUNG,    FT_ENCODING_WANSUNG },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_JOHAB,      FT_ENCODING_JOHAB }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
    };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    const TEncoding  *cur, *limit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    cur   = tt_encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
    limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
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
    for ( ; cur < limit; cur++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
      if ( cur->platform_id == platform_id )
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
        if ( cur->encoding_id == encoding_id ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
             cur->encoding_id == -1          )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
          return cur->encoding;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
    return FT_ENCODING_NONE;
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
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
  /* Fill in face->ttc_header.  If the font is not a TTC, it is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
  /* synthesized into a TTC with one offset table.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
  sfnt_open_font( FT_Stream  stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
                  TT_Face    face )
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
    FT_Memory  memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    FT_ULong   tag, offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    static const FT_Frame_Field  ttc_header_fields[] =
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
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
#define FT_STRUCTURE  TTC_HeaderRec
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
      FT_FRAME_START( 8 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
        FT_FRAME_LONG( version ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
        FT_FRAME_LONG( count   ),  /* this is ULong in the specs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
      FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    face->ttc_header.tag     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    face->ttc_header.version = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
    face->ttc_header.count   = 0;
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
    offset = FT_STREAM_POS();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
    if ( FT_READ_ULONG( tag ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
    if ( tag != 0x00010000UL &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
         tag != TTAG_ttcf    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
         tag != TTAG_OTTO    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
         tag != TTAG_true    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
         tag != TTAG_typ1    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
         tag != 0x00020000UL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
      return SFNT_Err_Unknown_File_Format;
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
    face->ttc_header.tag = TTAG_ttcf;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
    if ( tag == TTAG_ttcf )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
      FT_Int  n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
      FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
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
      if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
        return error;
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
      if ( face->ttc_header.count == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
        return SFNT_Err_Invalid_Table;
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
      /* a rough size estimate: let's conservatively assume that there   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
      /* is just a single table info in each subfont header (12 + 16*1 = */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
      /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
      /* size of the TTC header plus `28*count' bytes for all subfont    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
      /* headers                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
      if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
        return SFNT_Err_Array_Too_Large;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
      /* now read the offsets of each font in the file */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
      if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
      if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
        return error;
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
      for ( n = 0; n < face->ttc_header.count; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
        face->ttc_header.offsets[n] = FT_GET_ULONG();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
      FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    else
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
      FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
      face->ttc_header.version = 1 << 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
      face->ttc_header.count   = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
      if ( FT_NEW( face->ttc_header.offsets ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      face->ttc_header.offsets[0] = offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
  sfnt_init_face( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
                  TT_Face        face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
                  FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
                  FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
                  FT_Parameter*  params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    FT_Error        error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
    FT_Library      library = face->root.driver->root.library;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    SFNT_Service    sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
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
    /* for now, parameters are unused */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
    FT_UNUSED( num_params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
    FT_UNUSED( params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
    sfnt = (SFNT_Service)face->sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
    if ( !sfnt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
      sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
      if ( !sfnt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        return SFNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
      face->sfnt       = sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
      face->goto_table = sfnt->goto_table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
    FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
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
    error = sfnt_open_font( stream, face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
      return error;
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
    FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_index ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
    if ( face_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
      face_index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
    if ( face_index >= face->ttc_header.count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
      return SFNT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
    if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
    /* check that we have a valid TrueType file */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
    error = sfnt->load_font_dir( face, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
      return error;
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
    face->root.num_faces  = face->ttc_header.count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    face->root.face_index = face_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
#define LOAD_( x )                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
  do {                                                        \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
    FT_TRACE2(( "`" #x "' " ));                               \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
    FT_TRACE3(( "-->\n" ));                                   \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
                                                              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
    error = sfnt->load_##x( face, stream );                   \
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
    FT_TRACE2(( "%s\n", ( !error )                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
                        ? "loaded"                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
                        : ( error == SFNT_Err_Table_Missing ) \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
                          ? "missing"                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
                          : "failed to load" ));              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
    FT_TRACE3(( "\n" ));                                      \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
  } while ( 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
#define LOADM_( x, vertical )                                 \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
  do {                                                        \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
    FT_TRACE2(( "`%s" #x "' ",                                \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
                vertical ? "vertical " : "" ));               \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
    FT_TRACE3(( "-->\n" ));                                   \
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
    error = sfnt->load_##x( face, stream, vertical );         \
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
    FT_TRACE2(( "%s\n", ( !error )                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
                        ? "loaded"                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
                        : ( error == SFNT_Err_Table_Missing ) \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
                          ? "missing"                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
                          : "failed to load" ));              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    FT_TRACE3(( "\n" ));                                      \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
  } while ( 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
#define GET_NAME( id, field )                                 \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
  do {                                                        \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
    error = tt_face_get_name( face, TT_NAME_ID_##id, field ); \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
    if ( error )                                              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
      goto Exit;                                              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
  } while ( 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
  sfnt_load_face( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
                  TT_Face        face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
                  FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
                  FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
                  FT_Parameter*  params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
    FT_Error      psnames_error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
    FT_Bool       has_outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
    FT_Bool       is_apple_sbit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
    FT_Bool       ignore_preferred_family = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
    FT_Bool       ignore_preferred_subfamily = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    /* Check parameters */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
      FT_Int  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
      for ( i = 0; i < num_params; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
        if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
          ignore_preferred_family = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
        else if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
          ignore_preferred_subfamily = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    /* Load tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    /* We now support two SFNT-based bitmapped font formats.  They */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
    /* are recognized easily as they do not include a `glyf'       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
    /* table.                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    /*                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    /* The first format comes from Apple, and uses a table named   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
    /* `bhed' instead of `head' to store the font header (using    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
    /* the same format).  It also doesn't include horizontal and   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
    /* vertical metrics tables (i.e. `hhea' and `vhea' tables are  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
    /* missing).                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
    /*                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
    /* The other format comes from Microsoft, and is used with     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
    /* WinCE/PocketPC.  It looks like a standard TTF, except that  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
    /* it doesn't contain outlines.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
    /*                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    FT_TRACE2(( "sfnt_load_face: %08p\n\n", face ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
    /* do we have outlines in there? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
    has_outline   = FT_BOOL( face->root.internal->incremental_interface != 0 ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
                             tt_face_lookup_table( face, TTAG_glyf )    != 0 ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
                             tt_face_lookup_table( face, TTAG_CFF )     != 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    has_outline   = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
                             tt_face_lookup_table( face, TTAG_CFF )  != 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    is_apple_sbit = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    /* if this font doesn't contain outlines, we try to load */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    /* a `bhed' table                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
    if ( !has_outline && sfnt->load_bhed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
      LOAD_( bhed );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
      is_apple_sbit = FT_BOOL( !error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
    /* load the font header (`head' table) if this isn't an Apple */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    /* sbit font file                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
    if ( !is_apple_sbit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
      LOAD_( head );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
    if ( face->header.Units_Per_EM == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
      error = SFNT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    /* the following tables are often not present in embedded TrueType */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    /* fonts within PDF documents, so don't check for them.            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    LOAD_( maxp );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
    LOAD_( cmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
    /* the following tables are optional in PCL fonts -- */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
    /* don't check for errors                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    LOAD_( name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    LOAD_( post );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
    psnames_error = error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    /* do not load the metrics headers and tables if this is an Apple */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
    /* sbit font file                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
    if ( !is_apple_sbit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
      /* load the `hhea' and `hmtx' tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
      LOADM_( hhea, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
        LOADM_( hmtx, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
        if ( error == SFNT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
          error = SFNT_Err_Hmtx_Table_Missing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
          /* If this is an incrementally loaded font and there are */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
          /* overriding metrics, tolerate a missing `hmtx' table.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
          if ( face->root.internal->incremental_interface          &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
               face->root.internal->incremental_interface->funcs->
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
                 get_glyph_metrics                                 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
            face->horizontal.number_Of_HMetrics = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
            error = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
      else if ( error == SFNT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
        /* No `hhea' table necessary for SFNT Mac fonts. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
        if ( face->format_tag == TTAG_true )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
          FT_TRACE2(( "This is an SFNT Mac font.\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
          has_outline = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
          error = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
          error = SFNT_Err_Horiz_Header_Missing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
          /* If this is an incrementally loaded font and there are */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
          /* overriding metrics, tolerate a missing `hhea' table.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
          if ( face->root.internal->incremental_interface          &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
               face->root.internal->incremental_interface->funcs->
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
                 get_glyph_metrics                                 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
            face->horizontal.number_Of_HMetrics = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
            error = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
      /* try to load the `vhea' and `vmtx' tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
      LOADM_( hhea, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
        LOADM_( hmtx, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
        if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
          face->vertical_info = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      if ( error && error != SFNT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      LOAD_( os2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
        /* we treat the table as missing if there are any errors */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
        face->os2.version = 0xFFFFU;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
    /* the optional tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
    /* embedded bitmap support */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
    if ( sfnt->load_eblc )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
      LOAD_( eblc );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
        /* a font which contains neither bitmaps nor outlines is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
        /* still valid (although rather useless in most cases);  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
        /* however, you can find such stripped fonts in PDFs     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
        if ( error == SFNT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
          error = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
    LOAD_( pclt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
      if ( error != SFNT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
      face->pclt.Version = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    /* consider the kerning and gasp tables as optional */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    LOAD_( gasp );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
    LOAD_( kern );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
    face->root.num_glyphs = face->max_profile.numGlyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
    /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
    /* a WWS-only font face.  `WWS' stands for `weight', width', and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    /* `slope', a term used by Microsoft's Windows Presentation      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
    /* Foundation (WPF).  This flag has been introduced in version   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
    /* 1.5 of the OpenType specification (May 2008).                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
    face->root.family_name = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
    face->root.style_name  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
    if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
      if ( !ignore_preferred_family )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
        GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
      if ( !face->root.family_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
        GET_NAME( FONT_FAMILY, &face->root.family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
      if ( !ignore_preferred_subfamily )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
        GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      if ( !face->root.style_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
        GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
      GET_NAME( WWS_FAMILY, &face->root.family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
      if ( !face->root.family_name && !ignore_preferred_family )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
        GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
      if ( !face->root.family_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
        GET_NAME( FONT_FAMILY, &face->root.family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
      GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
      if ( !face->root.style_name && !ignore_preferred_subfamily )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
        GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
      if ( !face->root.style_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
        GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
    /* now set up root fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
      FT_Face  root  = &face->root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
      FT_Long  flags = root->face_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
      /* Compute face flags.                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
      if ( has_outline == TRUE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
        flags |= FT_FACE_FLAG_SCALABLE;   /* scalable outlines */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
      /* The sfnt driver only supports bitmap fonts natively, thus we */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
      /* don't set FT_FACE_FLAG_HINTER.                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
      flags |= FT_FACE_FLAG_SFNT       |  /* SFNT file format  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
               FT_FACE_FLAG_HORIZONTAL;   /* horizontal data   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
      if ( psnames_error == SFNT_Err_Ok               &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
           face->postscript.FormatType != 0x00030000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
        flags |= FT_FACE_FLAG_GLYPH_NAMES;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
      /* fixed width font? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
      if ( face->postscript.isFixedPitch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
        flags |= FT_FACE_FLAG_FIXED_WIDTH;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
      /* vertical information? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
      if ( face->vertical_info )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
        flags |= FT_FACE_FLAG_VERTICAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
      /* kerning available ? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
      if ( TT_FACE_HAS_KERNING( face ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
        flags |= FT_FACE_FLAG_KERNING;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
      /* Don't bother to load the tables unless somebody asks for them. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
      /* No need to do work which will (probably) not be used.          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
      if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
           tt_face_lookup_table( face, TTAG_fvar ) != 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
           tt_face_lookup_table( face, TTAG_gvar ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
        flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
      root->face_flags = flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
      /* Compute style flags.                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
      flags = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
      if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
        /* We have an OS/2 table; use the `fsSelection' field.  Bit 9 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
        /* indicates an oblique font face.  This flag has been        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
        /* introduced in version 1.5 of the OpenType specification.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
        if ( face->os2.fsSelection & 512 )       /* bit 9 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
          flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
        else if ( face->os2.fsSelection & 1 )    /* bit 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
          flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
        if ( face->os2.fsSelection & 32 )        /* bit 5 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
          flags |= FT_STYLE_FLAG_BOLD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
        /* this is an old Mac font, use the header field */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
        if ( face->header.Mac_Style & 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
          flags |= FT_STYLE_FLAG_BOLD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
        if ( face->header.Mac_Style & 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
          flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
      root->style_flags = flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
      /* Polish the charmaps.                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
      /*   Try to set the charmap encoding according to the platform &     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
      /*   encoding ID of each charmap.                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
      tt_face_build_cmaps( face );  /* ignore errors */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
      /* set the encoding fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
        FT_Int  m;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
        for ( m = 0; m < root->num_charmaps; m++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
          FT_CharMap  charmap = root->charmaps[m];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
          charmap->encoding = sfnt_find_encoding( charmap->platform_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
                                                  charmap->encoding_id );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
          if ( root->charmap     == NULL &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
               charmap->encoding == FT_ENCODING_UNICODE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
            /* set 'root->charmap' to the first Unicode encoding we find */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
            root->charmap = charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
      /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
       *  Now allocate the root array of FT_Bitmap_Size records and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
       *  populate them.  Unfortunately, it isn't possible to indicate bit
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
       *  depths in the FT_Bitmap_Size record.  This is a design error.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
        FT_UInt  i, count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
        count = face->sbit_num_strikes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
        count = (FT_UInt)face->num_sbit_strikes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
        if ( count > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
          FT_Memory        memory   = face->root.stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
          FT_UShort        em_size  = face->header.Units_Per_EM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
          FT_Short         avgwidth = face->os2.xAvgCharWidth;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
          FT_Size_Metrics  metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
          if ( em_size == 0 || face->os2.version == 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
            avgwidth = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
            em_size = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
          if ( FT_NEW_ARRAY( root->available_sizes, count ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
          for ( i = 0; i < count; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
            FT_Bitmap_Size*  bsize = root->available_sizes + i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
            error = sfnt->load_strike_metrics( face, i, &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
            if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
              goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
            bsize->height = (FT_Short)( metrics.height >> 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
            bsize->width = (FT_Short)(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
                ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
            bsize->x_ppem = metrics.x_ppem << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
            bsize->y_ppem = metrics.y_ppem << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
            /* assume 72dpi */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
            bsize->size   = metrics.y_ppem << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
          root->face_flags     |= FT_FACE_FLAG_FIXED_SIZES;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
          root->num_fixed_sizes = (FT_Int)count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
      /* a font with no bitmaps and no outlines is scalable; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
      /* it has only empty glyphs then                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
      if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
        root->face_flags |= FT_FACE_FLAG_SCALABLE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
      /*  Set up metrics.                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
      if ( FT_IS_SCALABLE( root ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
        /* XXX What about if outline header is missing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
        /*     (e.g. sfnt wrapped bitmap)?             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
        root->bbox.xMin    = face->header.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
        root->bbox.yMin    = face->header.yMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
        root->bbox.xMax    = face->header.xMax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
        root->bbox.yMax    = face->header.yMax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
        root->units_per_EM = face->header.Units_Per_EM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
        /* XXX: Computing the ascender/descender/height is very different */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
        /*      from what the specification tells you.  Apparently, we    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
        /*      must be careful because                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
        /*      - not all fonts have an OS/2 table; in this case, we take */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
        /*        the values in the horizontal header.  However, these    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
        /*        values very often are not reliable.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
        /*      - otherwise, the correct typographic values are in the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
        /*        sTypoAscender, sTypoDescender & sTypoLineGap fields.    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
        /*        However, certain fonts have these fields set to 0.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
        /*        Rather, they have usWinAscent & usWinDescent correctly  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
        /*        set (but with different values).                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
        /*      As an example, Arial Narrow is implemented through four   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
        /*      files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
        /*      Strangely, all fonts have the same values in their        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
        /*      sTypoXXX fields, except ARIALNB which sets them to 0.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
        /*      On the other hand, they all have different                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
        /*      usWinAscent/Descent values -- as a conclusion, the OS/2   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
        /*      table cannot be used to compute the text height reliably! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
        /* The ascender/descender/height are computed from the OS/2 table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
        /* when found.  Otherwise, they're taken from the horizontal      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
        /* header.                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
        /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
        root->ascender  = face->horizontal.Ascender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
        root->descender = face->horizontal.Descender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
        root->height    = (FT_Short)( root->ascender - root->descender +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
                                      face->horizontal.Line_Gap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
        /* if the line_gap is 0, we add an extra 15% to the text height --  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
        /* this computation is based on various versions of Times New Roman */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
        if ( face->horizontal.Line_Gap == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
          root->height = (FT_Short)( ( root->height * 115 + 50 ) / 100 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
        /* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
        /* "sTypoLineGap" fields set to 0, like ARIALNB.TTF             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
        if ( face->os2.version != 0xFFFFU && root->ascender )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
          FT_Int  height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
          root->ascender  =  face->os2.sTypoAscender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
          root->descender = -face->os2.sTypoDescender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
          height = root->ascender + root->descender + face->os2.sTypoLineGap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
          if ( height > root->height )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
            root->height = height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
        root->max_advance_width  = face->horizontal.advance_Width_Max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
        root->max_advance_height = (FT_Short)( face->vertical_info
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
                                     ? face->vertical.advance_Height_Max
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
                                     : root->height );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
        /* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
        /* Adjust underline position from top edge to centre of     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
        /* stroke to convert TrueType meaning to FreeType meaning.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
        root->underline_position  = face->postscript.underlinePosition -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
                                    face->postscript.underlineThickness / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
        root->underline_thickness = face->postscript.underlineThickness;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
    FT_TRACE2(( "sfnt_load_face: done\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
#undef LOAD_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
#undef LOADM_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
#undef GET_NAME
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
  sfnt_done_face( TT_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
    FT_Memory     memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
    SFNT_Service  sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
    memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
    sfnt   = (SFNT_Service)face->sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
    if ( sfnt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
      /* destroy the postscript names table if it is loaded */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
      if ( sfnt->free_psnames )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
        sfnt->free_psnames( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
      /* destroy the embedded bitmaps table if it is loaded */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
      if ( sfnt->free_eblc )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
        sfnt->free_eblc( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
#ifdef TT_CONFIG_OPTION_BDF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
    /* freeing the embedded BDF properties */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
    tt_face_free_bdf_props( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
    /* freeing the kerning table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
    tt_face_done_kern( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
    /* freeing the collection table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
    FT_FREE( face->ttc_header.offsets );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
    face->ttc_header.count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
    /* freeing table directory */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
    FT_FREE( face->dir_tables );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
    face->num_tables = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
      FT_Stream  stream = FT_FACE_STREAM( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
      /* simply release the 'cmap' table frame */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
      FT_FRAME_RELEASE( face->cmap_table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
      face->cmap_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
    /* freeing the horizontal metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
      FT_Stream  stream = FT_FACE_STREAM( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
      FT_FRAME_RELEASE( face->horz_metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
      FT_FRAME_RELEASE( face->vert_metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
      face->horz_metrics_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
      face->vert_metrics_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
    FT_FREE( face->horizontal.long_metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
    FT_FREE( face->horizontal.short_metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
    /* freeing the vertical ones, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
    if ( face->vertical_info )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
      FT_FREE( face->vertical.long_metrics  );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
      FT_FREE( face->vertical.short_metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
      face->vertical_info = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
    /* freeing the gasp table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
    FT_FREE( face->gasp.gaspRanges );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
    face->gasp.numRanges = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
    /* freeing the name table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
    if ( sfnt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
      sfnt->free_name( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
    /* freeing family and style name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
    FT_FREE( face->root.family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
    FT_FREE( face->root.style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
    /* freeing sbit size table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
    FT_FREE( face->root.available_sizes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
    face->root.num_fixed_sizes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
    FT_FREE( face->postscript_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
    face->sfnt = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
/* END */