misc/libfreetype/src/cache/ftccmap.c
author dag10
Fri, 01 Mar 2013 16:58:00 -0500
changeset 8622 2045bdf1b11b
parent 5172 88f2e05288ba
permissions -rw-r--r--
Resolves issue #528. Fixed platform-specific order of buttons on seed prompt and new room prompt. Fixed height of back button on all pages -- now aligns to bottom. On pagemain, feedback and dlc buttons no longer fixed size.
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
/*  ftccmap.c                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    FreeType CharMap cache (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 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*            2010, 2011 by                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_FREETYPE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_CACHE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "ftcmanag.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_INTERNAL_MEMORY_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "ftccback.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include "ftcerror.h"
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#define FT_COMPONENT  trace_cache
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  typedef enum  FTC_OldCMapType_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
    FTC_OLD_CMAP_BY_INDEX    = 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
    FTC_OLD_CMAP_BY_ENCODING = 1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
    FTC_OLD_CMAP_BY_ID       = 2
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
  } FTC_OldCMapType;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  typedef struct  FTC_OldCMapIdRec_
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_UInt  platform;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
    FT_UInt  encoding;
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
  } FTC_OldCMapIdRec, *FTC_OldCMapId;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  typedef struct  FTC_OldCMapDescRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    FTC_FaceID       face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    FTC_OldCMapType  type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    union
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
      FT_UInt           index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
      FT_Encoding       encoding;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      FTC_OldCMapIdRec  id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    } u;
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
  } FTC_OldCMapDescRec, *FTC_OldCMapDesc;
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
#endif /* FT_CONFIG_OLD_INTERNALS */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  /* Each FTC_CMapNode contains a simple array to map a range of character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  /* codes to equivalent glyph indices.                                    */
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
  /* For now, the implementation is very basic: Each node maps a range of  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  /* 128 consecutive character codes to their corresponding glyph indices. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  /* We could do more complex things, but I don't think it is really very  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  /* useful.                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  /* number of glyph indices / character code per node */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
#define FTC_CMAP_INDICES_MAX  128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
  /* compute a query/node hash */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
#define FTC_CMAP_HASH( faceid, index, charcode )         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
          ( _FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
            ( (charcode) / FTC_CMAP_INDICES_MAX )      )
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
  /* the charmap query */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  typedef struct  FTC_CMapQueryRec_
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
    FTC_FaceID  face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    FT_UInt     cmap_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    FT_UInt32   char_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  } FTC_CMapQueryRec, *FTC_CMapQuery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
#define FTC_CMAP_QUERY( x )  ((FTC_CMapQuery)(x))
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
#define FTC_CMAP_QUERY_HASH( x )                                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
          FTC_CMAP_HASH( (x)->face_id, (x)->cmap_index, (x)->char_code )
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
  /* the cmap cache node */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  typedef struct  FTC_CMapNodeRec_
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
    FTC_NodeRec  node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FTC_FaceID   face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    FT_UInt      cmap_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    FT_UInt32    first;                         /* first character in node */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    FT_UInt16    indices[FTC_CMAP_INDICES_MAX]; /* array of glyph indices  */
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
  } FTC_CMapNodeRec, *FTC_CMapNode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
#define FTC_CMAP_NODE( x ) ( (FTC_CMapNode)( x ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
#define FTC_CMAP_NODE_HASH( x )                                      \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
          FTC_CMAP_HASH( (x)->face_id, (x)->cmap_index, (x)->first )
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
  /* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  /* glyph indices haven't been queried through FT_Get_Glyph_Index() yet   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
#define FTC_CMAP_UNKNOWN  ( (FT_UInt16)-1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  /*************************************************************************/
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
  /*****                        CHARMAP NODES                          *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  /*************************************************************************/
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
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
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  ftc_cmap_node_free( FTC_Node   ftcnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
                      FTC_Cache  cache )
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
    FTC_CMapNode  node   = (FTC_CMapNode)ftcnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    FT_Memory     memory = cache->memory;
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_FREE( node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
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
  /* initialize a new cmap node */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
  ftc_cmap_node_new( FTC_Node   *ftcanode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
                     FT_Pointer  ftcquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
                     FTC_Cache   cache )
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
    FTC_CMapNode  *anode  = (FTC_CMapNode*)ftcanode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
    FTC_CMapQuery  query  = (FTC_CMapQuery)ftcquery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    FT_Error       error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    FT_Memory      memory = cache->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    FTC_CMapNode   node   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    FT_UInt        nn;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    if ( !FT_NEW( node ) )
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
      node->face_id    = query->face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
      node->cmap_index = query->cmap_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      node->first      = (query->char_code / FTC_CMAP_INDICES_MAX) *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
                         FTC_CMAP_INDICES_MAX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      for ( nn = 0; nn < FTC_CMAP_INDICES_MAX; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
        node->indices[nn] = FTC_CMAP_UNKNOWN;
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
    *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
  /* compute the weight of a given cmap node */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
  FT_CALLBACK_DEF( FT_Offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
  ftc_cmap_node_weight( FTC_Node   cnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
                        FTC_Cache  cache )
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
    FT_UNUSED( cnode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    FT_UNUSED( cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
    return sizeof ( *cnode );
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
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
  /* compare a cmap node to a given query */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
  FT_CALLBACK_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
  ftc_cmap_node_compare( FTC_Node    ftcnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
                         FT_Pointer  ftcquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
                         FTC_Cache   cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
                         FT_Bool*    list_changed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FTC_CMapNode   node  = (FTC_CMapNode)ftcnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FTC_CMapQuery  query = (FTC_CMapQuery)ftcquery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    FT_UNUSED( cache );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    if ( list_changed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
      *list_changed = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    if ( node->face_id    == query->face_id    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
         node->cmap_index == query->cmap_index )
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
      FT_UInt32  offset = (FT_UInt32)( query->char_code - node->first );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
      return FT_BOOL( offset < FTC_CMAP_INDICES_MAX );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    return 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
  FT_CALLBACK_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
  ftc_cmap_node_remove_faceid( FTC_Node    ftcnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
                               FT_Pointer  ftcface_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
                               FTC_Cache   cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
                               FT_Bool*    list_changed )
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
    FTC_CMapNode  node    = (FTC_CMapNode)ftcnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    FTC_FaceID    face_id = (FTC_FaceID)ftcface_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    FT_UNUSED( cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    if ( list_changed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
      *list_changed = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    return FT_BOOL( node->face_id == face_id );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  /*************************************************************************/
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  /*****                    GLYPH IMAGE CACHE                          *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
  /*****                                                               *****/
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
  /*************************************************************************/
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
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
  const FTC_CacheClassRec  ftc_cmap_cache_class =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    ftc_cmap_node_new,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    ftc_cmap_node_weight,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
    ftc_cmap_node_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    ftc_cmap_node_remove_faceid,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    ftc_cmap_node_free,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    sizeof ( FTC_CacheRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    ftc_cache_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    ftc_cache_done,
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
  /* documentation is in ftcache.h */
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
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
  FTC_CMapCache_New( FTC_Manager     manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
                     FTC_CMapCache  *acache )
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
    return FTC_Manager_RegisterCache( manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
                                      &ftc_cmap_cache_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
                                      FTC_CACHE_P( acache ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
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
   *  Unfortunately, it is not possible to support binary backwards
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
   *  compatibility in the cmap cache.  The FTC_CMapCache_Lookup signature
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
   *  changes were too deep, and there is no clever hackish way to detect
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
   *  what kind of structure we are being passed.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
   *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
   *  On the other hand it seems that no production code is using this
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
   *  function on Unix distributions.
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
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  /* documentation is in ftcache.h */
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
  FT_EXPORT_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
  FTC_CMapCache_Lookup( FTC_CMapCache  cmap_cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
                        FTC_FaceID     face_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
                        FT_Int         cmap_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
                        FT_UInt32      char_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    FTC_Cache         cache = FTC_CACHE( cmap_cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    FTC_CMapQueryRec  query;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    FTC_Node          node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    FT_Error          error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    FT_UInt           gindex = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    FT_PtrDist        hash;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    FT_Int            no_cmap_change = 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
    if ( cmap_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
      /* Treat a negative cmap index as a special value, meaning that you */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
      /* don't want to change the FT_Face's character map through this    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
      /* call.  This can be useful if the face requester callback already */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
      /* sets the face's charmap to the appropriate value.                */
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
      no_cmap_change = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
      cmap_index     = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    if ( !cache )
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_TRACE0(( "FTC_CMapCache_Lookup: bad arguments, returning 0\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
     * If cmap_index is greater than the maximum number of cachable
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
     * charmaps, we assume the request is from a legacy rogue client 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
     * using old internal header. See include/config/ftoption.h.
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
    if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE && !no_cmap_change )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
      FTC_OldCMapDesc  desc = (FTC_OldCMapDesc) face_id;
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
      char_code     = (FT_UInt32)cmap_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
      query.face_id = desc->face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
      switch ( desc->type )
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
      case FTC_OLD_CMAP_BY_INDEX:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
        query.cmap_index = desc->u.index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
        query.char_code  = (FT_UInt32)cmap_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
      case FTC_OLD_CMAP_BY_ENCODING:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
          FT_Face  face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
          error = FTC_Manager_LookupFace( cache->manager, desc->face_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
                                          &face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
            return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
          FT_Select_Charmap( face, desc->u.encoding );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
          return FT_Get_Char_Index( face, char_code );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
        return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
      query.face_id    = face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
      query.cmap_index = (FT_UInt)cmap_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
      query.char_code  = char_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
    hash = FTC_CMAP_HASH( face_id, cmap_index, char_code );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
                          node, error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    error = FTC_Cache_Lookup( cache, hash, &query, &node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    FT_ASSERT( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first ) <
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
                FTC_CMAP_INDICES_MAX );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
    /* something rotten can happen with rogue clients */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
    if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >=
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
                    FTC_CMAP_INDICES_MAX ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
      return 0; /* XXX: should return appropriate 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
    gindex = FTC_CMAP_NODE( node )->indices[char_code -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
                                            FTC_CMAP_NODE( node )->first];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    if ( gindex == FTC_CMAP_UNKNOWN )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
      FT_Face  face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
      gindex = 0;
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
      error = FTC_Manager_LookupFace( cache->manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
                                      FTC_CMAP_NODE( node )->face_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
                                      &face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
#ifdef FT_MAX_CHARMAP_CACHEABLE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
      /* something rotten can happen with rogue clients */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
      if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
        return 0; /* XXX: should return appropriate error */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
#endif
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
      if ( (FT_UInt)cmap_index < (FT_UInt)face->num_charmaps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
        FT_CharMap  old, cmap  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
        old  = face->charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
        cmap = face->charmaps[cmap_index];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
        if ( old != cmap && !no_cmap_change )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
          FT_Set_Charmap( face, cmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
        gindex = FT_Get_Char_Index( face, char_code );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
        if ( old != cmap && !no_cmap_change )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
          FT_Set_Charmap( face, old );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
      FTC_CMAP_NODE( node )->indices[char_code -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
                                     FTC_CMAP_NODE( node )->first]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
        = (FT_UShort)gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    return gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
/* END */