misc/libfreetype/src/type42/t42objs.c
author sheepluva
Wed, 05 Jun 2013 16:28:30 +0200
changeset 9137 d987230b85ed
parent 5172 88f2e05288ba
permissions -rw-r--r--
fixed all engine compilation hints and notes (that I could see)
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
/*  t42objs.c                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    Type 42 objects manager (body).                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  by Roberto Alameda.                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include "t42objs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include "t42parse.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "t42error.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_LIST_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_TRUETYPE_IDS_H 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#define FT_COMPONENT  trace_t42
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  T42_Open_Face( T42_Face  face )
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
    T42_LoaderRec  loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
    T42_Parser     parser;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
    T1_Font        type1 = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
    FT_Memory      memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
    FT_Error       error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
    PSAux_Service  psaux  = (PSAux_Service)face->psaux;
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
    t42_loader_init( &loader, face );
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
    parser = &loader.parser;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    if ( FT_ALLOC( face->ttf_data, 12 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    error = t42_parser_init( parser,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
                             face->root.stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
                             memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
                             psaux);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      goto Exit;
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
    error = t42_parse_dict( face, &loader,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
                            parser->base_dict, parser->base_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    if ( type1->font_type != 42 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
      error = T42_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
      goto Exit;
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
    /* now, propagate the charstrings and glyphnames tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    /* to the Type1 data                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    type1->num_glyphs = loader.num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    if ( !loader.charstrings.init )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      error = T42_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    loader.charstrings.init  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    type1->charstrings_block = loader.charstrings.block;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    type1->charstrings       = loader.charstrings.elements;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    type1->charstrings_len   = loader.charstrings.lengths;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    /* we copy the glyph names `block' and `elements' fields; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
    /* the `lengths' field must be released later             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    type1->glyph_names_block    = loader.glyph_names.block;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    type1->glyph_names          = (FT_String**)loader.glyph_names.elements;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    loader.glyph_names.block    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    loader.glyph_names.elements = 0;
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
    /* we must now build type1.encoding when we have a custom array */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
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_Int    charcode, idx, min_char, max_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
      FT_Byte*  char_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
      FT_Byte*  glyph_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      /* OK, we do the following: for each element in the encoding   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      /* table, look up the index of the glyph having the same name  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      /* as defined in the CharStrings array.                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
      /* The index is then stored in type1.encoding.char_index, and  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      /* the name in type1.encoding.char_name                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
      min_char = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
      max_char = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      charcode = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
      for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
        type1->encoding.char_index[charcode] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
        type1->encoding.char_name [charcode] = (char *)".notdef";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
        char_name = loader.encoding_table.elements[charcode];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
        if ( char_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
          for ( idx = 0; idx < type1->num_glyphs; idx++ )
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
            glyph_name = (FT_Byte*)type1->glyph_names[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
            if ( ft_strcmp( (const char*)char_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
                            (const char*)glyph_name ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
              type1->encoding.char_index[charcode] = (FT_UShort)idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
              type1->encoding.char_name [charcode] = (char*)glyph_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
              /* Change min/max encoded char only if glyph name is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
              /* not /.notdef                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
              if ( ft_strcmp( (const char*)".notdef",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
                              (const char*)glyph_name ) != 0 )
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
                if ( charcode < min_char )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
                  min_char = charcode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
                if ( charcode >= max_char )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
                  max_char = charcode + 1;
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
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      type1->encoding.code_first = min_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      type1->encoding.code_last  = max_char;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
      type1->encoding.num_chars  = loader.num_chars;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    }
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    t42_loader_done( &loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
  /***************** Driver Functions *************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
  T42_Face_Init( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
                 T42_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
                 FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
                 FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
                 FT_Parameter*  params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    FT_Error            error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    FT_Service_PsCMaps  psnames;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    PSAux_Service       psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    FT_Face             root  = (FT_Face)&face->root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    T1_Font             type1 = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    PS_FontInfo         info  = &type1->font_info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    FT_UNUSED( num_params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    FT_UNUSED( params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    face->ttf_face       = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    face->root.num_faces = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    face->psnames = psnames;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
                                           "psaux" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    psaux = (PSAux_Service)face->psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    /* open the tokenizer, this will also check the font format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    error = T42_Open_Face( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      goto Exit;
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
    /* if we just wanted to check the format, leave successfully now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    if ( face_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    /* check the face index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    if ( face_index > 0 )
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
      FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      error = T42_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    /* Now load the font program into the face object */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    /* Init the face object fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    /* Now set up root face fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    root->num_glyphs   = type1->num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    root->num_charmaps = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    root->face_index   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    root->face_flags = FT_FACE_FLAG_SCALABLE    |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
                       FT_FACE_FLAG_HORIZONTAL  |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
                       FT_FACE_FLAG_GLYPH_NAMES;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    if ( info->is_fixed_pitch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
      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
   215
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    /* We only set this flag if we have the patented bytecode interpreter. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    /* There are no known `tricky' Type42 fonts that could be loaded with  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    /* the unpatented interpreter.                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    root->face_flags |= FT_FACE_FLAG_HINTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
#endif
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
    /* XXX: TODO -- add kerning with .afm support */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    /* get style name -- be careful, some broken fonts only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    /* have a `/FontName' dictionary entry!                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    root->family_name = info->family_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    /* assume "Regular" style if we don't know better */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    root->style_name = (char *)"Regular";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    if ( root->family_name )
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
      char*  full   = info->full_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
      char*  family = root->family_name;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
      if ( full )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
        while ( *full )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
          if ( *full == *family )
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
            family++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
            full++;
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
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
            if ( *full == ' ' || *full == '-' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
              full++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
            else if ( *family == ' ' || *family == '-' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
              family++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
            else
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 ( !*family )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
                root->style_name = full;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
      /* do we have a `/FontName'? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
      if ( type1->font_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
        root->family_name = type1->font_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    /* no embedded bitmap support */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
    root->num_fixed_sizes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
    root->available_sizes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
    /* Load the TTF font embedded in the T42 font */
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_Open_Args  args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
      args.flags       = FT_OPEN_MEMORY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
      args.memory_base = face->ttf_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
      args.memory_size = face->ttf_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
      if ( num_params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
        args.flags     |= FT_OPEN_PARAMS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
        args.num_params = num_params;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
        args.params     = params;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
      error = FT_Open_Face( FT_FACE_LIBRARY( face ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
                            &args, 0, &face->ttf_face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    FT_Done_Size( face->ttf_face->size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    /* Ignore info in FontInfo dictionary and use the info from the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    /* loaded TTF font.  The PostScript interpreter also ignores it. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    root->bbox         = face->ttf_face->bbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
    root->units_per_EM = face->ttf_face->units_per_EM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
    root->ascender  = face->ttf_face->ascender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    root->descender = face->ttf_face->descender;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
    root->height    = face->ttf_face->height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    root->max_advance_width  = face->ttf_face->max_advance_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    root->max_advance_height = face->ttf_face->max_advance_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    root->underline_position  = (FT_Short)info->underline_position;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    root->underline_thickness = (FT_Short)info->underline_thickness;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    /* compute style flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    root->style_flags = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    if ( info->italic_angle )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
      root->style_flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
      root->style_flags |= FT_STYLE_FLAG_BOLD;
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
    if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
      root->face_flags |= FT_FACE_FLAG_VERTICAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
      if ( psnames && psaux )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
        FT_CharMapRec    charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
        T1_CMap_Classes  cmap_classes = psaux->t1_cmap_classes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
        FT_CMap_Class    clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
        charmap.face = root;
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
        /* first of all, try to synthesize a Unicode charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
        charmap.platform_id = TT_PLATFORM_MICROSOFT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
        charmap.encoding_id = TT_MS_ID_UNICODE_CS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
        charmap.encoding    = FT_ENCODING_UNICODE;
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
        error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
        if ( error && FT_Err_No_Unicode_Glyph_Name != error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
        error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
        /* now, generate an Adobe Standard encoding when appropriate */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
        charmap.platform_id = TT_PLATFORM_ADOBE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
        clazz               = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
        switch ( type1->encoding_type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
        case T1_ENCODING_TYPE_STANDARD:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
          charmap.encoding    = FT_ENCODING_ADOBE_STANDARD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
          charmap.encoding_id = TT_ADOBE_ID_STANDARD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
          clazz               = cmap_classes->standard;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
          break;
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
        case T1_ENCODING_TYPE_EXPERT:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
          charmap.encoding    = FT_ENCODING_ADOBE_EXPERT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
          charmap.encoding_id = TT_ADOBE_ID_EXPERT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
          clazz               = cmap_classes->expert;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
        case T1_ENCODING_TYPE_ARRAY:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
          charmap.encoding    = FT_ENCODING_ADOBE_CUSTOM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
          charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
          clazz               = cmap_classes->custom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
          break;
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
        case T1_ENCODING_TYPE_ISOLATIN1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
          charmap.encoding    = FT_ENCODING_ADOBE_LATIN_1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
          charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
          clazz               = cmap_classes->unicode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
          break;
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
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
          ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
        if ( clazz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
          error = FT_CMap_New( clazz, NULL, &charmap, NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        /* Select default charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
        if ( root->num_charmaps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
          root->charmap = root->charmaps[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
#endif
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
  T42_Face_Done( T42_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
    T1_Font      type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    PS_FontInfo  info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    FT_Memory    memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
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 ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
    type1  = &face->type1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    info   = &type1->font_info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
    /* delete internal ttf face prior to freeing face->ttf_data */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    if ( face->ttf_face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
      FT_Done_Face( face->ttf_face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    /* release font info strings */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    FT_FREE( info->version );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
    FT_FREE( info->notice );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    FT_FREE( info->full_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    FT_FREE( info->family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    FT_FREE( info->weight );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
    /* release top dictionary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
    FT_FREE( type1->charstrings_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    FT_FREE( type1->charstrings );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
    FT_FREE( type1->glyph_names );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
    FT_FREE( type1->charstrings_block );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
    FT_FREE( type1->glyph_names_block );
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
    FT_FREE( type1->encoding.char_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
    FT_FREE( type1->encoding.char_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
    FT_FREE( type1->font_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
    FT_FREE( face->ttf_data );
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
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
    /* release afm data if present */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    if ( face->afm_data )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
    /* release unicode map, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
    FT_FREE( face->unicode_map.maps );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    face->unicode_map.num_maps = 0;
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
    face->root.family_name = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
    face->root.style_name  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
  /*************************************************************************/
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
  /*    T42_Driver_Init                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
  /*    Initializes a given Type 42 driver object.                         */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
  /*    driver :: A handle to the target driver object.                    */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
  T42_Driver_Init( T42_Driver  driver )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
    FT_Module  ttmodule;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
    ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
    return T42_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
  T42_Driver_Done( T42_Driver  driver )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
    FT_UNUSED( driver );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
  T42_Size_Init( T42_Size  size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    FT_Face   face = size->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
    T42_Face  t42face = (T42_Face)face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    FT_Size   ttsize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
    FT_Error  error   = T42_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    error = FT_New_Size( t42face->ttf_face, &ttsize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    size->ttsize = ttsize;
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
    FT_Activate_Size( ttsize );
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
  T42_Size_Request( T42_Size         size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
                    FT_Size_Request  req )
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
    T42_Face  face = (T42_Face)size->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
    FT_Activate_Size( size->ttsize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
    error = FT_Request_Size( face->ttf_face, req );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
      ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
  T42_Size_Select( T42_Size  size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
                   FT_ULong  strike_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
    T42_Face  face = (T42_Face)size->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
    FT_Error  error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
    FT_Activate_Size( size->ttsize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
    error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
      ( (FT_Size)size )->metrics = face->ttf_face->size->metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
  T42_Size_Done( T42_Size  size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
    FT_Face      face    = size->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
    T42_Face     t42face = (T42_Face)face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
    FT_ListNode  node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
    node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    if ( node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
      FT_Done_Size( size->ttsize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
      size->ttsize = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
  T42_GlyphSlot_Init( T42_GlyphSlot  slot )
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
    FT_Face       face    = slot->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
    T42_Face      t42face = (T42_Face)face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
    FT_GlyphSlot  ttslot;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
    FT_Error      error   = T42_Err_Ok;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    if ( face->glyph == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
      /* First glyph slot for this face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
      slot->ttslot = t42face->ttf_face->glyph;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
      error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
      slot->ttslot = ttslot;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
  T42_GlyphSlot_Done( T42_GlyphSlot slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    FT_Done_GlyphSlot( slot->ttslot );
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
  t42_glyphslot_clear( FT_GlyphSlot  slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
    /* free bitmap if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    ft_glyphslot_free_bitmap( slot );
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
    /* clear all public fields in the glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
    FT_ZERO( &slot->metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
    FT_ZERO( &slot->outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    FT_ZERO( &slot->bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    slot->bitmap_left   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    slot->bitmap_top    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
    slot->num_subglyphs = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
    slot->subglyphs     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
    slot->control_data  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
    slot->control_len   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    slot->other         = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
    slot->format        = FT_GLYPH_FORMAT_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    slot->linearHoriAdvance = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
    slot->linearVertAdvance = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
  T42_GlyphSlot_Load( FT_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
                      FT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
                      FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
                      FT_Int32      load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
    T42_GlyphSlot    t42slot = (T42_GlyphSlot)glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
    T42_Size         t42size = (T42_Size)size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    FT_Driver_Class  ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
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
    t42_glyphslot_clear( t42slot->ttslot );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
    error = ttclazz->load_glyph( t42slot->ttslot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
                                 t42size->ttsize,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
                                 glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
                                 load_flags | FT_LOAD_NO_BITMAP );
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
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
      glyph->metrics = t42slot->ttslot->metrics;
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
      glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
      glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance;
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
      glyph->format  = t42slot->ttslot->format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
      glyph->outline = t42slot->ttslot->outline;
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
      glyph->bitmap      = t42slot->ttslot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
      glyph->bitmap_left = t42slot->ttslot->bitmap_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      glyph->bitmap_top  = t42slot->ttslot->bitmap_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
      glyph->num_subglyphs = t42slot->ttslot->num_subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
      glyph->subglyphs     = t42slot->ttslot->subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
      glyph->control_data  = t42slot->ttslot->control_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
      glyph->control_len   = t42slot->ttslot->control_len;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
    return error;
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
/* END */