misc/libfreetype/src/pcf/pcfdrivr.c
author nemo
Fri, 02 Sep 2011 08:16:34 -0400
changeset 5737 ddbb20092cb0
parent 5172 88f2e05288ba
permissions -rw-r--r--
oops.
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
/*  pcfdrivr.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 pcf 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) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
                  2010 by
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
    Francesco Zappa Nardelli
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
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
    10
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
    11
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
    12
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
    13
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
    14
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
    15
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
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
    17
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
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
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
    20
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
    21
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
    22
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
    23
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
    24
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
    25
THE SOFTWARE.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
*/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
#include FT_GZIP_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
#include FT_LZW_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
#include FT_BZIP2_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#include FT_ERRORS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
#include FT_BDF_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
#include FT_TRUETYPE_IDS_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 "pcf.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
#include "pcfdrivr.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
#include "pcfread.h"
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
#include "pcferror.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
#include "pcfutil.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
#define FT_COMPONENT  trace_pcfread
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
#include FT_SERVICE_BDF_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
#include FT_SERVICE_XFREE86_NAME_H
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  /* 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
    58
  /* 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
    59
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
#define FT_COMPONENT  trace_pcfdriver
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
  typedef struct  PCF_CMapRec_
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
    FT_CMapRec    root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    FT_UInt       num_encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    PCF_Encoding  encodings;
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
  } PCF_CMapRec, *PCF_CMap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  pcf_cmap_init( FT_CMap     pcfcmap,   /* PCF_CMap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
                 FT_Pointer  init_data )
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
    PCF_CMap  cmap = (PCF_CMap)pcfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    PCF_Face  face = (PCF_Face)FT_CMAP_FACE( pcfcmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    FT_UNUSED( init_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
    cmap->num_encodings = (FT_UInt)face->nencodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    cmap->encodings     = face->encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    return PCF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  pcf_cmap_done( FT_CMap  pcfcmap )         /* PCF_CMap */
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
    PCF_CMap  cmap = (PCF_CMap)pcfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    cmap->encodings     = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    cmap->num_encodings = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  pcf_cmap_char_index( FT_CMap    pcfcmap,  /* PCF_CMap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
                       FT_UInt32  charcode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    PCF_CMap      cmap      = (PCF_CMap)pcfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    PCF_Encoding  encodings = cmap->encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    FT_UInt       min, max, mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    FT_UInt       result    = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    max = cmap->num_encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    while ( min < max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
      FT_ULong  code;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
      mid  = ( min + max ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
      code = encodings[mid].enc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
      if ( charcode == code )
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
        result = encodings[mid].glyph + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
        break;
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
      if ( charcode < code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
        max = mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
        min = mid + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
  FT_CALLBACK_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
  pcf_cmap_char_next( FT_CMap    pcfcmap,   /* PCF_CMap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
                      FT_UInt32  *acharcode )
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
    PCF_CMap      cmap      = (PCF_CMap)pcfcmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    PCF_Encoding  encodings = cmap->encodings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    FT_UInt       min, max, mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    FT_ULong      charcode  = *acharcode + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_UInt       result    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    max = cmap->num_encodings;
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
    while ( min < max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
      FT_ULong  code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      mid  = ( min + max ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      code = encodings[mid].enc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      if ( charcode == code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
        result = encodings[mid].glyph + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      if ( charcode < code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
        max = mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
        min = mid + 1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    charcode = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    if ( min < cmap->num_encodings )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      charcode = encodings[min].enc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      result   = encodings[min].glyph + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    if ( charcode > 0xFFFFFFFFUL )
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
      FT_TRACE1(( "pcf_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
   184
      *acharcode = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
      /* 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
   186
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      *acharcode = (FT_UInt32)charcode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
  const FT_CMap_ClassRec  pcf_cmap_class =
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
    sizeof ( PCF_CMapRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    pcf_cmap_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    pcf_cmap_done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    pcf_cmap_char_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    pcf_cmap_char_next,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    NULL, NULL, NULL, NULL, NULL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
  PCF_Face_Done( FT_Face  pcfface )         /* PCF_Face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    PCF_Face   face = (PCF_Face)pcfface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    FT_Memory  memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    memory = FT_FACE_MEMORY( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    FT_FREE( face->encodings );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    FT_FREE( face->metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    /* free properties */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
      PCF_Property  prop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      FT_Int        i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      if ( face->properties )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
        for ( i = 0; i < face->nprops; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
          prop = &face->properties[i];
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
          if ( prop )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
            FT_FREE( prop->name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
            if ( prop->isString )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
              FT_FREE( prop->value.atom );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
      FT_FREE( face->properties );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    FT_FREE( face->toc.tables );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    FT_FREE( pcfface->family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    FT_FREE( pcfface->style_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    FT_FREE( pcfface->available_sizes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
    FT_FREE( face->charset_encoding );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    FT_FREE( face->charset_registry );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    FT_TRACE4(( "PCF_Face_Done: done face\n" ));
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
    /* close compressed stream if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    if ( pcfface->stream == &face->comp_stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
      FT_Stream_Close( &face->comp_stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
      pcfface->stream = face->comp_source;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
  PCF_Face_Init( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
                 FT_Face        pcfface,        /* PCF_Face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
                 FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
                 FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
                 FT_Parameter*  params )
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
    PCF_Face  face  = (PCF_Face)pcfface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
    FT_Error  error = PCF_Err_Ok;
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
    FT_UNUSED( num_params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    FT_UNUSED( params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    error = pcf_load_font( stream, face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
      PCF_Face_Done( pcfface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
#if defined( FT_CONFIG_OPTION_USE_ZLIB )  || \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    defined( FT_CONFIG_OPTION_USE_LZW )   || \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    defined( FT_CONFIG_OPTION_USE_BZIP2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
#ifdef FT_CONFIG_OPTION_USE_ZLIB
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_Error  error2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
        /* this didn't work, try gzip support! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
        error2 = FT_Stream_OpenGzip( &face->comp_stream, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
        if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
          goto Fail;
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
        error = error2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
#endif /* FT_CONFIG_OPTION_USE_ZLIB */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
#ifdef FT_CONFIG_OPTION_USE_LZW
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
        FT_Error  error3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
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
        /* this didn't work, try LZW support! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
        error3 = FT_Stream_OpenLZW( &face->comp_stream, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
        if ( FT_ERROR_BASE( error3 ) == FT_Err_Unimplemented_Feature )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
          goto Fail;
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
        error = error3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
#endif /* FT_CONFIG_OPTION_USE_LZW */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
#ifdef FT_CONFIG_OPTION_USE_BZIP2
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      if ( error )
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
        FT_Error  error4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
        /* this didn't work, try Bzip2 support! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
        error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
        if ( FT_ERROR_BASE( error4 ) == FT_Err_Unimplemented_Feature )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
          goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
        error = error4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
#endif /* FT_CONFIG_OPTION_USE_BZIP2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
      face->comp_source = stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
      pcfface->stream   = &face->comp_stream;
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
      stream = pcfface->stream;
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
      error = pcf_load_font( stream, face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
#else /* !(FT_CONFIG_OPTION_USE_ZLIB ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
           FT_CONFIG_OPTION_USE_LZW ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
           FT_CONFIG_OPTION_USE_BZIP2) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
    /* set up charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
      FT_String  *charset_registry = face->charset_registry;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
      FT_String  *charset_encoding = face->charset_encoding;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
      FT_Bool     unicode_charmap  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
      if ( charset_registry && charset_encoding )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
        char*  s = charset_registry;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        /* 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
   364
           on locales. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
        if ( ( s[0] == 'i' || s[0] == 'I' ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
             ( s[1] == 's' || s[1] == 'S' ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
             ( s[2] == 'o' || s[2] == 'O' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
          s += 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
          if ( !ft_strcmp( s, "10646" )                      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
               ( !ft_strcmp( s, "8859" ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
                 !ft_strcmp( face->charset_encoding, "1" ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
          unicode_charmap = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
        }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
        FT_CharMapRec  charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        charmap.face        = FT_FACE( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
        charmap.encoding    = FT_ENCODING_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
        /* initial platform/encoding should indicate unset status? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
        charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
        charmap.encoding_id = TT_APPLE_ID_DEFAULT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
        if ( unicode_charmap )
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
          charmap.encoding    = FT_ENCODING_UNICODE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
          charmap.platform_id = TT_PLATFORM_MICROSOFT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
          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
   392
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
        error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
        /* Select default charmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
        if ( pcfface->num_charmaps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
          pcfface->charmap = pcfface->charmaps[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    FT_TRACE2(( "[not a valid PCF file]\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
    PCF_Face_Done( pcfface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
    error = PCF_Err_Unknown_File_Format;  /* error */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  PCF_Size_Select( FT_Size   size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
                   FT_ULong  strike_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
    PCF_Accel  accel = &( (PCF_Face)size->face )->accel;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
    FT_Select_Metrics( size->face, strike_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
    size->metrics.ascender    =  accel->fontAscent << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
    size->metrics.descender   = -accel->fontDescent << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
    size->metrics.max_advance =  accel->maxbounds.characterWidth << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
    return PCF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
  PCF_Size_Request( FT_Size          size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
                    FT_Size_Request  req )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
    PCF_Face         face  = (PCF_Face)size->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
    FT_Bitmap_Size*  bsize = size->face->available_sizes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
    FT_Error         error = PCF_Err_Invalid_Pixel_Size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
    FT_Long          height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    height = FT_REQUEST_HEIGHT( req );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
    height = ( height + 32 ) >> 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
    switch ( req->type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
    case FT_SIZE_REQUEST_TYPE_NOMINAL:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
      if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
        error = PCF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
      break;
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
    case FT_SIZE_REQUEST_TYPE_REAL_DIM:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
      if ( height == ( face->accel.fontAscent +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
                       face->accel.fontDescent ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        error = PCF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
      error = PCF_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
      break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
      return PCF_Size_Select( size, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
  FT_CALLBACK_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
  PCF_Glyph_Load( FT_GlyphSlot  slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
                  FT_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
                  FT_UInt       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
                  FT_Int32      load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
    PCF_Face    face   = (PCF_Face)FT_SIZE_FACE( size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
    FT_Stream   stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
    FT_Error    error  = PCF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
    FT_Bitmap*  bitmap = &slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
    PCF_Metric  metric;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
    FT_Offset   bytes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
    FT_UNUSED( load_flags );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    FT_TRACE4(( "load_glyph %d ---", glyph_index ));
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 ( !face || glyph_index >= (FT_UInt)face->root.num_glyphs )
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
      error = PCF_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
    stream = face->root.stream;
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
    if ( glyph_index > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
      glyph_index--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
    metric = face->metrics + glyph_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
    bitmap->rows       = metric->ascent + metric->descent;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
    bitmap->width      = metric->rightSideBearing - metric->leftSideBearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    bitmap->num_grays  = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
    FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
                  PCF_BIT_ORDER( face->bitmapsFormat ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
                  PCF_BYTE_ORDER( face->bitmapsFormat ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
                  PCF_GLYPH_PAD( face->bitmapsFormat ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    switch ( PCF_GLYPH_PAD( face->bitmapsFormat ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
    case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
      bitmap->pitch = ( bitmap->width + 7 ) >> 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
      break;
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
    case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
      bitmap->pitch = ( ( bitmap->width + 15 ) >> 4 ) << 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
    case 4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
      bitmap->pitch = ( ( bitmap->width + 31 ) >> 5 ) << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
    case 8:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
      bitmap->pitch = ( ( bitmap->width + 63 ) >> 6 ) << 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
      return PCF_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
    /* XXX: to do: are there cases that need repadding the bitmap? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
    bytes = bitmap->pitch * bitmap->rows;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    error = ft_glyphslot_alloc_bitmap( slot, bytes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
    if ( FT_STREAM_SEEK( metric->bits )          ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
         FT_STREAM_READ( bitmap->buffer, bytes ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
    if ( PCF_BIT_ORDER( face->bitmapsFormat ) != MSBFirst )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
      BitOrderInvert( bitmap->buffer, bytes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
    if ( ( PCF_BYTE_ORDER( face->bitmapsFormat ) !=
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
           PCF_BIT_ORDER( face->bitmapsFormat )  ) )
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
      switch ( PCF_SCAN_UNIT( face->bitmapsFormat ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
      case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
        break;
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
      case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
        TwoByteSwap( bitmap->buffer, bytes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
      case 4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
        FourByteSwap( bitmap->buffer, bytes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
        break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    slot->format      = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    slot->bitmap_left = metric->leftSideBearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
    slot->bitmap_top  = metric->ascent;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    slot->metrics.horiAdvance  = metric->characterWidth << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    slot->metrics.horiBearingX = metric->leftSideBearing << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
    slot->metrics.horiBearingY = metric->ascent << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
    slot->metrics.width        = ( metric->rightSideBearing -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
                                   metric->leftSideBearing ) << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
    slot->metrics.height       = bitmap->rows << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
    ft_synthesize_vertical_metrics( &slot->metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
                                    ( face->accel.fontAscent +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
                                      face->accel.fontDescent ) << 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    FT_TRACE4(( " --- ok\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
    return error;
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
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
  *  BDF SERVICE
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
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
  pcf_get_bdf_property( PCF_Face          face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
                        const char*       prop_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
                        BDF_PropertyRec  *aproperty )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
    PCF_Property  prop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    prop = pcf_find_property( face, prop_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
    if ( prop != NULL )
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
      if ( prop->isString )
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
        aproperty->type   = BDF_PROPERTY_TYPE_ATOM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
        aproperty->u.atom = prop->value.atom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
        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
   612
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
          FT_TRACE1(( "pcf_get_bdf_property: " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
          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
   615
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
        /* Apparently, the PCF driver loads all properties as signed integers!
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
         * This really doesn't seem to be a problem, because this is
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
         * sufficient for any meaningful values.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
        aproperty->type      = BDF_PROPERTY_TYPE_INTEGER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
        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
   622
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    return PCF_Err_Invalid_Argument;
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
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
  pcf_get_charset_id( PCF_Face      face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
                      const char*  *acharset_encoding,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
                      const char*  *acharset_registry )
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
    *acharset_encoding = face->charset_encoding;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
    *acharset_registry = face->charset_registry;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
  static const FT_Service_BDFRec  pcf_service_bdf =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
    (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
    (FT_BDF_GetPropertyFunc) pcf_get_bdf_property
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
 /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
  *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
  *  SERVICE LIST
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
  static const FT_ServiceDescRec  pcf_services[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
    { FT_SERVICE_ID_BDF,       &pcf_service_bdf },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
    { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_PCF },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
    { NULL, NULL }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
  FT_CALLBACK_DEF( FT_Module_Interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
  pcf_driver_requester( FT_Module    module,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
                        const char*  name )
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( module );
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
    return ft_service_list_lookup( pcf_services, name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
  const FT_Driver_ClassRec  pcf_driver_class =
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
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
      FT_MODULE_FONT_DRIVER        |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
      FT_MODULE_DRIVER_NO_OUTLINES,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
      sizeof ( FT_DriverRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
      "pcf",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
      0x20000L,
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
      0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
      0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
      0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
      pcf_driver_requester
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
    },
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
    sizeof ( PCF_FaceRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    sizeof ( FT_SizeRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
    sizeof ( FT_GlyphSlotRec ),
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
    PCF_Face_Init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
    PCF_Face_Done,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
    0,                      /* FT_Size_InitFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
    0,                      /* FT_Size_DoneFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
    0,                      /* FT_Slot_InitFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
    0,                      /* FT_Slot_DoneFunc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
    ft_stub_set_char_sizes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
    ft_stub_set_pixel_sizes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
    PCF_Glyph_Load,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
    0,                      /* FT_Face_GetKerningFunc  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
    0,                      /* FT_Face_AttachFunc      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
    0,                      /* FT_Face_GetAdvancesFunc */
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
    PCF_Size_Request,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
    PCF_Size_Select
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
  };
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
/* END */