misc/libfreetype/src/truetype/ttpload.c
author nemo
Sun, 25 Sep 2011 15:40:01 -0400
changeset 6028 335eaf56d976
parent 5172 88f2e05288ba
permissions -rw-r--r--
rename to match prior mass hat rename
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
/*  ttpload.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
/*    TrueType-specific tables loader (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 1996-2002, 2004-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_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include "ttpload.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
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "ttgxvar.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include "tterrors.h"
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
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
#define FT_COMPONENT  trace_ttpload
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /*    tt_face_load_loca                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  /*    Load the locations table.                                          */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  /*    face   :: A handle to the target face object.                      */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  /*    stream :: The input stream.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
  tt_face_load_loca( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
                     FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    FT_ULong  table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    FT_Int    shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    /* we need the size of the `glyf' table for malformed `loca' tables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
    error = face->goto_table( face, TTAG_glyf, stream, &face->glyf_len );
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
    /* it is possible that a font doesn't have a glyf table at all */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
    /* or its size is zero                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    if ( error == TT_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
      face->glyf_len = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    else if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
      goto Exit;
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
    FT_TRACE2(( "Locations " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    error = face->goto_table( face, TTAG_loca, stream, &table_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      error = TT_Err_Locations_Missing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
      goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    if ( face->header.Index_To_Loc_Format != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
      shift = 2;
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
      if ( table_len >= 0x40000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
        FT_TRACE2(( "table too large\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
        error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
        goto Exit;
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
      face->num_locations = table_len >> shift;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      shift = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
      if ( table_len >= 0x20000L )
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_TRACE2(( "table too large\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
        error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
        goto Exit;
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
      face->num_locations = table_len >> shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
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
      FT_TRACE2(( "glyph count mismatch!  loca: %d, maxp: %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
                  face->num_locations - 1, face->root.num_glyphs ));
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
      /* we only handle the case where `maxp' gives a larger value */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
      if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
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
        FT_Long   new_loca_len =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
                    ( (FT_Long)( face->root.num_glyphs ) + 1 ) << shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
        TT_Table  entry = face->dir_tables;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
        TT_Table  limit = entry + face->num_tables;
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
        FT_Long   pos  = FT_Stream_Pos( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
        FT_Long   dist = 0x7FFFFFFFL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
        /* compute the distance to next table in font file */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
        for ( ; entry < limit; entry++ )
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_Long  diff = entry->Offset - pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
          if ( diff > 0 && diff < dist )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
            dist = diff;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
        if ( entry == limit )
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
          /* `loca' is the last table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
          dist = stream->size - pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
        if ( new_loca_len <= dist )
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
          face->num_locations = face->root.num_glyphs + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
          table_len           = new_loca_len;
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_TRACE2(( "adjusting num_locations to %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
                      face->num_locations ));
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
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
     * Extract the frame.  We don't need to decompress it since
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
     * we are able to parse it directly.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    if ( FT_FRAME_EXTRACT( table_len, face->glyph_locations ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    FT_TRACE2(( "loaded\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
  FT_LOCAL_DEF( FT_ULong )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
  tt_face_get_location( TT_Face   face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
                        FT_UInt   gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
                        FT_UInt  *asize )
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_ULong  pos1, pos2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    FT_Byte*  p_limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    pos1 = pos2 = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    if ( gindex < face->num_locations )
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
      if ( face->header.Index_To_Loc_Format != 0 )
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
        p       = face->glyph_locations + gindex * 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
        p_limit = face->glyph_locations + face->num_locations * 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
        pos1 = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
        pos2 = pos1;
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
        if ( p + 4 <= p_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
          pos2 = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
        p       = face->glyph_locations + gindex * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
        p_limit = face->glyph_locations + face->num_locations * 2;
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
        pos1 = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
        pos2 = pos1;
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
        if ( p + 2 <= p_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
          pos2 = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
        pos1 <<= 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
        pos2 <<= 1;
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    /* Check broken location data */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    if ( pos1 >= face->glyf_len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
      FT_TRACE1(( "tt_face_get_location:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
                 " too large offset=0x%08lx found for gid=0x%04lx,"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
                 " exceeding the end of glyf table (0x%08lx)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
                 pos1, gindex, face->glyf_len ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
      *asize = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    if ( pos2 >= face->glyf_len )
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
      FT_TRACE1(( "tt_face_get_location:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
                 " too large offset=0x%08lx found for gid=0x%04lx,"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
                 " truncate at the end of glyf table (0x%08lx)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
                 pos2, gindex + 1, face->glyf_len ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      pos2 = face->glyf_len;
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
    /* The `loca' table must be ordered; it refers to the length of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    /* an entry as the difference between the current and the next  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    /* position.  However, there do exist (malformed) fonts which   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
    /* don't obey this rule, so we are only able to provide an      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
    /* upper bound for the size.                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    /*                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    /* We get (intentionally) a wrong, non-zero result in case the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
    /* `glyf' table is missing.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    if ( pos2 >= pos1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
      *asize = (FT_UInt)( pos2 - pos1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
      *asize = (FT_UInt)( face->glyf_len - pos1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    return pos1;
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
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
  tt_face_done_loca( TT_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    FT_Stream  stream = face->root.stream;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    FT_FRAME_RELEASE( face->glyph_locations );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    face->num_locations = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
  /*    tt_face_load_cvt                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
  /*    Load the control value table into a face object.                   */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  /*    face   :: A handle to the target face object.                      */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  /*    stream :: A handle to the input stream.                            */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
  tt_face_load_cvt( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
                    FT_Stream  stream )
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
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    FT_Memory  memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    FT_ULong   table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
    FT_TRACE2(( "CVT " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    error = face->goto_table( face, TTAG_cvt, stream, &table_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
      FT_TRACE2(( "is missing\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      face->cvt_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      face->cvt      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
      error          = TT_Err_Ok;
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
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
    face->cvt_size = table_len / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    if ( FT_NEW_ARRAY( face->cvt, face->cvt_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
      goto Exit;
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
    if ( FT_FRAME_ENTER( face->cvt_size * 2L ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
      goto Exit;
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
      FT_Short*  cur   = face->cvt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
      FT_Short*  limit = cur + face->cvt_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
      for ( ; cur < limit; cur++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
        *cur = FT_GET_SHORT();
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
    FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    FT_TRACE2(( "loaded\n" ));
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
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    if ( face->doblend )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
      error = tt_face_vary_cvt( face, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
#else /* !TT_USE_BYTECODE_INTERPRETER */
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
    FT_UNUSED( face   );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    FT_UNUSED( stream );
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
    return TT_Err_Ok;
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
#endif
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
  /*    tt_face_load_fpgm                                                  */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
  /*    Load the font program.                                             */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
  /*    face   :: A handle to the target face object.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
  /*    stream :: A handle to the input stream.                            */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
  /*    FreeType error code.  0 means success.                             */
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
  tt_face_load_fpgm( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
                     FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
#ifdef TT_USE_BYTECODE_INTERPRETER
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
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    FT_ULong  table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
    FT_TRACE2(( "Font program " ));
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
    /* The font program is optional */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
    error = face->goto_table( face, TTAG_fpgm, stream, &table_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    if ( error )
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
      face->font_program      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
      face->font_program_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
      error                   = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
      FT_TRACE2(( "is missing\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    else
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
      face->font_program_size = table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
      if ( FT_FRAME_EXTRACT( table_len, face->font_program ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
        goto Exit;
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
      FT_TRACE2(( "loaded, %12d bytes\n", face->font_program_size ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    return 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
#else /* !TT_USE_BYTECODE_INTERPRETER */
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
    FT_UNUSED( face   );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    return TT_Err_Ok;
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
#endif
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
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
  /*    tt_face_load_prep                                                  */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
  /*    Load the cvt program.                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
  /*    face   :: A handle to the target face object.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
  /*    stream :: A handle to the input stream.                            */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
  tt_face_load_prep( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
                     FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
#ifdef TT_USE_BYTECODE_INTERPRETER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    FT_ULong  table_len;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
    FT_TRACE2(( "Prep program " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    error = face->goto_table( face, TTAG_prep, stream, &table_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
      face->cvt_program      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
      face->cvt_program_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
      error                  = TT_Err_Ok;
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
      FT_TRACE2(( "is missing\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
    else
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
      face->cvt_program_size = table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
      if ( FT_FRAME_EXTRACT( table_len, face->cvt_program ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
      FT_TRACE2(( "loaded, %12d bytes\n", face->cvt_program_size ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
#else /* !TT_USE_BYTECODE_INTERPRETER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
    FT_UNUSED( face   );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
    FT_UNUSED( stream );
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
    return TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
#endif
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
  /*    tt_face_load_hdmx                                                  */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
  /*    Load the `hdmx' table into the face object.                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
  /*    face   :: A handle to the target face object.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
  /*    stream :: A handle to the input stream.                            */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
  /*    FreeType error code.  0 means success.                             */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
  tt_face_load_hdmx( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
                     FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
    FT_Memory  memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
    FT_UInt    version, nn, num_records;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    FT_ULong   table_size, record_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    FT_Byte*   p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
    FT_Byte*   limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
    /* this table is optional */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
    error = face->goto_table( face, TTAG_hdmx, stream, &table_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
    if ( error || table_size < 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
      return TT_Err_Ok;
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
    if ( FT_FRAME_EXTRACT( table_size, face->hdmx_table ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
      goto Exit;
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
    p     = face->hdmx_table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    limit = p + table_size;
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
    version     = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
    num_records = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
    record_size = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    /* The maximum number of bytes in an hdmx device record is the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    /* maximum number of glyphs + 2; this is 0xFFFF + 2; this is   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    /* the reason why `record_size' is a long (which we read as    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
    /* unsigned long for convenience).  In practice, two bytes     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
    /* sufficient to hold the size value.                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
    /*                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
    /* There are at least two fonts, HANNOM-A and HANNOM-B version */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
    /* 2.0 (2005), which get this wrong: The upper two bytes of    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    /* the size value are set to 0xFF instead of 0x00.  We catch   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
    /* and fix this.                                               */
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
    if ( record_size >= 0xFFFF0000UL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
      record_size &= 0xFFFFU;
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
    /* The limit for `num_records' is a heuristic value. */
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 ( version != 0 || num_records > 255 || record_size > 0x10001L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
      error = TT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
    if ( FT_NEW_ARRAY( face->hdmx_record_sizes, num_records ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
      goto Fail;
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
    for ( nn = 0; nn < num_records; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
      if ( p + record_size > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
      face->hdmx_record_sizes[nn] = p[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
      p                          += record_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
    face->hdmx_record_count = nn;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    face->hdmx_table_size   = table_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
    face->hdmx_record_size  = record_size;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    return error;
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
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    FT_FRAME_RELEASE( face->hdmx_table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
    face->hdmx_table_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
    goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
  tt_face_free_hdmx( TT_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
    FT_Stream  stream = face->root.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    FT_Memory  memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    FT_FREE( face->hdmx_record_sizes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    FT_FRAME_RELEASE( face->hdmx_table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
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
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
  /* Return the advance width table for a given pixel size if it is found  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
  /* in the font's `hdmx' table (if any).                                  */
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
  FT_LOCAL_DEF( FT_Byte* )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
  tt_face_get_device_metrics( TT_Face  face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
                              FT_UInt  ppem,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
                              FT_UInt  gindex )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    FT_UInt   nn;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    FT_Byte*  result      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
    FT_ULong  record_size = face->hdmx_record_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
    FT_Byte*  record      = face->hdmx_table + 8;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    for ( nn = 0; nn < face->hdmx_record_count; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
      if ( face->hdmx_record_sizes[nn] == ppem )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
        gindex += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
        if ( gindex < record_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
          result = record + nn * record_size + gindex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    return result;
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
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
/* END */