misc/libfreetype/src/cache/ftcbasic.c
author nemo
Fri, 27 Jul 2012 19:27:39 -0400
changeset 7459 8511a3f899d3
parent 5172 88f2e05288ba
permissions -rw-r--r--
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
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
/*  ftcbasic.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
/*    The FreeType basic cache interface (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 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 by            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_OBJECTS_H
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
#include FT_CACHE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "ftcglyph.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include "ftcimage.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include "ftcsbits.h"
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
#include "ftccback.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "ftcerror.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#define FT_COMPONENT  trace_cache
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
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
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
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
   *  These structures correspond to the FTC_Font and FTC_ImageDesc types
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
   *  that were defined in version 2.1.7.
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
  typedef struct  FTC_OldFontRec_
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
    FTC_FaceID  face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
    FT_UShort   pix_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
    FT_UShort   pix_height;
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
  } FTC_OldFontRec, *FTC_OldFont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  typedef struct  FTC_OldImageDescRec_
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
    FTC_OldFontRec  font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    FT_UInt32       flags;
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
  } FTC_OldImageDescRec, *FTC_OldImageDesc;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
   *  Notice that FTC_OldImageDescRec and FTC_ImageTypeRec are nearly
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
   *  identical, bit-wise.  The only difference is that the `width' and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
   *  `height' fields are expressed as 16-bit integers in the old structure,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
   *  and as normal `int' in the new one.
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
   *  We are going to perform a weird hack to detect which structure is
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
   *  being passed to the image and sbit caches.  If the new structure's
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
   *  `width' is larger than 0x10000, we assume that we are really receiving
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
   *  an FTC_OldImageDesc.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
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
   *  Basic Families
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
  typedef struct  FTC_BasicAttrRec_
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
    FTC_ScalerRec  scaler;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    FT_UInt        load_flags;
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
  } FTC_BasicAttrRec, *FTC_BasicAttrs;
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
#define FTC_BASIC_ATTR_COMPARE( a, b )                                 \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
          FT_BOOL( FTC_SCALER_COMPARE( &(a)->scaler, &(b)->scaler ) && \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
                   (a)->load_flags == (b)->load_flags               )
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
#define FTC_BASIC_ATTR_HASH( a )                                   \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
          ( FTC_SCALER_HASH( &(a)->scaler ) + 31*(a)->load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
  typedef struct  FTC_BasicQueryRec_
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
    FTC_GQueryRec     gquery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    FTC_BasicAttrRec  attrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  } FTC_BasicQueryRec, *FTC_BasicQuery;
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
  typedef struct  FTC_BasicFamilyRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    FTC_FamilyRec     family;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    FTC_BasicAttrRec  attrs;
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
  } FTC_BasicFamilyRec, *FTC_BasicFamily;
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
  FT_CALLBACK_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  ftc_basic_family_compare( FTC_MruNode  ftcfamily,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
                            FT_Pointer   ftcquery )
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_BasicFamily  family = (FTC_BasicFamily)ftcfamily;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FTC_BasicQuery   query  = (FTC_BasicQuery)ftcquery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    return FTC_BASIC_ATTR_COMPARE( &family->attrs, &query->attrs );
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
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
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  ftc_basic_family_init( FTC_MruNode  ftcfamily,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
                         FT_Pointer   ftcquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
                         FT_Pointer   ftccache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    FTC_BasicFamily  family = (FTC_BasicFamily)ftcfamily;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    FTC_BasicQuery   query  = (FTC_BasicQuery)ftcquery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    FTC_Cache        cache  = (FTC_Cache)ftccache;
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
    FTC_Family_Init( FTC_FAMILY( family ), cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    family->attrs = query->attrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    return 0;
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
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  ftc_basic_family_get_count( FTC_Family   ftcfamily,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
                              FTC_Manager  manager )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    FTC_BasicFamily  family = (FTC_BasicFamily)ftcfamily;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    FT_Face          face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    FT_UInt          result = 0;
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
    error = FTC_Manager_LookupFace( manager, family->attrs.scaler.face_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
                                    &face );
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
    if ( error || !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      return result;
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
    if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
      FT_TRACE1(( "ftc_basic_family_get_count: too large number of glyphs " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      FT_TRACE1(( "in this face, truncated\n", face->num_glyphs ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
      result = (FT_UInt)face->num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    return result;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
  ftc_basic_family_load_bitmap( FTC_Family   ftcfamily,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
                                FT_UInt      gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
                                FTC_Manager  manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
                                FT_Face     *aface )
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
    FTC_BasicFamily  family = (FTC_BasicFamily)ftcfamily;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    FT_Size          size;
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
    error = FTC_Manager_LookupSize( manager, &family->attrs.scaler, &size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    if ( !error )
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
      FT_Face  face = size->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      error = FT_Load_Glyph( face, gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
                             family->attrs.load_flags | FT_LOAD_RENDER );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
        *aface = face;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
    return error;
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
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
  ftc_basic_family_load_glyph( FTC_Family  ftcfamily,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
                               FT_UInt     gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
                               FTC_Cache   cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
                               FT_Glyph   *aglyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    FTC_BasicFamily  family = (FTC_BasicFamily)ftcfamily;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FTC_Scaler       scaler = &family->attrs.scaler;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    FT_Face          face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    FT_Size          size;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    /* we will now load the glyph image */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    error = FTC_Manager_LookupSize( cache->manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
                                    scaler,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
                                    &size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    if ( !error )
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
      face = size->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
      error = FT_Load_Glyph( face, gindex, family->attrs.load_flags );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
      if ( !error )
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
        if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
             face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
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
          /* ok, copy it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
          FT_Glyph  glyph;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
          error = FT_Get_Glyph( face->glyph, &glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
          if ( !error )
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
            *aglyph = glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
            goto Exit;
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
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
          error = FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
  FT_CALLBACK_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
  ftc_basic_gnode_compare_faceid( FTC_Node    ftcgnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
                                  FT_Pointer  ftcface_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
                                  FTC_Cache   cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
                                  FT_Bool*    list_changed )
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
    FTC_GNode        gnode   = (FTC_GNode)ftcgnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    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
   246
    FTC_BasicFamily  family  = (FTC_BasicFamily)gnode->family;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    FT_Bool          result;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    if ( list_changed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
      *list_changed = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    result = FT_BOOL( family->attrs.scaler.face_id == face_id );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    if ( result )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      /* we must call this function to avoid this node from appearing
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
       * in later lookups with the same face_id!
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
      FTC_GNode_UnselectFamily( gnode, cache );
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
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
  }
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
  * basic image cache
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
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  const FTC_IFamilyClassRec  ftc_basic_image_family_class =
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
      sizeof ( FTC_BasicFamilyRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
      ftc_basic_family_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
      ftc_basic_family_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
      0,                        /* FTC_MruNode_ResetFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
      0                         /* FTC_MruNode_DoneFunc  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
    ftc_basic_family_load_glyph
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
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
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  const FTC_GCacheClassRec  ftc_basic_image_cache_class =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
      ftc_inode_new,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
      ftc_inode_weight,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
      ftc_gnode_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
      ftc_basic_gnode_compare_faceid,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
      ftc_inode_free,
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
      sizeof ( FTC_GCacheRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
      ftc_gcache_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
      ftc_gcache_done
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
    (FTC_MruListClass)&ftc_basic_image_family_class
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
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
  /* documentation is in ftcache.h */
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
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
  FTC_ImageCache_New( FTC_Manager      manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
                      FTC_ImageCache  *acache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
    return FTC_GCache_New( manager, &ftc_basic_image_cache_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
                           (FTC_GCache*)acache );
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
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
  /* documentation is in ftcache.h */
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_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
  FTC_ImageCache_Lookup( FTC_ImageCache  cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
                         FTC_ImageType   type,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
                         FT_UInt         gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
                         FT_Glyph       *aglyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
                         FTC_Node       *anode )
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
    FTC_BasicQueryRec  query;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    FTC_Node           node = 0; /* make compiler happy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    FT_Error           error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    FT_PtrDist         hash;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    /* some argument checks are delayed to FTC_Cache_Lookup */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
    if ( !aglyph )
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
      error = FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
      goto Exit;
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
    *aglyph = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
    if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
      *anode  = 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
#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
     *  This one is a major hack used to detect whether we are passed a
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
     *  regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
    if ( (FT_ULong)type->width >= 0x10000L )
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
      FTC_OldImageDesc  desc = (FTC_OldImageDesc)type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
      query.attrs.scaler.face_id = desc->font.face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
      query.attrs.scaler.width   = desc->font.pix_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
      query.attrs.scaler.height  = desc->font.pix_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
      query.attrs.load_flags     = desc->flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
    else
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
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
      if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
        FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
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.attrs.scaler.face_id = type->face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
      query.attrs.scaler.width   = type->width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
      query.attrs.scaler.height  = type->height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
      query.attrs.load_flags     = (FT_UInt)type->flags;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    query.attrs.scaler.pixel = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
    query.attrs.scaler.x_res = 0;  /* make compilers happy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    query.attrs.scaler.y_res = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
#if 1  /* inlining is about 50% faster! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    FTC_GCACHE_LOOKUP_CMP( cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
                           ftc_basic_family_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
                           FTC_GNode_Compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
                           hash, gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
                           &query,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
                           node,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
                           error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    error = FTC_GCache_Lookup( FTC_GCACHE( cache ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
                               hash, gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
                               FTC_GQUERY( &query ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
                               &node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    if ( !error )
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
      *aglyph = FTC_INODE( node )->glyph;
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
      if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
        *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
        node->ref_count++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
  /* documentation is in ftcache.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
  FTC_ImageCache_LookupScaler( FTC_ImageCache  cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
                               FTC_Scaler      scaler,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
                               FT_ULong        load_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
                               FT_UInt         gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
                               FT_Glyph       *aglyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
                               FTC_Node       *anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
    FTC_BasicQueryRec  query;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
    FTC_Node           node = 0; /* make compiler happy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    FT_Error           error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
    FT_PtrDist         hash;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
    /* some argument checks are delayed to FTC_Cache_Lookup */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
    if ( !aglyph || !scaler )
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
      error = FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
    *aglyph = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
    if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
      *anode  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
    /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
    if ( load_flags > FT_UINT_MAX )
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
      FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
      FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    query.attrs.scaler     = scaler[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
    query.attrs.load_flags = (FT_UInt)load_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
    hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
    FTC_GCACHE_LOOKUP_CMP( cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
                           ftc_basic_family_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
                           FTC_GNode_Compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
                           hash, gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
                           &query,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
                           node,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
                           error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
      *aglyph = FTC_INODE( node )->glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
      if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
        *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
        node->ref_count++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
  
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  /* yet another backwards-legacy structure */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
  typedef struct  FTC_OldImage_Desc_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
    FTC_FontRec  font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
    FT_UInt      image_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
  } FTC_OldImage_Desc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
#define FTC_OLD_IMAGE_FORMAT( x )  ( (x) & 7 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
#define ftc_old_image_format_bitmap    0x0000
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
#define ftc_old_image_format_outline   0x0001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
#define ftc_old_image_format_mask      0x000F
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
#define ftc_old_image_flag_monochrome  0x0010
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
#define ftc_old_image_flag_unhinted    0x0020
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
#define ftc_old_image_flag_autohinted  0x0040
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
#define ftc_old_image_flag_unscaled    0x0080
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
#define ftc_old_image_flag_no_sbits    0x0100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
  /* monochrome bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
#define ftc_old_image_mono             ftc_old_image_format_bitmap   | \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
                                       ftc_old_image_flag_monochrome
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
  /* anti-aliased bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
#define ftc_old_image_grays            ftc_old_image_format_bitmap
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
  /* scaled outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
#define ftc_old_image_outline          ftc_old_image_format_outline
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
  ftc_image_type_from_old_desc( FTC_ImageType       typ,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
                                FTC_OldImage_Desc*  desc )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    typ->face_id = desc->font.face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    typ->width   = desc->font.pix_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
    typ->height  = desc->font.pix_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
    /* convert image type flags to load flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
      FT_UInt  load_flags = FT_LOAD_DEFAULT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
      FT_UInt  type       = desc->image_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
      /* determine load flags, depending on the font description's */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
      /* image type                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
      if ( FTC_OLD_IMAGE_FORMAT( type ) == ftc_old_image_format_bitmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
        if ( type & ftc_old_image_flag_monochrome )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
          load_flags |= FT_LOAD_MONOCHROME;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
        /* disable embedded bitmaps loading if necessary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
        if ( type & ftc_old_image_flag_no_sbits )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
          load_flags |= FT_LOAD_NO_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
        /* we want an outline, don't load embedded bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
        load_flags |= FT_LOAD_NO_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
        if ( type & ftc_old_image_flag_unscaled )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
          load_flags |= FT_LOAD_NO_SCALE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
      /* always render glyphs to bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
      load_flags |= FT_LOAD_RENDER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
      if ( type & ftc_old_image_flag_unhinted )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
        load_flags |= FT_LOAD_NO_HINTING;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
      if ( type & ftc_old_image_flag_autohinted )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
        load_flags |= FT_LOAD_FORCE_AUTOHINT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
      typ->flags = load_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
  FT_EXPORT( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
  FTC_Image_Cache_New( FTC_Manager      manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
                       FTC_ImageCache  *acache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
  FT_EXPORT( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
  FTC_Image_Cache_Lookup( FTC_ImageCache      icache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
                          FTC_OldImage_Desc*  desc,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
                          FT_UInt             gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
                          FT_Glyph           *aglyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
  FTC_Image_Cache_New( FTC_Manager      manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
                       FTC_ImageCache  *acache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
    return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
  FTC_Image_Cache_Lookup( FTC_ImageCache      icache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
                          FTC_OldImage_Desc*  desc,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
                          FT_UInt             gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
                          FT_Glyph           *aglyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
    FTC_ImageTypeRec  type0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
    if ( !desc )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
      return FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    ftc_image_type_from_old_desc( &type0, desc );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
    return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
                                   &type0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
                                   gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
                                   aglyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
                                   NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
 /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
  * basic small bitmap cache
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
  const FTC_SFamilyClassRec  ftc_basic_sbit_family_class =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
      sizeof( FTC_BasicFamilyRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
      ftc_basic_family_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
      ftc_basic_family_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
      0,                            /* FTC_MruNode_ResetFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
      0                             /* FTC_MruNode_DoneFunc  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
    },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
    ftc_basic_family_get_count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    ftc_basic_family_load_bitmap
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
  const FTC_GCacheClassRec  ftc_basic_sbit_cache_class =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
      ftc_snode_new,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
      ftc_snode_weight,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
      ftc_snode_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
      ftc_basic_gnode_compare_faceid,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
      ftc_snode_free,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
      sizeof ( FTC_GCacheRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
      ftc_gcache_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
      ftc_gcache_done
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
    },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
    (FTC_MruListClass)&ftc_basic_sbit_family_class
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
  /* documentation is in ftcache.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
  FTC_SBitCache_New( FTC_Manager     manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
                     FTC_SBitCache  *acache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
    return FTC_GCache_New( manager, &ftc_basic_sbit_cache_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
                           (FTC_GCache*)acache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
  /* documentation is in ftcache.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
  FTC_SBitCache_Lookup( FTC_SBitCache  cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
                        FTC_ImageType  type,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
                        FT_UInt        gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
                        FTC_SBit      *ansbit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
                        FTC_Node      *anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
    FT_Error           error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
    FTC_BasicQueryRec  query;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
    FTC_Node           node = 0; /* make compiler happy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
    FT_PtrDist         hash;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
    if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
      *anode = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
    /* other argument checks delayed to FTC_Cache_Lookup */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
    if ( !ansbit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
      return FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
    *ansbit = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
    /*  This one is a major hack used to detect whether we are passed a
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
     *  regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
    if ( (FT_ULong)type->width >= 0x10000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
      FTC_OldImageDesc  desc = (FTC_OldImageDesc)type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
      query.attrs.scaler.face_id = desc->font.face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
      query.attrs.scaler.width   = desc->font.pix_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
      query.attrs.scaler.height  = desc->font.pix_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
      query.attrs.load_flags     = desc->flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
      if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
        FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
        FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
      query.attrs.scaler.face_id = type->face_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      query.attrs.scaler.width   = type->width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
      query.attrs.scaler.height  = type->height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
      query.attrs.load_flags     = (FT_UInt)type->flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
    query.attrs.scaler.pixel = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
    query.attrs.scaler.x_res = 0;  /* make compilers happy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
    query.attrs.scaler.y_res = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
    /* beware, the hash must be the same for all glyph ranges! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
    hash = FTC_BASIC_ATTR_HASH( &query.attrs ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
           gindex / FTC_SBIT_ITEMS_PER_NODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
#if 1  /* inlining is about 50% faster! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
    FTC_GCACHE_LOOKUP_CMP( cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
                           ftc_basic_family_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
                           FTC_SNode_Compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
                           hash, gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
                           &query,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
                           node,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
                           error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
    error = FTC_GCache_Lookup( FTC_GCACHE( cache ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
                               hash,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
                               gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
                               FTC_GQUERY( &query ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
                               &node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    *ansbit = FTC_SNODE( node )->sbits +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
              ( gindex - FTC_GNODE( node )->gindex );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
    if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
      *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
      node->ref_count++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
  /* documentation is in ftcache.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
  FTC_SBitCache_LookupScaler( FTC_SBitCache  cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
                              FTC_Scaler     scaler,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
                              FT_ULong       load_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
                              FT_UInt        gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
                              FTC_SBit      *ansbit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
                              FTC_Node      *anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
    FT_Error           error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
    FTC_BasicQueryRec  query;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
    FTC_Node           node = 0; /* make compiler happy */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
    FT_PtrDist         hash;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
    if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
        *anode = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
    /* other argument checks delayed to FTC_Cache_Lookup */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
    if ( !ansbit || !scaler )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
        return FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
    *ansbit = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
    /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
    if ( load_flags > FT_UINT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
      FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
      FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
    query.attrs.scaler     = scaler[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
    query.attrs.load_flags = (FT_UInt)load_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
    /* beware, the hash must be the same for all glyph ranges! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
    hash = FTC_BASIC_ATTR_HASH( &query.attrs ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
             gindex / FTC_SBIT_ITEMS_PER_NODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
    FTC_GCACHE_LOOKUP_CMP( cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
                           ftc_basic_family_compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
                           FTC_SNode_Compare,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
                           hash, gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
                           &query,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
                           node,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
                           error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
    *ansbit = FTC_SNODE( node )->sbits +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
              ( gindex - FTC_GNODE( node )->gindex );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
    if ( anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
      *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
      node->ref_count++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
  FT_EXPORT( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
  FTC_SBit_Cache_New( FTC_Manager     manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
                      FTC_SBitCache  *acache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
  FT_EXPORT( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
  FTC_SBit_Cache_Lookup( FTC_SBitCache       cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
                         FTC_OldImage_Desc*  desc,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
                         FT_UInt             gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
                         FTC_SBit           *ansbit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
  FTC_SBit_Cache_New( FTC_Manager     manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
                      FTC_SBitCache  *acache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
    return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
  FTC_SBit_Cache_Lookup( FTC_SBitCache       cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
                         FTC_OldImage_Desc*  desc,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
                         FT_UInt             gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
                         FTC_SBit           *ansbit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
    FTC_ImageTypeRec  type0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
    if ( !desc )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
      return FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
    ftc_image_type_from_old_desc( &type0, desc );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
    return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
                                  &type0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
                                  gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
                                  ansbit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
                                  NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
/* END */