misc/libfreetype/src/sfnt/ttbdf.c
author unc0rr
Sun, 27 Nov 2011 23:13:22 +0300
changeset 6453 11c578d30bd3
parent 5172 88f2e05288ba
permissions -rw-r--r--
Countless imporvements to the parser and countless help to the parser in sources. Now parser is able to parse the whole engine \o/
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
/*  ttbdf.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 and OpenType embedded BDF properties (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 2005, 2006, 2010 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_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "ttbdf.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 "sferrors.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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#ifdef TT_CONFIG_OPTION_BDF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /*************************************************************************/
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
  /* 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
    33
  /* 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
    34
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#define FT_COMPONENT  trace_ttbdf
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  tt_face_free_bdf_props( TT_Face  face )
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
    TT_BDF  bdf = &face->bdf;
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
    if ( bdf->loaded )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
      FT_Stream  stream = FT_FACE(face)->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
      if ( bdf->table != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
        FT_FRAME_RELEASE( bdf->table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
      bdf->table_end    = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      bdf->strings      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
      bdf->strings_size = 0;
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
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
  tt_face_load_bdf_props( 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
    TT_BDF    bdf = &face->bdf;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    FT_ULong  length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    FT_Error  error;
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
    FT_ZERO( bdf );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    error = tt_face_goto_table( face, TTAG_BDF, stream, &length );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    if ( error                                  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
         length < 8                             ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
         FT_FRAME_EXTRACT( length, bdf->table ) )
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
      error = SFNT_Err_Invalid_Table;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    bdf->table_end = bdf->table + length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      FT_Byte*   p           = bdf->table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
      FT_UInt    version     = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
      FT_UInt    num_strikes = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
      FT_ULong   strings     = FT_NEXT_ULONG ( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
      FT_UInt    count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
      FT_Byte*   strike;
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
      if ( version != 0x0001                 ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
           strings < 8                       ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
           ( strings - 8 ) / 4 < num_strikes ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
           strings + 1 > length              )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
        goto BadTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      }
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
      bdf->num_strikes  = num_strikes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
      bdf->strings      = bdf->table + strings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      bdf->strings_size = length - strings;
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
      count  = bdf->num_strikes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
      p      = bdf->table + 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
      strike = p + count * 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      for ( ; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
        FT_UInt  num_items = FT_PEEK_USHORT( p + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
        /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
         *  We don't need to check the value sets themselves, since this
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
         *  is done later.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
        strike += 10 * num_items;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
        p += 4;
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
      if ( strike > bdf->strings )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
        goto BadTable;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    bdf->loaded = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    return error;
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
  BadTable:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    FT_FRAME_RELEASE( bdf->table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    FT_ZERO( bdf );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    error = SFNT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
  tt_face_find_bdf_prop( TT_Face           face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
                         const char*       property_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
                         BDF_PropertyRec  *aprop )
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
    TT_BDF     bdf   = &face->bdf;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    FT_Size    size  = FT_FACE(face)->size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    FT_Error   error = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_Byte*   p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    FT_UInt    count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    FT_Byte*   strike;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    FT_Offset  property_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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    aprop->type = BDF_PROPERTY_TYPE_NONE;
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
    if ( bdf->loaded == 0 )
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
      error = tt_face_load_bdf_props( face, FT_FACE( face )->stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    count  = bdf->num_strikes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    p      = bdf->table + 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    strike = p + 4 * count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    error = SFNT_Err_Invalid_Argument;
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
    if ( size == NULL || property_name == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      goto Exit;
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
    property_len = ft_strlen( property_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    if ( property_len == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    for ( ; count > 0; count-- )
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_UInt  _ppem  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
      FT_UInt  _count = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      if ( _ppem == size->metrics.y_ppem )
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
        count = _count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
        goto FoundStrike;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      strike += 10 * _count;
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
    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  FoundStrike:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    p = strike;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    for ( ; count > 0; count-- )
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
      FT_UInt  type = FT_PEEK_USHORT( p + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      if ( ( type & 0x10 ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
        FT_UInt32  name_offset = FT_PEEK_ULONG( p     );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
        FT_UInt32  value       = FT_PEEK_ULONG( p + 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
        /* be a bit paranoid for invalid entries here */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
        if ( name_offset < bdf->strings_size                    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
             property_len < bdf->strings_size - name_offset     &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
             ft_strncmp( property_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
                         (const char*)bdf->strings + name_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
                         bdf->strings_size - name_offset ) == 0 )
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
          switch ( type & 0x0F )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
          case 0x00:  /* string */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
          case 0x01:  /* atoms */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
            /* check that the content is really 0-terminated */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
            if ( value < bdf->strings_size &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
                 ft_memchr( bdf->strings + value, 0, bdf->strings_size ) )
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
              aprop->type   = BDF_PROPERTY_TYPE_ATOM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
              aprop->u.atom = (const char*)bdf->strings + value;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
              error         = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
              goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
            break;
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
          case 0x02:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
            aprop->type      = BDF_PROPERTY_TYPE_INTEGER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
            aprop->u.integer = (FT_Int32)value;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
            error            = SFNT_Err_Ok;
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
          case 0x03:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
            aprop->type       = BDF_PROPERTY_TYPE_CARDINAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
            aprop->u.cardinal = value;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
            error             = SFNT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
          default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
            ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
        }
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
      p += 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
#endif /* TT_CONFIG_OPTION_BDF */
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
/* END */