misc/libfreetype/src/bdf/bdfdrivr.c
author nemo
Sun, 26 Jun 2011 20:19:11 -0400
changeset 5330 0f31c8ab064b
parent 5172 88f2e05288ba
permissions -rw-r--r--
disable .reserve - not 4.6 compatible
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
/*  bdfdrivr.c
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
    FreeType font driver for bdf files
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
    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
    Francesco Zappa Nardelli
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
Permission is hereby granted, free of charge, to any person obtaining a copy
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
of this software and associated documentation files (the "Software"), to deal
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
in the Software without restriction, including without limitation the rights
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
copies of the Software, and to permit persons to whom the Software is
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
furnished to do so, subject to the following conditions:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
The above copyright notice and this permission notice shall be included in
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
all copies or substantial portions of the Software.
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
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
THE SOFTWARE.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
*/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#include FT_BDF_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
#include FT_TRUETYPE_IDS_H 
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
#include FT_SERVICE_BDF_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
#include FT_SERVICE_XFREE86_NAME_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
#include "bdf.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
#include "bdfdrivr.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
#include "bdferror.h"
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
  /* 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
    47
  /* 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
    48
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
#define FT_COMPONENT  trace_bdfdriver
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  typedef struct  BDF_CMapRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    FT_CMapRec        cmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    FT_ULong          num_encodings; /* ftobjs.h: FT_CMap->clazz->size */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    BDF_encoding_el*  encodings;
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
  } BDF_CMapRec, *BDF_CMap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
  bdf_cmap_init( FT_CMap     bdfcmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
                 FT_Pointer  init_data )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    BDF_CMap  cmap = (BDF_CMap)bdfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    BDF_Face  face = (BDF_Face)FT_CMAP_FACE( cmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    FT_UNUSED( init_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    cmap->num_encodings = face->bdffont->glyphs_used;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    cmap->encodings     = face->en_table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    return BDF_Err_Ok;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  bdf_cmap_done( FT_CMap  bdfcmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    BDF_CMap  cmap = (BDF_CMap)bdfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    cmap->encodings     = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    cmap->num_encodings = 0;
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
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
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  bdf_cmap_char_index( FT_CMap    bdfcmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
                       FT_UInt32  charcode )
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
    BDF_CMap          cmap      = (BDF_CMap)bdfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    BDF_encoding_el*  encodings = cmap->encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    FT_ULong          min, max, mid; /* num_encodings */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    FT_UShort         result    = 0; /* encodings->glyph */
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
    min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    max = cmap->num_encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    while ( min < max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
      FT_ULong  code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
      mid  = ( min + max ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      code = encodings[mid].enc;
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
      if ( charcode == code )
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
        /* increase glyph index by 1 --              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
        /* we reserve slot 0 for the undefined glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
        result = encodings[mid].glyph + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
        break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
      if ( charcode < code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
        max = mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
        min = mid + 1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  bdf_cmap_char_next( FT_CMap     bdfcmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
                      FT_UInt32  *acharcode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    BDF_CMap          cmap      = (BDF_CMap)bdfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    BDF_encoding_el*  encodings = cmap->encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    FT_ULong          min, max, mid; /* num_encodings */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    FT_UShort         result   = 0;  /* encodings->glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    FT_ULong          charcode = *acharcode + 1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    max = cmap->num_encodings;
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
    while ( min < max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
      FT_ULong  code; /* same as BDF_encoding_el.enc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      mid  = ( min + max ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      code = encodings[mid].enc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      if ( charcode == code )
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
        /* increase glyph index by 1 --              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
        /* we reserve slot 0 for the undefined glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
        result = encodings[mid].glyph + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
        goto Exit;
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
      if ( charcode < code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
        max = mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
        min = mid + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    charcode = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    if ( min < cmap->num_encodings )
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
      charcode = encodings[min].enc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      result   = encodings[min].glyph + 1;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    if ( charcode > 0xFFFFFFFFUL )
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
      FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%x > 32bit API" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      *acharcode = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      /* XXX: result should be changed to indicate an overflow error */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      *acharcode = (FT_UInt32)charcode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
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
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  const FT_CMap_ClassRec  bdf_cmap_class =
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
    sizeof ( BDF_CMapRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    bdf_cmap_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    bdf_cmap_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    bdf_cmap_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    bdf_cmap_char_next,
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
    NULL, NULL, NULL, NULL, NULL
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
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
  bdf_interpret_style( BDF_Face  bdf )
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
    FT_Error         error  = BDF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    FT_Face          face   = FT_FACE( bdf );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    FT_Memory        memory = face->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    bdf_font_t*      font   = bdf->bdffont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    bdf_property_t*  prop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    char*   strings[4] = { NULL, NULL, NULL, NULL };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    size_t  nn, len, lengths[4];
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    face->style_flags = 0;
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
    prop = bdf_get_font_property( font, (char *)"SLANT" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    if ( prop && prop->format == BDF_ATOM                             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
         prop->value.atom                                             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
         ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
           *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
      face->style_flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
      strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
                   ? (char *)"Oblique"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
                   : (char *)"Italic";
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    if ( prop && prop->format == BDF_ATOM                             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
         prop->value.atom                                             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
         ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      face->style_flags |= FT_STYLE_FLAG_BOLD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
      strings[1] = (char *)"Bold";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    prop = bdf_get_font_property( font, (char *)"SETWIDTH_NAME" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    if ( prop && prop->format == BDF_ATOM                              &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
         prop->value.atom && *(prop->value.atom)                       &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
      strings[3] = (char *)(prop->value.atom);
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
    prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    if ( prop && prop->format == BDF_ATOM                              &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
         prop->value.atom && *(prop->value.atom)                       &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
      strings[0] = (char *)(prop->value.atom);
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
    len = 0;
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
    for ( len = 0, nn = 0; nn < 4; nn++ )
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
      lengths[nn] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
      if ( strings[nn] )
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
        lengths[nn] = ft_strlen( strings[nn] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
        len        += lengths[nn] + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    if ( len == 0 )
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
      strings[0] = (char *)"Regular";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      lengths[0] = ft_strlen( strings[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
      len        = lengths[0] + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      char*  s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
      if ( FT_ALLOC( face->style_name, len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
      s = face->style_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
      for ( nn = 0; nn < 4; nn++ )
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
        char*  src = strings[nn];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
        len = lengths[nn];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
        if ( src == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
        /* separate elements with a space */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
        if ( s != face->style_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
          *s++ = ' ';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
        ft_memcpy( s, src, len );
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
        /* need to convert spaces to dashes for */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
        /* add_style_name and setwidth_name     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
        if ( nn == 0 || nn == 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
          size_t  mm;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
          for ( mm = 0; mm < len; mm++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
            if ( s[mm] == ' ' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
              s[mm] = '-';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
        s += len;
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
      *s = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
  BDF_Face_Done( FT_Face  bdfface )         /* BDF_Face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    BDF_Face   face = (BDF_Face)bdfface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    FT_Memory  memory;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      return;
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
    memory = FT_FACE_MEMORY( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    bdf_free_font( face->bdffont );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    FT_FREE( face->en_table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    FT_FREE( face->charset_encoding );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    FT_FREE( face->charset_registry );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
    FT_FREE( bdfface->family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    FT_FREE( bdfface->style_name );
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
    FT_FREE( bdfface->available_sizes );
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_FREE( face->bdffont );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
    FT_TRACE4(( "BDF_Face_Done: done face\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
  BDF_Face_Init( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
                 FT_Face        bdfface,        /* BDF_Face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
                 FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
                 FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
                 FT_Parameter*  params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
    FT_Error       error  = BDF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
    BDF_Face       face   = (BDF_Face)bdfface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    FT_Memory      memory = FT_FACE_MEMORY( face );
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
    bdf_font_t*    font = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    bdf_options_t  options;
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
    FT_UNUSED( num_params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
    FT_UNUSED( params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    if ( FT_STREAM_SEEK( 0 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    options.correct_metrics = 1;   /* FZ XXX: options semantics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    options.keep_unencoded  = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    options.keep_comments   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    options.font_spacing    = BDF_PROPORTIONAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    error = bdf_load_font( stream, memory, &options, &font );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
    if ( error == BDF_Err_Missing_Startfont_Field )
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(( "[not a valid BDF file]\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
    else if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
      goto Exit;
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
    /* we have a bdf font: let's construct the face object */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    face->bdffont = font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
      bdf_property_t*  prop = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
      FT_TRACE4(( "number of glyphs: %d (%d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
                  font->glyphs_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
                  font->glyphs_used ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
      FT_TRACE4(( "number of unencoded glyphs: %d (%d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
                  font->unencoded_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
                  font->unencoded_used ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
      bdfface->num_faces  = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
      bdfface->face_index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
      bdfface->face_flags = FT_FACE_FLAG_FIXED_SIZES |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
                            FT_FACE_FLAG_HORIZONTAL  |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
                            FT_FACE_FLAG_FAST_GLYPHS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
      prop = bdf_get_font_property( font, "SPACING" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
      if ( prop && prop->format == BDF_ATOM                             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
           prop->value.atom                                             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
           ( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
             *(prop->value.atom) == 'C' || *(prop->value.atom) == 'c' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
        bdfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      /* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
      /* FZ XXX: I need a font to implement this */
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
      prop = bdf_get_font_property( font, "FAMILY_NAME" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
      if ( prop && prop->value.atom )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
        if ( FT_STRDUP( bdfface->family_name, prop->value.atom ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
        bdfface->family_name = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
      if ( ( error = bdf_interpret_style( face ) ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
      /* the number of glyphs (with one slot for the undefined glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
      /* at position 0 and all unencoded glyphs)                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
      bdfface->num_glyphs = font->glyphs_size + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
      bdfface->num_fixed_sizes = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
      if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
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
        FT_Bitmap_Size*  bsize = bdfface->available_sizes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
        FT_Short         resolution_x = 0, resolution_y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
        FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
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
        bsize->height = (FT_Short)( font->font_ascent + font->font_descent );
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
        prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
        if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
          bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
          bsize->width = (FT_Short)( bsize->height * 2/3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        prop = bdf_get_font_property( font, "POINT_SIZE" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
        if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
          /* convert from 722.7 decipoints to 72 points per inch */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
          bsize->size =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
            (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
          bsize->size = bsize->width << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
        prop = bdf_get_font_property( font, "PIXEL_SIZE" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
        if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
          bsize->y_ppem = (FT_Short)prop->value.l << 6;
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
        prop = bdf_get_font_property( font, "RESOLUTION_X" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
        if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
          resolution_x = (FT_Short)prop->value.l;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
        prop = bdf_get_font_property( font, "RESOLUTION_Y" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
        if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
          resolution_y = (FT_Short)prop->value.l;
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
        if ( bsize->y_ppem == 0 )
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
          bsize->y_ppem = bsize->size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
          if ( resolution_y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
            bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
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
        if ( resolution_x && resolution_y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
          bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
          bsize->x_ppem = bsize->y_ppem;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
      /* encoding table */
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
        bdf_glyph_t*   cur = font->glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
        unsigned long  n;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
        if ( FT_NEW_ARRAY( face->en_table, font->glyphs_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
        face->default_glyph = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
        for ( n = 0; n < font->glyphs_size; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
          (face->en_table[n]).enc = cur[n].encoding;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
          FT_TRACE4(( "idx %d, val 0x%lX\n", n, cur[n].encoding ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
          (face->en_table[n]).glyph = (FT_Short)n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
          if ( cur[n].encoding == font->default_char )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
            if ( n < FT_UINT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
              face->default_glyph = (FT_UInt)n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
              FT_TRACE1(( "idx %d is too large for this system\n", n ));
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
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
      /* charmaps */
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
        bdf_property_t  *charset_registry = 0, *charset_encoding = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
        FT_Bool          unicode_charmap  = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
        charset_registry =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
          bdf_get_font_property( font, "CHARSET_REGISTRY" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
        charset_encoding =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
          bdf_get_font_property( font, "CHARSET_ENCODING" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
        if ( charset_registry && charset_encoding )
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
          if ( charset_registry->format == BDF_ATOM &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
               charset_encoding->format == BDF_ATOM &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
               charset_registry->value.atom         &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
               charset_encoding->value.atom         )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
            const char*  s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
            if ( FT_STRDUP( face->charset_encoding,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
                            charset_encoding->value.atom ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
                 FT_STRDUP( face->charset_registry,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
                            charset_registry->value.atom ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
              goto Exit;
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
            /* Uh, oh, compare first letters manually to avoid dependency */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
            /* on locales.                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
            s = face->charset_registry;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
            if ( ( s[0] == 'i' || s[0] == 'I' ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
                 ( s[1] == 's' || s[1] == 'S' ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
                 ( s[2] == 'o' || s[2] == 'O' ) )
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
              s += 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
              if ( !ft_strcmp( s, "10646" )                      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
                   ( !ft_strcmp( s, "8859" ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
                     !ft_strcmp( face->charset_encoding, "1" ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
              unicode_charmap = 1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
              FT_CharMapRec  charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
              charmap.face        = FT_FACE( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
              charmap.encoding    = FT_ENCODING_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
              /* initial platform/encoding should indicate unset status? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
              charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
              charmap.encoding_id = TT_APPLE_ID_DEFAULT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
              if ( unicode_charmap )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
                charmap.encoding    = FT_ENCODING_UNICODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
                charmap.platform_id = TT_PLATFORM_MICROSOFT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
                charmap.encoding_id = TT_MS_ID_UNICODE_CS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
              error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
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
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
              /* Select default charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
              if ( bdfface->num_charmaps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
                bdfface->charmap = bdfface->charmaps[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
            }
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
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
        /* otherwise assume Adobe standard encoding */
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
          FT_CharMapRec  charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
          charmap.face        = FT_FACE( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
          charmap.encoding    = FT_ENCODING_ADOBE_STANDARD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
          charmap.platform_id = TT_PLATFORM_ADOBE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
          charmap.encoding_id = TT_ADOBE_ID_STANDARD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
          error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
          /* Select default charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
          if ( bdfface->num_charmaps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
            bdfface->charmap = bdfface->charmaps[0];
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
    BDF_Face_Done( bdfface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    return BDF_Err_Unknown_File_Format;
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
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
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
  BDF_Size_Select( FT_Size   size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
                   FT_ULong  strike_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    bdf_font_t*  bdffont = ( (BDF_Face)size->face )->bdffont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    FT_Select_Metrics( size->face, strike_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
    size->metrics.ascender    = bdffont->font_ascent << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
    size->metrics.descender   = -bdffont->font_descent << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
    size->metrics.max_advance = bdffont->bbx.width << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
    return BDF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
  BDF_Size_Request( FT_Size          size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
                    FT_Size_Request  req )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    FT_Face          face    = size->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    FT_Bitmap_Size*  bsize   = face->available_sizes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    bdf_font_t*      bdffont = ( (BDF_Face)face )->bdffont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    FT_Error         error   = BDF_Err_Invalid_Pixel_Size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
    FT_Long          height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
    height = FT_REQUEST_HEIGHT( req );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    height = ( height + 32 ) >> 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    switch ( req->type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
    case FT_SIZE_REQUEST_TYPE_NOMINAL:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
      if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
        error = BDF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
    case FT_SIZE_REQUEST_TYPE_REAL_DIM:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
      if ( height == ( bdffont->font_ascent +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
                       bdffont->font_descent ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
        error = BDF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
      error = BDF_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
      return BDF_Size_Select( size, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
  BDF_Glyph_Load( FT_GlyphSlot  slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
                  FT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
                  FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
                  FT_Int32      load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
    BDF_Face     bdf    = (BDF_Face)FT_SIZE_FACE( size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
    FT_Face      face   = FT_FACE( bdf );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
    FT_Error     error  = BDF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
    FT_Bitmap*   bitmap = &slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
    bdf_glyph_t  glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
    int          bpp    = bdf->bdffont->bpp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
    FT_UNUSED( load_flags );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
    if ( !face || glyph_index >= (FT_UInt)face->num_glyphs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
      error = BDF_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
    /* index 0 is the undefined glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
    if ( glyph_index == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
      glyph_index = bdf->default_glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
      glyph_index--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    /* slot, bitmap => freetype, glyph => bdflib */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
    glyph = bdf->bdffont->glyphs[glyph_index];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
    bitmap->rows  = glyph.bbx.height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
    bitmap->width = glyph.bbx.width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
    if ( glyph.bpr > INT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
      FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
                   glyph.bpr ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
    bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
    /* note: we don't allocate a new array to hold the bitmap; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    /*       we can simply point to it                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
    ft_glyphslot_set_bitmap( slot, glyph.bitmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
    switch ( bpp )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
    case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
    case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      bitmap->pixel_mode = FT_PIXEL_MODE_GRAY2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
    case 4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
      bitmap->pixel_mode = FT_PIXEL_MODE_GRAY4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
    case 8:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
      bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
      bitmap->num_grays  = 256;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
    slot->format      = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
    slot->bitmap_left = glyph.bbx.x_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
    slot->bitmap_top  = glyph.bbx.ascent;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
    slot->metrics.horiAdvance  = glyph.dwidth << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
    slot->metrics.horiBearingX = glyph.bbx.x_offset << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
    slot->metrics.horiBearingY = glyph.bbx.ascent << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
    slot->metrics.width        = bitmap->width << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
    slot->metrics.height       = bitmap->rows << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
     * XXX DWIDTH1 and VVECTOR should be parsed and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
     * used here, provided such fonts do exist.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    ft_synthesize_vertical_metrics( &slot->metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
                                    bdf->bdffont->bbx.height << 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
 /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
  *  BDF SERVICE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
  bdf_get_bdf_property( BDF_Face          face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
                        const char*       prop_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
                        BDF_PropertyRec  *aproperty )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
    bdf_property_t*  prop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
    FT_ASSERT( face && face->bdffont );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
    prop = bdf_get_font_property( face->bdffont, prop_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
    if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
      switch ( prop->format )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
      case BDF_ATOM:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
        aproperty->type   = BDF_PROPERTY_TYPE_ATOM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
        aproperty->u.atom = prop->value.atom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
      case BDF_INTEGER:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
        if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
          FT_TRACE1(( "bdf_get_bdf_property: " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
          FT_TRACE1(( "too large integer 0x%x is truncated\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
        aproperty->type      = BDF_PROPERTY_TYPE_INTEGER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
        aproperty->u.integer = (FT_Int32)prop->value.l;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
      case BDF_CARDINAL:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
        if ( prop->value.ul > 0xFFFFFFFFUL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
          FT_TRACE1(( "bdf_get_bdf_property: " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
          FT_TRACE1(( "too large cardinal 0x%x is truncated\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
        aproperty->type       = BDF_PROPERTY_TYPE_CARDINAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
        aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
    return BDF_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
  bdf_get_charset_id( BDF_Face      face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
                      const char*  *acharset_encoding,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
                      const char*  *acharset_registry )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
    *acharset_encoding = face->charset_encoding;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
    *acharset_registry = face->charset_registry;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
  static const FT_Service_BDFRec  bdf_service_bdf =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    (FT_BDF_GetCharsetIdFunc)bdf_get_charset_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
    (FT_BDF_GetPropertyFunc) bdf_get_bdf_property
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
 /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
  *  SERVICES LIST
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
  static const FT_ServiceDescRec  bdf_services[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
    { FT_SERVICE_ID_BDF,       &bdf_service_bdf },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
    { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_BDF },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
    { NULL, NULL }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
  FT_CALLBACK_DEF( FT_Module_Interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
  bdf_driver_requester( FT_Module    module,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
                        const char*  name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
    FT_UNUSED( module );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
    return ft_service_list_lookup( bdf_services, name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
  const FT_Driver_ClassRec  bdf_driver_class =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
      FT_MODULE_FONT_DRIVER         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
      FT_MODULE_DRIVER_NO_OUTLINES,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
      sizeof ( FT_DriverRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
      "bdf",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
      0x20000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
      0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
      (FT_Module_Constructor)0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
      (FT_Module_Requester)  bdf_driver_requester
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
    },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
    sizeof ( BDF_FaceRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
    sizeof ( FT_SizeRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
    sizeof ( FT_GlyphSlotRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
    BDF_Face_Init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
    BDF_Face_Done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
    0,                          /* FT_Size_InitFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
    0,                          /* FT_Size_DoneFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
    0,                          /* FT_Slot_InitFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
    0,                          /* FT_Slot_DoneFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
    ft_stub_set_char_sizes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
    ft_stub_set_pixel_sizes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
    BDF_Glyph_Load,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
    0,                          /* FT_Face_GetKerningFunc   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
    0,                          /* FT_Face_AttachFunc       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
    0,                          /* FT_Face_GetAdvancesFunc  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
    BDF_Size_Request,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
    BDF_Size_Select
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
/* END */