misc/libfreetype/src/winfonts/winfnt.c
author Henek
Sun, 26 Jun 2011 02:47:36 +0200
changeset 5313 5e18eaef65d0
parent 5172 88f2e05288ba
permissions -rw-r--r--
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
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
/*  winfnt.c                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    FreeType font driver for Windows FNT/FON files                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010 by */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  Copyright 2003 Huw D M Davies for Codeweavers                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  Copyright 2007 Dmitry Timoshkov for Codeweavers                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  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
    13
/*  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
    14
/*  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
    15
/*  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
    16
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_WINFONTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include FT_INTERNAL_OBJECTS_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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "winfnt.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include "fnterrs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#include FT_SERVICE_WINFNT_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include FT_SERVICE_XFREE86_NAME_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /* 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
    36
  /* 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
    37
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
#define FT_COMPONENT  trace_winfnt
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  static const FT_Frame_Field  winmz_header_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
#define FT_STRUCTURE  WinMZ_HeaderRec
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
    FT_FRAME_START( 64 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
      FT_FRAME_USHORT_LE ( magic ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
      FT_FRAME_SKIP_BYTES( 29 * 2 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
      FT_FRAME_ULONG_LE  ( lfanew ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  static const FT_Frame_Field  winne_header_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
#define FT_STRUCTURE  WinNE_HeaderRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    FT_FRAME_START( 40 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
      FT_FRAME_USHORT_LE ( magic ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
      FT_FRAME_SKIP_BYTES( 34 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      FT_FRAME_USHORT_LE ( resource_tab_offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
      FT_FRAME_USHORT_LE ( rname_tab_offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
  static const FT_Frame_Field  winpe32_header_fields[] =
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
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
#define FT_STRUCTURE  WinPE32_HeaderRec
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
    FT_FRAME_START( 248 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      FT_FRAME_ULONG_LE  ( magic ),   /* PE00 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      FT_FRAME_USHORT_LE ( machine ), /* 0x014c - i386 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
      FT_FRAME_USHORT_LE ( number_of_sections ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
      FT_FRAME_SKIP_BYTES( 12 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
      FT_FRAME_USHORT_LE ( size_of_optional_header ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
      FT_FRAME_SKIP_BYTES( 2 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
      FT_FRAME_USHORT_LE ( magic32 ), /* 0x10b */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
      FT_FRAME_SKIP_BYTES( 110 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
      FT_FRAME_ULONG_LE  ( rsrc_virtual_address ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
      FT_FRAME_ULONG_LE  ( rsrc_size ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      FT_FRAME_SKIP_BYTES( 104 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  static const FT_Frame_Field  winpe32_section_fields[] =
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
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
#define FT_STRUCTURE  WinPE32_SectionRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    FT_FRAME_START( 40 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
      FT_FRAME_BYTES     ( name, 8 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
      FT_FRAME_SKIP_BYTES( 4 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
      FT_FRAME_ULONG_LE  ( virtual_address ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      FT_FRAME_ULONG_LE  ( size_of_raw_data ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      FT_FRAME_ULONG_LE  ( pointer_to_raw_data ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      FT_FRAME_SKIP_BYTES( 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  static const FT_Frame_Field  winpe_rsrc_dir_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
#define FT_STRUCTURE  WinPE_RsrcDirRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    FT_FRAME_START( 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      FT_FRAME_ULONG_LE ( characteristics ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
      FT_FRAME_ULONG_LE ( time_date_stamp ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
      FT_FRAME_USHORT_LE( major_version ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
      FT_FRAME_USHORT_LE( minor_version ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
      FT_FRAME_USHORT_LE( number_of_named_entries ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
      FT_FRAME_USHORT_LE( number_of_id_entries ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  static const FT_Frame_Field  winpe_rsrc_dir_entry_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
#define FT_STRUCTURE  WinPE_RsrcDirEntryRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    FT_FRAME_START( 8 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
      FT_FRAME_ULONG_LE( name ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
      FT_FRAME_ULONG_LE( offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  static const FT_Frame_Field  winpe_rsrc_data_entry_fields[] =
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
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
#define FT_STRUCTURE  WinPE_RsrcDataEntryRec
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
    FT_FRAME_START( 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
      FT_FRAME_ULONG_LE( offset_to_data ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
      FT_FRAME_ULONG_LE( size ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      FT_FRAME_ULONG_LE( code_page ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      FT_FRAME_ULONG_LE( reserved ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
  static const FT_Frame_Field  winfnt_header_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
#define FT_STRUCTURE  FT_WinFNT_HeaderRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_FRAME_START( 148 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      FT_FRAME_USHORT_LE( version ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      FT_FRAME_ULONG_LE ( file_size ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
      FT_FRAME_BYTES    ( copyright, 60 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      FT_FRAME_USHORT_LE( file_type ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
      FT_FRAME_USHORT_LE( nominal_point_size ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      FT_FRAME_USHORT_LE( vertical_resolution ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
      FT_FRAME_USHORT_LE( horizontal_resolution ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
      FT_FRAME_USHORT_LE( ascent ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
      FT_FRAME_USHORT_LE( internal_leading ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
      FT_FRAME_USHORT_LE( external_leading ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      FT_FRAME_BYTE     ( italic ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      FT_FRAME_BYTE     ( underline ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
      FT_FRAME_BYTE     ( strike_out ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      FT_FRAME_USHORT_LE( weight ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      FT_FRAME_BYTE     ( charset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      FT_FRAME_USHORT_LE( pixel_width ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
      FT_FRAME_USHORT_LE( pixel_height ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
      FT_FRAME_BYTE     ( pitch_and_family ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      FT_FRAME_USHORT_LE( avg_width ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      FT_FRAME_USHORT_LE( max_width ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
      FT_FRAME_BYTE     ( first_char ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      FT_FRAME_BYTE     ( last_char ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
      FT_FRAME_BYTE     ( default_char ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
      FT_FRAME_BYTE     ( break_char ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
      FT_FRAME_USHORT_LE( bytes_per_row ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      FT_FRAME_ULONG_LE ( device_offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
      FT_FRAME_ULONG_LE ( face_name_offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
      FT_FRAME_ULONG_LE ( bits_pointer ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      FT_FRAME_ULONG_LE ( bits_offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      FT_FRAME_BYTE     ( reserved ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
      FT_FRAME_ULONG_LE ( flags ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
      FT_FRAME_USHORT_LE( A_space ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      FT_FRAME_USHORT_LE( B_space ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
      FT_FRAME_USHORT_LE( C_space ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
      FT_FRAME_ULONG_LE ( color_table_offset ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      FT_FRAME_BYTES    ( reserved1, 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  fnt_font_done( FNT_Face face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    FT_Memory  memory = FT_FACE( face )->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    FT_Stream  stream = FT_FACE( face )->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    FNT_Font   font   = face->font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    if ( !font )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      return;
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
    if ( font->fnt_frame )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
      FT_FRAME_RELEASE( font->fnt_frame );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_FREE( font->family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    FT_FREE( font );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    face->font = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
  fnt_font_load( FNT_Font   font,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
                 FT_Stream  stream )
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
    FT_Error          error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    FT_WinFNT_Header  header = &font->header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    FT_Bool           new_format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    FT_UInt           size;
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
    /* first of all, read the FNT header */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    if ( FT_STREAM_SEEK( font->offset )                        ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
         FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    /* check header */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    if ( header->version != 0x200 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
         header->version != 0x300 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      FT_TRACE2(( "[not a valid FNT file]\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
      error = FNT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    new_format = FT_BOOL( font->header.version == 0x300 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    size       = new_format ? 148 : 118;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    if ( header->file_size < size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
      FT_TRACE2(( "[not a valid FNT file]\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
      error = FNT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    /* Version 2 doesn't have these fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    if ( header->version == 0x200 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
      header->flags   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
      header->A_space = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
      header->B_space = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
      header->C_space = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
      header->color_table_offset = 0;
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
    if ( header->file_type & 1 )
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
      FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
      error = FNT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    /* this is a FNT file/table; extract its frame */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    if ( FT_STREAM_SEEK( font->offset )                         ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
         FT_FRAME_EXTRACT( header->file_size, font->fnt_frame ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  fnt_face_get_dll_font( FNT_Face  face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
                         FT_Int    face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
    FT_Stream        stream = FT_FACE( face )->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
    FT_Memory        memory = FT_FACE( face )->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    WinMZ_HeaderRec  mz_header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
    face->font = 0;
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
    /* does it begin with an MZ header? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    if ( FT_STREAM_SEEK( 0 )                                      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
         FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    error = FNT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    if ( mz_header.magic == WINFNT_MZ_MAGIC )
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
      /* yes, now look for an NE header in the file */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
      WinNE_HeaderRec  ne_header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
      FT_TRACE2(( "MZ signature found\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
      if ( FT_STREAM_SEEK( mz_header.lfanew )                       ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
           FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
      error = FNT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
      if ( ne_header.magic == WINFNT_NE_MAGIC )
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
        /* good, now look into the resource table for each FNT resource */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
        FT_ULong   res_offset  = mz_header.lfanew +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
                                   ne_header.resource_tab_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
        FT_UShort  size_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
        FT_UShort  font_count  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
        FT_ULong   font_offset = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
        FT_TRACE2(( "NE signature found\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
        if ( FT_STREAM_SEEK( res_offset )                    ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
             FT_FRAME_ENTER( ne_header.rname_tab_offset -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
                             ne_header.resource_tab_offset ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
        size_shift = FT_GET_USHORT_LE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
        for (;;)
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
          FT_UShort  type_id, count;
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
          type_id = FT_GET_USHORT_LE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
          if ( !type_id )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
          count = FT_GET_USHORT_LE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
          if ( type_id == 0x8008U )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
            font_count  = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
            font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
                                      ( stream->cursor - stream->limit ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
            break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
          stream->cursor += 4 + count * 12;
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
        FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
        if ( !font_count || !font_offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
          FT_TRACE2(( "this file doesn't contain any FNT resources\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
          error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
        /* loading `winfnt_header_fields' needs at least 118 bytes;    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
        /* use this as a rough measure to check the expected font size */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
        if ( font_count * 118UL > stream->size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
          FT_TRACE2(( "invalid number of faces\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
          error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
        face->root.num_faces = font_count;
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
        if ( face_index >= font_count )
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
          error = FNT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
        else if ( face_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
          goto Exit;
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_NEW( face->font ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
          goto Exit;
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 ( FT_STREAM_SEEK( font_offset + face_index * 12 ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
             FT_FRAME_ENTER( 12 )                            )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
          goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
        face->font->offset   = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
        face->font->fnt_size = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
        stream->cursor += 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
        FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
        error = fnt_font_load( face->font, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
      else if ( ne_header.magic == WINFNT_PE_MAGIC )
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
        WinPE32_HeaderRec       pe32_header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
        WinPE32_SectionRec      pe32_section;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
        WinPE_RsrcDirRec        root_dir, name_dir, lang_dir;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
        WinPE_RsrcDirEntryRec   dir_entry1, dir_entry2, dir_entry3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
        WinPE_RsrcDataEntryRec  data_entry;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
        FT_Long    root_dir_offset, name_dir_offset, lang_dir_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
        FT_UShort  i, j, k;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
        FT_TRACE2(( "PE signature found\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
        if ( FT_STREAM_SEEK( mz_header.lfanew )                           ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
             FT_STREAM_READ_FIELDS( winpe32_header_fields, &pe32_header ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
          goto Exit;
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
        FT_TRACE2(( "magic %04lx, machine %02x, number_of_sections %u, "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
                    "size_of_optional_header %02x\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
                    "magic32 %02x, rsrc_virtual_address %04lx, "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
                    "rsrc_size %04lx\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
                    pe32_header.magic, pe32_header.machine,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
                    pe32_header.number_of_sections,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
                    pe32_header.size_of_optional_header,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
                    pe32_header.magic32, pe32_header.rsrc_virtual_address,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
                    pe32_header.rsrc_size ));
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
        if ( pe32_header.magic != WINFNT_PE_MAGIC /* check full signature */ ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
             pe32_header.machine != 0x014c /* i386 */                        ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
             pe32_header.size_of_optional_header != 0xe0 /* FIXME */         ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
             pe32_header.magic32 != 0x10b                                    )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
          FT_TRACE2(( "this file has an invalid PE header\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
          error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
          goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
        face->root.num_faces = 0;
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
        for ( i = 0; i < pe32_header.number_of_sections; i++ )
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
          if ( FT_STREAM_READ_FIELDS( winpe32_section_fields,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
                                      &pe32_section ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
            goto Exit;
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
          FT_TRACE2(( "name %.8s, va %04lx, size %04lx, offset %04lx\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
                      pe32_section.name, pe32_section.virtual_address,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
                      pe32_section.size_of_raw_data,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
                      pe32_section.pointer_to_raw_data ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
          if ( pe32_header.rsrc_virtual_address ==
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
                 pe32_section.virtual_address )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
            goto Found_rsrc_section;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
        FT_TRACE2(( "this file doesn't contain any resources\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
        error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
      Found_rsrc_section:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
        FT_TRACE2(( "found resources section %.8s\n", pe32_section.name ));
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
        if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data )        ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
             FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &root_dir ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
          goto Exit;
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
        root_dir_offset = pe32_section.pointer_to_raw_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        for ( i = 0; i < root_dir.number_of_named_entries +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
                           root_dir.number_of_id_entries; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
          if ( FT_STREAM_SEEK( root_dir_offset + 16 + i * 8 )      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
               FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
                                      &dir_entry1 )                )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
            goto Exit;
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
          if ( !(dir_entry1.offset & 0x80000000UL ) /* DataIsDirectory */ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
            error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
          dir_entry1.offset &= ~0x80000000UL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
          name_dir_offset = pe32_section.pointer_to_raw_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
                            dir_entry1.offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
          if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
                               dir_entry1.offset )                       ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
               FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &name_dir ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
          for ( j = 0; j < name_dir.number_of_named_entries +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
                             name_dir.number_of_id_entries; j++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
            if ( FT_STREAM_SEEK( name_dir_offset + 16 + j * 8 )      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
                 FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
                                        &dir_entry2 )                )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
              goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
            if ( !(dir_entry2.offset & 0x80000000UL ) /* DataIsDirectory */ )
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
              error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
              goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
            dir_entry2.offset &= ~0x80000000UL;
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
            lang_dir_offset = pe32_section.pointer_to_raw_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
                                dir_entry2.offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
            if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
                                   dir_entry2.offset )                     ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
                 FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &lang_dir ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
              goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
            for ( k = 0; k < lang_dir.number_of_named_entries +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
                               lang_dir.number_of_id_entries; k++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
              if ( FT_STREAM_SEEK( lang_dir_offset + 16 + k * 8 )      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
                   FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
                                          &dir_entry3 )                )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
                goto Exit;
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
              if ( dir_entry2.offset & 0x80000000UL /* DataIsDirectory */ )
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
                error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
                goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
              if ( dir_entry1.name == 8 /* RT_FONT */ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
                if ( FT_STREAM_SEEK( root_dir_offset + dir_entry3.offset ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
                     FT_STREAM_READ_FIELDS( winpe_rsrc_data_entry_fields,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
                                            &data_entry )                  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
                  goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
                FT_TRACE2(( "found font #%lu, offset %04lx, "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
                            "size %04lx, cp %lu\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
                            dir_entry2.name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
                            pe32_section.pointer_to_raw_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
                              data_entry.offset_to_data -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
                              pe32_section.virtual_address,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
                            data_entry.size, data_entry.code_page ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
                if ( face_index == face->root.num_faces )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
                {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
                  if ( FT_NEW( face->font ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
                    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
                  face->font->offset   = pe32_section.pointer_to_raw_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
                                           data_entry.offset_to_data -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
                                           pe32_section.virtual_address;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
                  face->font->fnt_size = data_entry.size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
                  error = fnt_font_load( face->font, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
                  if ( error )
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
                    FT_TRACE2(( "font #%lu load error %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
                                dir_entry2.name, error ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
                    goto Fail;
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
                  else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
                    FT_TRACE2(( "font #%lu successfully loaded\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
                                dir_entry2.name ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
                }
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
                face->root.num_faces++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
      if ( !face->root.num_faces )
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
        FT_TRACE2(( "this file doesn't contain any RT_FONT resources\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
        error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
      if ( face_index >= face->root.num_faces )
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
        error = FNT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
      fnt_font_done( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
  typedef struct  FNT_CMapRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    FT_CMapRec  cmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
    FT_UInt32   first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    FT_UInt32   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
  } FNT_CMapRec, *FNT_CMap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
  fnt_cmap_init( FNT_CMap  cmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    FNT_Face  face = (FNT_Face)FT_CMAP_FACE( cmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
    FNT_Font  font = face->font;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
    cmap->first = (FT_UInt32)  font->header.first_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    cmap->count = (FT_UInt32)( font->header.last_char - cmap->first + 1 );
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
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
  static FT_UInt
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
  fnt_cmap_char_index( FNT_CMap   cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
                       FT_UInt32  char_code )
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
    FT_UInt  gindex = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
    char_code -= cmap->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
    if ( char_code < cmap->count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
      /* we artificially increase the glyph index; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
      /* FNT_Load_Glyph reverts to the right one   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
      gindex = (FT_UInt)( char_code + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    return gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
  static FT_UInt32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
  fnt_cmap_char_next( FNT_CMap    cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
                      FT_UInt32  *pchar_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    FT_UInt    gindex = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    FT_UInt32  result = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
    FT_UInt32  char_code = *pchar_code + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
    if ( char_code <= cmap->first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
      result = cmap->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
      gindex = 1;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      char_code -= cmap->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
      if ( char_code < cmap->count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
        result = cmap->first + char_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
        gindex = (FT_UInt)( char_code + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
    *pchar_code = result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
    return gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
  static const FT_CMap_ClassRec  fnt_cmap_class_rec =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
    sizeof ( FNT_CMapRec ),
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
    (FT_CMap_InitFunc)     fnt_cmap_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
    (FT_CMap_DoneFunc)     NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
    (FT_CMap_CharIndexFunc)fnt_cmap_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
    (FT_CMap_CharNextFunc) fnt_cmap_char_next,
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
    NULL, NULL, NULL, NULL, NULL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
  };
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
  static FT_CMap_Class const  fnt_cmap_class = &fnt_cmap_class_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
  FNT_Face_Done( FNT_Face  face )
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
    FT_Memory  memory;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
    memory = FT_FACE_MEMORY( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
    fnt_font_done( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
    FT_FREE( face->root.available_sizes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    face->root.num_fixed_sizes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
  }
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
  FNT_Face_Init( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
                 FNT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
                 FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
                 FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
                 FT_Parameter*  params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    FT_Memory  memory = FT_FACE_MEMORY( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
    FT_UNUSED( num_params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
    FT_UNUSED( params );
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
    /* try to load font from a DLL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
    error = fnt_face_get_dll_font( face, face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
    if ( !error && face_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
    if ( error == FNT_Err_Unknown_File_Format )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
      /* this didn't work; try to load a single FNT font */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
      FNT_Font  font;
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
      if ( FT_NEW( face->font ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
        goto Exit;
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
      face->root.num_faces = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
      font           = face->font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
      font->offset   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
      font->fnt_size = stream->size;
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
      error = fnt_font_load( font, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
        if ( face_index > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
          error = FNT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
        else if ( face_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
          goto Exit;
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
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
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    /* we now need to fill the root FT_Face fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    /* with relevant information                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
      FT_Face     root = FT_FACE( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
      FNT_Font    font = face->font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
      FT_PtrDist  family_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
      root->face_index = face_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
      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
   743
                         FT_FACE_FLAG_HORIZONTAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
      if ( font->header.avg_width == font->header.max_width )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
      if ( font->header.italic )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
        root->style_flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
      if ( font->header.weight >= 800 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
        root->style_flags |= FT_STYLE_FLAG_BOLD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
      /* set up the `fixed_sizes' array */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
      if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
        goto Fail;
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
      root->num_fixed_sizes = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
        FT_Bitmap_Size*  bsize = root->available_sizes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
        FT_UShort        x_res, y_res;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
        bsize->width  = font->header.avg_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
        bsize->height = (FT_Short)(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
          font->header.pixel_height + font->header.external_leading );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
        bsize->size   = font->header.nominal_point_size << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
        x_res = font->header.horizontal_resolution;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
        if ( !x_res )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
          x_res = 72;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
        y_res = font->header.vertical_resolution;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
        if ( !y_res )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
          y_res = 72;
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
        bsize->y_ppem = FT_MulDiv( bsize->size, y_res, 72 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
        bsize->y_ppem = FT_PIX_ROUND( bsize->y_ppem );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
        /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
         * this reads:
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
         * the nominal height is larger than the bbox's height
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
         * => nominal_point_size contains incorrect value;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
         *    use pixel_height as the nominal height
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
        if ( bsize->y_ppem > ( font->header.pixel_height << 6 ) )
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
          FT_TRACE2(( "use pixel_height as the nominal height\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
          bsize->y_ppem = font->header.pixel_height << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
          bsize->size   = FT_MulDiv( bsize->y_ppem, 72, y_res );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
        bsize->x_ppem = FT_MulDiv( bsize->size, x_res, 72 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
        bsize->x_ppem = FT_PIX_ROUND( bsize->x_ppem );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
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
        FT_CharMapRec  charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
        charmap.encoding    = FT_ENCODING_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
        /* initial platform/encoding should indicate unset status? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
        charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
        charmap.encoding_id = TT_APPLE_ID_DEFAULT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
        charmap.face        = root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
        if ( font->header.charset == FT_WinFNT_ID_MAC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
          charmap.encoding    = FT_ENCODING_APPLE_ROMAN;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
          charmap.platform_id = TT_PLATFORM_MACINTOSH;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
/*        charmap.encoding_id = TT_MAC_ID_ROMAN; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
        error = FT_CMap_New( fnt_cmap_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
                             NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
                             &charmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
                             NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
          goto Fail;
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
        /* Select default charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
        if ( root->num_charmaps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
          root->charmap = root->charmaps[0];
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
      /* setup remaining flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
      /* reserve one slot for the .notdef glyph at index 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
      root->num_glyphs = font->header.last_char -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
                         font->header.first_char + 1 + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
      if ( font->header.face_name_offset >= font->header.file_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
        FT_TRACE2(( "invalid family name offset\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
        error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
        goto Fail;
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
      family_size = font->header.file_size - font->header.face_name_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
      /* Some broken fonts don't delimit the face name with a final */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
      /* NULL byte -- the frame is erroneously one byte too small.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
      /* We thus allocate one more byte, setting it explicitly to   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
      /* zero.                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
      if ( FT_ALLOC( font->family_name, family_size + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
      FT_MEM_COPY( font->family_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
                   font->fnt_frame + font->header.face_name_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
                   family_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
      font->family_name[family_size] = '\0';
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
      if ( FT_REALLOC( font->family_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
                       family_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
                       ft_strlen( font->family_name ) + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
      root->family_name = font->family_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
      root->style_name  = (char *)"Regular";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
      if ( root->style_flags & FT_STYLE_FLAG_BOLD )
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
        if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
          root->style_name = (char *)"Bold Italic";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
          root->style_name = (char *)"Bold";
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
      else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
        root->style_name = (char *)"Italic";
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
    goto Exit;
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
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
    FNT_Face_Done( face );
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
  FNT_Size_Select( FT_Size  size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
    FNT_Face          face   = (FNT_Face)size->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
    FT_WinFNT_Header  header = &face->font->header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
    FT_Select_Metrics( size->face, 0 );
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
    size->metrics.ascender    = header->ascent * 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
    size->metrics.descender   = -( header->pixel_height -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
                                   header->ascent ) * 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
    size->metrics.max_advance = header->max_width * 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
    return FNT_Err_Ok;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
  FNT_Size_Request( FT_Size          size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
                    FT_Size_Request  req )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
    FNT_Face          face    = (FNT_Face)size->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
    FT_WinFNT_Header  header  = &face->font->header;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
    FT_Bitmap_Size*   bsize   = size->face->available_sizes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
    FT_Error          error   = FNT_Err_Invalid_Pixel_Size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
    FT_Long           height;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
    height = FT_REQUEST_HEIGHT( req );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
    height = ( height + 32 ) >> 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
    switch ( req->type )
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
    case FT_SIZE_REQUEST_TYPE_NOMINAL:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
      if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
        error = FNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
      break;
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
    case FT_SIZE_REQUEST_TYPE_REAL_DIM:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
      if ( height == header->pixel_height )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
        error = FNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
      error = FNT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
      break;
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
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
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
      return FNT_Size_Select( size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
  FNT_Load_Glyph( FT_GlyphSlot  slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
                  FT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
                  FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
                  FT_Int32      load_flags )
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
    FNT_Face    face   = (FNT_Face)FT_SIZE_FACE( size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
    FNT_Font    font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
    FT_Error    error  = FNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
    FT_Byte*    p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
    FT_Int      len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
    FT_Bitmap*  bitmap = &slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
    FT_ULong    offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
    FT_Bool     new_format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
    FT_UNUSED( load_flags );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
    if ( !face )
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
      error = FNT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
    font = face->font;
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
    if ( !font ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
         glyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
      error = FNT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
    if ( glyph_index > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
      glyph_index--;                           /* revert to real index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
      glyph_index = font->header.default_char; /* the .notdef glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
    new_format = FT_BOOL( font->header.version == 0x300 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
    len        = new_format ? 6 : 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
    /* jump to glyph entry */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
    p = font->fnt_frame + ( new_format ? 148 : 118 ) + len * glyph_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
    bitmap->width = FT_NEXT_SHORT_LE( p );
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
    if ( new_format )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
      offset = FT_NEXT_ULONG_LE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
      offset = FT_NEXT_USHORT_LE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
    if ( offset >= font->header.file_size )
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
      FT_TRACE2(( "invalid FNT offset\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
      error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
    /* jump to glyph data */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
    p = font->fnt_frame + /* font->header.bits_offset */ + offset;
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
    /* allocate and build bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
      FT_Memory  memory = FT_FACE_MEMORY( slot->face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
      FT_Int     pitch  = ( bitmap->width + 7 ) >> 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
      FT_Byte*   column;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
      FT_Byte*   write;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
      bitmap->pitch      = pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
      bitmap->rows       = font->header.pixel_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
      bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
      if ( offset + pitch * bitmap->rows >= font->header.file_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
        FT_TRACE2(( "invalid bitmap width\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
        error = FNT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
        goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
      /* note: since glyphs are stored in columns and not in rows we */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
      /*       can't use ft_glyphslot_set_bitmap                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
      if ( FT_ALLOC_MULT( bitmap->buffer, pitch, bitmap->rows ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
      column = (FT_Byte*)bitmap->buffer;
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
      for ( ; pitch > 0; pitch--, column++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
        FT_Byte*  limit = p + bitmap->rows;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
        for ( write = column; p < limit; p++, write += bitmap->pitch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
          *write = *p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
    slot->internal->flags = FT_GLYPH_OWN_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
    slot->bitmap_left     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
    slot->bitmap_top      = font->header.ascent;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
    slot->format          = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
    /* now set up metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
    slot->metrics.width        = bitmap->width << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
    slot->metrics.height       = bitmap->rows << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
    slot->metrics.horiAdvance  = bitmap->width << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
    slot->metrics.horiBearingX = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
    slot->metrics.horiBearingY = slot->bitmap_top << 6;
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
    ft_synthesize_vertical_metrics( &slot->metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
                                    bitmap->rows << 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
  }
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
  winfnt_get_header( FT_Face               face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
                     FT_WinFNT_HeaderRec  *aheader )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
    FNT_Font  font = ((FNT_Face)face)->font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
    *aheader = font->header;
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
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
  }
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
  static const FT_Service_WinFntRec  winfnt_service_rec =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
    winfnt_get_header
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
 /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
  *  SERVICE LIST
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
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
  static const FT_ServiceDescRec  winfnt_services[] =
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
    { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_WINFNT },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
    { FT_SERVICE_ID_WINFNT,    &winfnt_service_rec },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
    { NULL, NULL }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
  static FT_Module_Interface
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
  winfnt_get_service( FT_Driver         driver,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
                      const FT_String*  service_id )
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
    FT_UNUSED( driver );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
    return ft_service_list_lookup( winfnt_services, service_id );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
  const FT_Driver_ClassRec  winfnt_driver_class =
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_MODULE_FONT_DRIVER        |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
      FT_MODULE_DRIVER_NO_OUTLINES,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
      sizeof ( FT_DriverRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
      "winfonts",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
      0x20000L,
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
      0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
      (FT_Module_Constructor)0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
      (FT_Module_Requester)  winfnt_get_service
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
    sizeof( FNT_FaceRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
    sizeof( FT_SizeRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
    sizeof( FT_GlyphSlotRec ),
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
    (FT_Face_InitFunc)        FNT_Face_Init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
    (FT_Face_DoneFunc)        FNT_Face_Done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
    (FT_Size_InitFunc)        0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
    (FT_Size_DoneFunc)        0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
    (FT_Slot_InitFunc)        0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
    (FT_Slot_DoneFunc)        0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
    ft_stub_set_char_sizes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
    ft_stub_set_pixel_sizes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
    (FT_Slot_LoadFunc)        FNT_Load_Glyph,
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
    (FT_Face_GetKerningFunc)  0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
    (FT_Face_AttachFunc)      0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
    (FT_Face_GetAdvancesFunc) 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
    (FT_Size_RequestFunc)     FNT_Size_Request,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
    (FT_Size_SelectFunc)      FNT_Size_Select
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
/* END */