misc/libfreetype/src/cache/ftcsbits.c
author koda
Tue, 26 Mar 2013 01:13:45 +0100
branchcmake_pascal
changeset 8846 c156ac6ddc2b
parent 5172 88f2e05288ba
permissions -rw-r--r--
set directories to be included externally, in the project file
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
/*  ftcsbits.c                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    FreeType sbits manager (body).                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 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_CACHE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "ftcsbits.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_ERRORS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include "ftccback.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "ftcerror.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#undef  FT_COMPONENT
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
  /*************************************************************************/
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
  /*****                     SBIT CACHE NODES                          *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  ftc_sbit_copy_bitmap( FTC_SBit    sbit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
                        FT_Bitmap*  bitmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
                        FT_Memory   memory )
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
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    FT_Int    pitch = bitmap->pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
    FT_ULong  size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    if ( pitch < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
      pitch = -pitch;
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
    size = (FT_ULong)( pitch * bitmap->rows );
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
    if ( !FT_ALLOC( sbit->buffer, size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
  ftc_snode_free( FTC_Node   ftcsnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
                  FTC_Cache  cache )
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
    FTC_SNode  snode  = (FTC_SNode)ftcsnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    FTC_SBit   sbit   = snode->sbits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    FT_UInt    count  = snode->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
    FT_Memory  memory = cache->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
    for ( ; count > 0; sbit++, count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      FT_FREE( sbit->buffer );
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_GNode_Done( FTC_GNODE( snode ), cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    FT_FREE( snode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  FTC_SNode_Free( FTC_SNode  snode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
                  FTC_Cache  cache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    ftc_snode_free( FTC_NODE( snode ), cache );
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
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
   *  This function tries to load a small bitmap within a given FTC_SNode.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
   *  Note that it returns a non-zero error code _only_ in the case of
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
   *  out-of-memory condition.  For all other errors (e.g., corresponding
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
   *  to a bad font file), this function will mark the sbit as `unavailable'
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
   *  and return a value of 0.
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
   *  You should also read the comment within the @ftc_snode_compare
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
   *  function below to see how out-of-memory is handled during a lookup.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
  ftc_snode_load( FTC_SNode    snode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
                  FTC_Manager  manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
                  FT_UInt      gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
                  FT_ULong    *asize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    FT_Error          error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    FTC_GNode         gnode  = FTC_GNODE( snode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    FTC_Family        family = gnode->family;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    FT_Memory         memory = manager->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FT_Face           face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    FTC_SBit          sbit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    FTC_SFamilyClass  clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
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
    if ( (FT_UInt)(gindex - gnode->gindex) >= snode->count )
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_ERROR(( "ftc_snode_load: invalid glyph index" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
      return FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    sbit  = snode->sbits + ( gindex - gnode->gindex );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    clazz = (FTC_SFamilyClass)family->clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    sbit->buffer = 0;
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
    error = clazz->family_load_glyph( family, gindex, manager, &face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
      goto BadGlyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
      FT_Int        temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
      FT_GlyphSlot  slot   = face->glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
      FT_Bitmap*    bitmap = &slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
      FT_Pos        xadvance, yadvance; /* FT_GlyphSlot->advance.{x|y} */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
        FT_TRACE0(( "ftc_snode_load:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
                    " glyph loaded didn't return a bitmap\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
        goto BadGlyph;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
      /* Check that our values fit into 8-bit containers!       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      /* If this is not the case, our bitmap is too large       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      /* and we will leave it as `missing' with sbit.buffer = 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
#define CHECK_CHAR( d )  ( temp = (FT_Char)d, temp == d )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
#define CHECK_BYTE( d )  ( temp = (FT_Byte)d, temp == d )
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
      /* horizontal advance in pixels */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      xadvance = ( slot->advance.x + 32 ) >> 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
      yadvance = ( slot->advance.y + 32 ) >> 6;
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 ( !CHECK_BYTE( bitmap->rows  )     ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
           !CHECK_BYTE( bitmap->width )     ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
           !CHECK_CHAR( bitmap->pitch )     ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
           !CHECK_CHAR( slot->bitmap_left ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
           !CHECK_CHAR( slot->bitmap_top  ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
           !CHECK_CHAR( xadvance )          ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
           !CHECK_CHAR( yadvance )          )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
        FT_TRACE2(( "ftc_snode_load:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
                    " glyph too large for small bitmap cache\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
        goto BadGlyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      sbit->width     = (FT_Byte)bitmap->width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
      sbit->height    = (FT_Byte)bitmap->rows;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
      sbit->pitch     = (FT_Char)bitmap->pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
      sbit->left      = (FT_Char)slot->bitmap_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      sbit->top       = (FT_Char)slot->bitmap_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
      sbit->xadvance  = (FT_Char)xadvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
      sbit->yadvance  = (FT_Char)yadvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      sbit->format    = (FT_Byte)bitmap->pixel_mode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      sbit->max_grays = (FT_Byte)(bitmap->num_grays - 1);
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
      /* copy the bitmap into a new buffer -- ignore error */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      error = ftc_sbit_copy_bitmap( sbit, bitmap, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
      /* now, compute size */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      if ( asize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
        *asize = FT_ABS( sbit->pitch ) * sbit->height;
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
    } /* glyph loading successful */
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
    /* ignore the errors that might have occurred --   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    /* we mark unloaded glyphs with `sbit.buffer == 0' */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    /* and `width == 255', `height == 0'               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    /*                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    if ( error && error != FTC_Err_Out_Of_Memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    BadGlyph:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
      sbit->width  = 255;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      sbit->height = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      sbit->buffer = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
      error        = FTC_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
      if ( asize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
        *asize = 0;
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
  FTC_SNode_New( FTC_SNode  *psnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
                 FTC_GQuery  gquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
                 FTC_Cache   cache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    FT_Memory   memory = cache->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    FT_Error    error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    FTC_SNode   snode  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    FT_UInt     gindex = gquery->gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    FTC_Family  family = gquery->family;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    FTC_SFamilyClass  clazz = FTC_CACHE__SFAMILY_CLASS( cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    FT_UInt           total;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    FT_UInt           node_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    total = clazz->family_get_count( family, cache->manager );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    if ( total == 0 || gindex >= total )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
      error = FTC_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    if ( !FT_NEW( snode ) )
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
      FT_UInt  count, start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
      start = gindex - ( gindex % FTC_SBIT_ITEMS_PER_NODE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
      count = total - start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
      if ( count > FTC_SBIT_ITEMS_PER_NODE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
        count = FTC_SBIT_ITEMS_PER_NODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
      FTC_GNode_Init( FTC_GNODE( snode ), start, family );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
      snode->count = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
      for ( node_count = 0; node_count < count; node_count++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
        snode->sbits[node_count].width = 255;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
      error = ftc_snode_load( snode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
                              cache->manager,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
                              gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
                              NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
        FTC_SNode_Free( snode, cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
        snode = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    *psnode = snode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    return error;
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
  ftc_snode_new( FTC_Node   *ftcpsnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
                 FT_Pointer  ftcgquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
                 FTC_Cache   cache )
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
    FTC_SNode  *psnode = (FTC_SNode*)ftcpsnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
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
    return FTC_SNode_New( psnode, gquery, cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
  FT_LOCAL_DEF( FT_Offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
  ftc_snode_weight( FTC_Node   ftcsnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
                    FTC_Cache  cache )
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
    FTC_SNode  snode = (FTC_SNode)ftcsnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    FT_UInt    count = snode->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    FTC_SBit   sbit  = snode->sbits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    FT_Int     pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    FT_Offset  size;
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
    FT_UNUSED( cache );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    FT_ASSERT( snode->count <= FTC_SBIT_ITEMS_PER_NODE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    /* the node itself */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    size = sizeof ( *snode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    for ( ; count > 0; count--, sbit++ )
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
      if ( sbit->buffer )
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
        pitch = sbit->pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
        if ( pitch < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
          pitch = -pitch;
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
        /* add the size of a given glyph image */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
        size += pitch * sbit->height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    return size;
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
#if 0
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_LOCAL_DEF( FT_Offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
  FTC_SNode_Weight( FTC_SNode  snode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    return ftc_snode_weight( FTC_NODE( snode ), NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
  FT_LOCAL_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
  ftc_snode_compare( FTC_Node    ftcsnode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
                     FT_Pointer  ftcgquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
                     FTC_Cache   cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
                     FT_Bool*    list_changed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    FTC_SNode   snode  = (FTC_SNode)ftcsnode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
    FTC_GNode   gnode  = FTC_GNODE( snode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
    FT_UInt     gindex = gquery->gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    FT_Bool     result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    if (list_changed)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
      *list_changed = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    result = FT_BOOL( gnode->family == gquery->family                    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
                      (FT_UInt)( gindex - gnode->gindex ) < snode->count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    if ( result )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
      /* check if we need to load the glyph bitmap now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
      FTC_SBit  sbit = snode->sbits + ( gindex - gnode->gindex );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
      /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
       *  The following code illustrates what to do when you want to
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
       *  perform operations that may fail within a lookup function.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
       *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
       *  Here, we want to load a small bitmap on-demand; we thus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
       *  need to call the `ftc_snode_load' function which may return
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
       *  a non-zero error code only when we are out of memory (OOM).
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
       *  The correct thing to do is to use @FTC_CACHE_TRYLOOP and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
       *  @FTC_CACHE_TRYLOOP_END in order to implement a retry loop
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
       *  that is capable of flushing the cache incrementally when
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
       *  an OOM errors occur.
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
       *  However, we need to `lock' the node before this operation to
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
       *  prevent it from being flushed within the loop.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
       *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
       *  When we exit the loop, we unlock the node, then check the `error'
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
       *  variable.  If it is non-zero, this means that the cache was
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
       *  completely flushed and that no usable memory was found to load
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
       *  the bitmap.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
       *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
       *  We then prefer to return a value of 0 (i.e., NO MATCH).  This
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
       *  ensures that the caller will try to allocate a new node.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
       *  This operation consequently _fail_ and the lookup function
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
       *  returns the appropriate OOM error code.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
       *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
       *  Note that `buffer == NULL && width == 255' is a hack used to
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
       *  tag `unavailable' bitmaps in the array.  We should never try
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
       *  to load these.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
       *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
      if ( sbit->buffer == NULL && sbit->width == 255 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        FT_ULong  size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
        FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
        ftcsnode->ref_count++;  /* lock node to prevent flushing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
                                /* in retry loop                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
        FTC_CACHE_TRYLOOP( cache )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
          error = ftc_snode_load( snode, cache->manager, gindex, &size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
        FTC_CACHE_TRYLOOP_END( list_changed );
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
        ftcsnode->ref_count--;  /* unlock the node */
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 ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
          result = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
          cache->manager->cur_weight += size;
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
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
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
#ifdef FTC_INLINE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
  FT_LOCAL_DEF( FT_Bool )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
  FTC_SNode_Compare( FTC_SNode   snode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
                     FTC_GQuery  gquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
                     FTC_Cache   cache,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
                     FT_Bool*    list_changed )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    return ftc_snode_compare( FTC_NODE( snode ), gquery,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
                              cache, list_changed );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
/* END */