misc/libfreetype/src/cid/cidobjs.c
author unc0rr
Mon, 04 Feb 2013 00:13:55 +0400
changeset 8479 8d71109b04d2
parent 5172 88f2e05288ba
permissions -rw-r--r--
Some work on loading replay and interaction with checker
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  cidobjs.c                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    CID objects manager (body).                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 by       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "cidgload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include "cidload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include FT_INTERNAL_POSTSCRIPT_AUX_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#include "ciderrs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /* 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
    36
  /* 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
    37
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
#define FT_COMPONENT  trace_cidobjs
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
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
  /*                            SLOT  FUNCTIONS                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  cid_slot_done( FT_GlyphSlot  slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    slot->internal->glyph_hints = 0;
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  cid_slot_init( FT_GlyphSlot  slot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    CID_Face          face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    PSHinter_Service  pshinter;
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
    face     = (CID_Face)slot->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    pshinter = (PSHinter_Service)face->pshinter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    if ( pshinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
      FT_Module  module;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
      module = FT_Get_Module( slot->face->driver->root.library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
                              "pshinter" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
      if ( module )
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
        T1_Hints_Funcs  funcs;
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
        funcs = pshinter->get_t1_funcs( module );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
        slot->internal->glyph_hints = (void*)funcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    return 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
  /*                           SIZE  FUNCTIONS                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
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
  static PSH_Globals_Funcs
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  cid_size_get_globals_funcs( CID_Size  size )
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
    CID_Face          face     = (CID_Face)size->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    PSHinter_Service  pshinter = (PSHinter_Service)face->pshinter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    FT_Module         module;
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
    module = FT_Get_Module( size->root.face->driver->root.library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
                            "pshinter" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    return ( module && pshinter && pshinter->get_globals_funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
           ? pshinter->get_globals_funcs( module )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
           : 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  cid_size_done( FT_Size  cidsize )         /* CID_Size */
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
    CID_Size  size = (CID_Size)cidsize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    if ( cidsize->internal )
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
      PSH_Globals_Funcs  funcs;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
      funcs = cid_size_get_globals_funcs( size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
      if ( funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
        funcs->destroy( (PSH_Globals)cidsize->internal );
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
      cidsize->internal = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  cid_size_init( FT_Size  cidsize )     /* CID_Size */
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
    CID_Size           size  = (CID_Size)cidsize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    FT_Error           error = CID_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    PSH_Globals_Funcs  funcs = cid_size_get_globals_funcs( size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    if ( funcs )
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
      PSH_Globals   globals;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
      CID_Face      face = (CID_Face)cidsize->face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
      CID_FaceDict  dict = face->cid.font_dicts + face->root.face_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
      PS_Private    priv = &dict->private_dict;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      error = funcs->create( cidsize->face->memory, priv, &globals );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
        cidsize->internal = (FT_Size_Internal)(void*)globals;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    return error;
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
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_LOCAL( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
  cid_size_request( FT_Size          size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
                    FT_Size_Request  req )
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
    PSH_Globals_Funcs  funcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    FT_Request_Metrics( size->face, req );
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
    funcs = cid_size_get_globals_funcs( (CID_Size)size );
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
    if ( funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      funcs->set_scale( (PSH_Globals)size->internal,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
                        size->metrics.x_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
                        size->metrics.y_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
                        0, 0 );
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
    return CID_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
  /*                           FACE  FUNCTIONS                             */
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
  /*************************************************************************/
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  /*    cid_face_done                                                      */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
  /*    Finalizes a given face object.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
  /*    face :: A pointer to the face object to destroy.                   */
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_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
  cid_face_done( FT_Face  cidface )         /* CID_Face */
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
    CID_Face      face = (CID_Face)cidface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FT_Memory     memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    CID_FaceInfo  cid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    PS_FontInfo   info;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
      return;
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
    cid    = &face->cid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    info   = &cid->font_info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    memory = cidface->memory;
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
    /* release subrs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    if ( face->subrs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
      FT_Int  n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      for ( n = 0; n < cid->num_dicts; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
        CID_Subrs  subr = face->subrs + n;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
        if ( subr->code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
          FT_FREE( subr->code[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
          FT_FREE( subr->code );
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
      }
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
      FT_FREE( face->subrs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    /* release FontInfo strings */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    FT_FREE( info->version );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    FT_FREE( info->notice );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    FT_FREE( info->full_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    FT_FREE( info->family_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    FT_FREE( info->weight );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
    /* release font dictionaries */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    FT_FREE( cid->font_dicts );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    cid->num_dicts = 0;
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
    /* release other strings */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    FT_FREE( cid->cid_font_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    FT_FREE( cid->registry );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    FT_FREE( cid->ordering );
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
    cidface->family_name = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    cidface->style_name  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    FT_FREE( face->binary_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    FT_FREE( face->cid_stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
  /*    cid_face_init                                                      */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
  /*    Initializes a given CID face object.                               */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
  /*    stream     :: The source font stream.                              */
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
  /*    face_index :: The index of the font face in the resource.          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  /*    num_params :: Number of additional generic parameters.  Ignored.   */
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
  /*    params     :: Additional generic parameters.  Ignored.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
  /*    face       :: The newly built face object.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
  /*    FreeType error code.  0 means success.                             */
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
  cid_face_init( FT_Stream      stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
                 FT_Face        cidface,        /* CID_Face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
                 FT_Int         face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
                 FT_Int         num_params,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
                 FT_Parameter*  params )
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
    CID_Face          face = (CID_Face)cidface;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    FT_Error          error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    PSAux_Service     psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    PSHinter_Service  pshinter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
    FT_UNUSED( num_params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
    FT_UNUSED( params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    FT_UNUSED( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    cidface->num_faces = 1;
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
    psaux = (PSAux_Service)face->psaux;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    if ( !psaux )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
      psaux = (PSAux_Service)FT_Get_Module_Interface(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
                FT_FACE_LIBRARY( face ), "psaux" );
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
      face->psaux = psaux;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
    pshinter = (PSHinter_Service)face->pshinter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    if ( !pshinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
      pshinter = (PSHinter_Service)FT_Get_Module_Interface(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
                   FT_FACE_LIBRARY( face ), "pshinter" );
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
      face->pshinter = pshinter;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    /* open the tokenizer; this will also check the font format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    if ( FT_STREAM_SEEK( 0 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      goto Exit;
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
    error = cid_face_open( face, face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    /* if we just wanted to check the format, leave successfully now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    if ( face_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
      goto Exit;
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
    /* check the face index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    /* XXX: handle CID fonts with more than a single face */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    if ( face_index != 0 )
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
      FT_ERROR(( "cid_face_init: invalid face index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
      error = CID_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
      goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    /* now load the font program into the face object */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    /* initialize the face object fields */
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
    /* set up root face fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
      CID_FaceInfo  cid  = &face->cid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
      PS_FontInfo   info = &cid->font_info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
      cidface->num_glyphs   = cid->cid_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
      cidface->num_charmaps = 0;
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
      cidface->face_index = face_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
      cidface->face_flags = FT_FACE_FLAG_SCALABLE   | /* scalable outlines */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
                            FT_FACE_FLAG_HORIZONTAL | /* horizontal data   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
                            FT_FACE_FLAG_HINTER;      /* has native hinter */
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
      if ( info->is_fixed_pitch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
        cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
      /* XXX: TODO: add kerning with .afm support */
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
      /* get style name -- be careful, some broken fonts only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
      /* have a /FontName dictionary entry!                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
      cidface->family_name = info->family_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
      /* assume "Regular" style if we don't know better */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
      cidface->style_name = (char *)"Regular";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
      if ( cidface->family_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
        char*  full   = info->full_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
        char*  family = cidface->family_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
        if ( full )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
          while ( *full )
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
            if ( *full == *family )
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
              family++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
              full++;
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
            else
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
              if ( *full == ' ' || *full == '-' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
                full++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
              else if ( *family == ' ' || *family == '-' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
                family++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
              else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
                if ( !*family )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
                  cidface->style_name = full;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
                break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
          }
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
      else
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
        /* do we have a `/FontName'? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
        if ( cid->cid_font_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
          cidface->family_name = cid->cid_font_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
      /* compute style flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      cidface->style_flags = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
      if ( info->italic_angle )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
        cidface->style_flags |= FT_STYLE_FLAG_ITALIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
      if ( info->weight )
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
        if ( !ft_strcmp( info->weight, "Bold"  ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
             !ft_strcmp( info->weight, "Black" ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
          cidface->style_flags |= FT_STYLE_FLAG_BOLD;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
      /* no embedded bitmap support */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
      cidface->num_fixed_sizes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
      cidface->available_sizes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
      cidface->bbox.xMin =   cid->font_bbox.xMin            >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
      cidface->bbox.yMin =   cid->font_bbox.yMin            >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
      /* no `U' suffix here to 0xFFFF! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
      cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFF ) >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
      cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFF ) >> 16;
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
      if ( !cidface->units_per_EM )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
        cidface->units_per_EM = 1000;
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
      cidface->ascender  = (FT_Short)( cidface->bbox.yMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      cidface->descender = (FT_Short)( cidface->bbox.yMin );
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
      cidface->height = (FT_Short)( ( cidface->units_per_EM * 12 ) / 10 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
      if ( cidface->height < cidface->ascender - cidface->descender )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
        cidface->height = (FT_Short)( cidface->ascender - cidface->descender );
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
      cidface->underline_position  = (FT_Short)info->underline_position;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
      cidface->underline_thickness = (FT_Short)info->underline_thickness;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    }
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
  }
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
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
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
  /*    cid_driver_init                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
  /*    Initializes a given CID driver object.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
  /*    driver :: A handle to the target driver object.                    */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
  cid_driver_init( FT_Module  driver )
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
    FT_UNUSED( driver );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
    return CID_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
  /*    cid_driver_done                                                    */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
  /*    Finalizes a given CID driver.                                      */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  /*    driver :: A handle to the target CID driver.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
  cid_driver_done( FT_Module  driver )
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
    FT_UNUSED( driver );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
/* END */