misc/libfreetype/src/psaux/t1cmap.c
author unc0rr
Sat, 17 Nov 2012 22:07:17 +0400
branchphysfslayer
changeset 8046 4d3415927d2c
parent 5172 88f2e05288ba
permissions -rw-r--r--
Use (undocumented) Mix_LoadMUS_RW to load music
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
/*  t1cmap.c                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    Type 1 character map support (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, 2006, 2007 by                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include "t1cmap.h"
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 FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "psauxerr.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
  /*****          TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS           *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*************************************************************************/
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  t1_cmap_std_init( T1_CMapStd  cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
                    FT_Int      is_expert )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
    T1_Face             face    = (T1_Face)FT_CMAP_FACE( cmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
    FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
    cmap->num_glyphs    = face->type1.num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
    cmap->glyph_names   = (const char* const*)face->type1.glyph_names;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    cmap->sid_to_string = psnames->adobe_std_strings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    cmap->code_to_sid   = is_expert ? psnames->adobe_expert_encoding
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
                                    : psnames->adobe_std_encoding;
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_ASSERT( cmap->code_to_sid != NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  t1_cmap_std_done( T1_CMapStd  cmap )
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
    cmap->num_glyphs    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    cmap->glyph_names   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    cmap->sid_to_string = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    cmap->code_to_sid   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
  t1_cmap_std_char_index( T1_CMapStd  cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
                          FT_UInt32   char_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    FT_UInt  result = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    if ( char_code < 256 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
      FT_UInt      code, n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
      const char*  glyph_name;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      /* convert character code to Adobe SID string */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
      code       = cmap->code_to_sid[char_code];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
      glyph_name = cmap->sid_to_string( code );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
      /* look for the corresponding glyph name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
      for ( n = 0; n < cmap->num_glyphs; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
        const char* gname = cmap->glyph_names[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
        if ( gname && gname[0] == glyph_name[0]  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
             ft_strcmp( gname, glyph_name ) == 0 )
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
          result = n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
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
  FT_CALLBACK_DEF( FT_UInt32 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
  t1_cmap_std_char_next( T1_CMapStd   cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
                         FT_UInt32   *pchar_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    FT_UInt    result    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    FT_UInt32  char_code = *pchar_code + 1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    while ( char_code < 256 )
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
      result = t1_cmap_std_char_index( cmap, char_code );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      if ( result != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
      char_code++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    char_code = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    *pchar_code = char_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
    return result;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  t1_cmap_standard_init( T1_CMapStd  cmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    t1_cmap_std_init( cmap, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    return 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  t1_cmap_standard_class_rec =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    sizeof ( T1_CMapStdRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    (FT_CMap_InitFunc)     t1_cmap_standard_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    (FT_CMap_DoneFunc)     t1_cmap_std_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    (FT_CMap_CharIndexFunc)t1_cmap_std_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    (FT_CMap_CharNextFunc) t1_cmap_std_char_next,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    NULL, NULL, NULL, NULL, NULL
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
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
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
  t1_cmap_expert_init( T1_CMapStd  cmap )
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
    t1_cmap_std_init( cmap, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
  FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
  t1_cmap_expert_class_rec =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    sizeof ( T1_CMapStdRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    (FT_CMap_InitFunc)     t1_cmap_expert_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    (FT_CMap_DoneFunc)     t1_cmap_std_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    (FT_CMap_CharIndexFunc)t1_cmap_std_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    (FT_CMap_CharNextFunc) t1_cmap_std_char_next,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    NULL, NULL, NULL, NULL, NULL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  /*************************************************************************/
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  /*****                    TYPE1 CUSTOM ENCODING CMAP                 *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
  /*************************************************************************/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
  t1_cmap_custom_init( T1_CMapCustom  cmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    T1_Face      face     = (T1_Face)FT_CMAP_FACE( cmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    T1_Encoding  encoding = &face->type1.encoding;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    cmap->first   = encoding->code_first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    cmap->count   = (FT_UInt)( encoding->code_last - cmap->first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    cmap->indices = encoding->char_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    FT_ASSERT( cmap->indices != NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
    FT_ASSERT( encoding->code_first <= encoding->code_last );
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
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
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
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  t1_cmap_custom_done( T1_CMapCustom  cmap )
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
    cmap->indices = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    cmap->first   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    cmap->count   = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
  t1_cmap_custom_char_index( T1_CMapCustom  cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
                             FT_UInt32      char_code )
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
    FT_UInt    result = 0;
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
    if ( ( char_code >= cmap->first )                  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
         ( char_code < ( cmap->first + cmap->count ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
      result = cmap->indices[char_code];
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
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
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
  FT_CALLBACK_DEF( FT_UInt32 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
  t1_cmap_custom_char_next( T1_CMapCustom  cmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
                            FT_UInt32     *pchar_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    FT_UInt    result = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    FT_UInt32  char_code = *pchar_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    ++char_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    if ( char_code < cmap->first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      char_code = cmap->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    for ( ; char_code < ( cmap->first + cmap->count ); char_code++ )
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
      result = cmap->indices[char_code];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
      if ( result != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
        goto Exit;
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
    char_code = 0;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    *pchar_code = char_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
    return result;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
  FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
  t1_cmap_custom_class_rec =
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
    sizeof ( T1_CMapCustomRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    (FT_CMap_InitFunc)     t1_cmap_custom_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    (FT_CMap_DoneFunc)     t1_cmap_custom_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    (FT_CMap_CharIndexFunc)t1_cmap_custom_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    (FT_CMap_CharNextFunc) t1_cmap_custom_char_next,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    NULL, NULL, NULL, NULL, NULL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
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
  /*****            TYPE1 SYNTHETIC UNICODE ENCODING CMAP              *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
  FT_CALLBACK_DEF( const char * )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  t1_get_glyph_name( T1_Face  face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
                     FT_UInt  idx )
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
    return face->type1.glyph_names[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
  t1_cmap_unicode_init( PS_Unicodes  unicodes )
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
    T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    FT_Memory           memory  = FT_FACE_MEMORY( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
    return psnames->unicodes_init( memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
                                   unicodes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
                                   face->type1.num_glyphs,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
                                   (PS_GetGlyphNameFunc)&t1_get_glyph_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
                                   (PS_FreeGlyphNameFunc)NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
                                   (FT_Pointer)face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
  t1_cmap_unicode_done( PS_Unicodes  unicodes )
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_Face    face   = FT_CMAP_FACE( unicodes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    FT_Memory  memory = FT_FACE_MEMORY( face );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    FT_FREE( unicodes->maps );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    unicodes->num_maps = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
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
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  t1_cmap_unicode_char_index( PS_Unicodes  unicodes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
                              FT_UInt32    char_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
    FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
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
    return psnames->unicodes_char_index( unicodes, char_code );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
  FT_CALLBACK_DEF( FT_UInt32 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
  t1_cmap_unicode_char_next( PS_Unicodes  unicodes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
                             FT_UInt32   *pchar_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
    T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
    FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    return psnames->unicodes_char_next( unicodes, pchar_code );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
  FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
  t1_cmap_unicode_class_rec =
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
    sizeof ( PS_UnicodesRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
    (FT_CMap_InitFunc)     t1_cmap_unicode_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
    (FT_CMap_DoneFunc)     t1_cmap_unicode_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    (FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    NULL, NULL, NULL, NULL, NULL
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
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
/* END */