- Remove svn:needs-lock, svn:eol-type, and svn:eol-tyle properties.
[reactos.git] / reactos / lib / 3rdparty / freetype / src / cid / cidobjs.c
index adb78c8..1b3bfbf 100644 (file)
-/***************************************************************************/\r
-/*                                                                         */\r
-/*  cidobjs.c                                                              */\r
-/*                                                                         */\r
-/*    CID objects manager (body).                                          */\r
-/*                                                                         */\r
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by                   */\r
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */\r
-/*                                                                         */\r
-/*  This file is part of the FreeType project, and may only be used,       */\r
-/*  modified, and distributed under the terms of the FreeType project      */\r
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */\r
-/*  this file you indicate that you have read the license and              */\r
-/*  understand and accept it fully.                                        */\r
-/*                                                                         */\r
-/***************************************************************************/\r
-\r
-\r
-#include <ft2build.h>\r
-#include FT_INTERNAL_DEBUG_H\r
-#include FT_INTERNAL_STREAM_H\r
-\r
-#include "cidgload.h"\r
-#include "cidload.h"\r
-\r
-#include FT_SERVICE_POSTSCRIPT_CMAPS_H\r
-#include FT_INTERNAL_POSTSCRIPT_AUX_H\r
-#include FT_INTERNAL_POSTSCRIPT_HINTS_H\r
-\r
-#include "ciderrs.h"\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */\r
-  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */\r
-  /* messages during execution.                                            */\r
-  /*                                                                       */\r
-#undef  FT_COMPONENT\r
-#define FT_COMPONENT  trace_cidobjs\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /*                            SLOT  FUNCTIONS                            */\r
-  /*                                                                       */\r
-  /*************************************************************************/\r
-\r
-  FT_LOCAL_DEF( void )\r
-  cid_slot_done( FT_GlyphSlot  slot )\r
-  {\r
-    slot->internal->glyph_hints = 0;\r
-  }\r
-\r
-\r
-  FT_LOCAL_DEF( FT_Error )\r
-  cid_slot_init( FT_GlyphSlot  slot )\r
-  {\r
-    CID_Face          face;\r
-    PSHinter_Service  pshinter;\r
-\r
-\r
-    face     = (CID_Face)slot->face;\r
-    pshinter = (PSHinter_Service)face->pshinter;\r
-\r
-    if ( pshinter )\r
-    {\r
-      FT_Module  module;\r
-\r
-\r
-      module = FT_Get_Module( slot->face->driver->root.library,\r
-                              "pshinter" );\r
-      if ( module )\r
-      {\r
-        T1_Hints_Funcs  funcs;\r
-\r
-\r
-        funcs = pshinter->get_t1_funcs( module );\r
-        slot->internal->glyph_hints = (void*)funcs;\r
-      }\r
-    }\r
-\r
-    return 0;\r
-  }\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /*                           SIZE  FUNCTIONS                             */\r
-  /*                                                                       */\r
-  /*************************************************************************/\r
-\r
-\r
-  static PSH_Globals_Funcs\r
-  cid_size_get_globals_funcs( CID_Size  size )\r
-  {\r
-    CID_Face          face     = (CID_Face)size->root.face;\r
-    PSHinter_Service  pshinter = (PSHinter_Service)face->pshinter;\r
-    FT_Module         module;\r
-\r
-\r
-    module = FT_Get_Module( size->root.face->driver->root.library,\r
-                            "pshinter" );\r
-    return ( module && pshinter && pshinter->get_globals_funcs )\r
-           ? pshinter->get_globals_funcs( module )\r
-           : 0;\r
-  }\r
-\r
-\r
-  FT_LOCAL_DEF( void )\r
-  cid_size_done( FT_Size  cidsize )         /* CID_Size */\r
-  {\r
-    CID_Size  size = (CID_Size)cidsize;\r
-\r
-\r
-    if ( cidsize->internal )\r
-    {\r
-      PSH_Globals_Funcs  funcs;\r
-\r
-\r
-      funcs = cid_size_get_globals_funcs( size );\r
-      if ( funcs )\r
-        funcs->destroy( (PSH_Globals)cidsize->internal );\r
-\r
-      cidsize->internal = 0;\r
-    }\r
-  }\r
-\r
-\r
-  FT_LOCAL_DEF( FT_Error )\r
-  cid_size_init( FT_Size  cidsize )     /* CID_Size */\r
-  {\r
-    CID_Size           size  = (CID_Size)cidsize;\r
-    FT_Error           error = 0;\r
-    PSH_Globals_Funcs  funcs = cid_size_get_globals_funcs( size );\r
-\r
-\r
-    if ( funcs )\r
-    {\r
-      PSH_Globals   globals;\r
-      CID_Face      face = (CID_Face)cidsize->face;\r
-      CID_FaceDict  dict = face->cid.font_dicts + face->root.face_index;\r
-      PS_Private    priv = &dict->private_dict;\r
-\r
-\r
-      error = funcs->create( cidsize->face->memory, priv, &globals );\r
-      if ( !error )\r
-        cidsize->internal = (FT_Size_Internal)(void*)globals;\r
-    }\r
-\r
-    return error;\r
-  }\r
-\r
-\r
-  FT_LOCAL( FT_Error )\r
-  cid_size_request( FT_Size          size,\r
-                    FT_Size_Request  req )\r
-  {\r
-    PSH_Globals_Funcs  funcs;\r
-\r
-\r
-    FT_Request_Metrics( size->face, req );\r
-\r
-    funcs = cid_size_get_globals_funcs( (CID_Size)size );\r
-\r
-    if ( funcs )\r
-      funcs->set_scale( (PSH_Globals)size->internal,\r
-                        size->metrics.x_scale,\r
-                        size->metrics.y_scale,\r
-                        0, 0 );\r
-\r
-    return CID_Err_Ok;\r
-  }\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /*                           FACE  FUNCTIONS                             */\r
-  /*                                                                       */\r
-  /*************************************************************************/\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /* <Function>                                                            */\r
-  /*    cid_face_done                                                      */\r
-  /*                                                                       */\r
-  /* <Description>                                                         */\r
-  /*    Finalizes a given face object.                                     */\r
-  /*                                                                       */\r
-  /* <Input>                                                               */\r
-  /*    face :: A pointer to the face object to destroy.                   */\r
-  /*                                                                       */\r
-  FT_LOCAL_DEF( void )\r
-  cid_face_done( FT_Face  cidface )         /* CID_Face */\r
-  {\r
-    CID_Face   face = (CID_Face)cidface;\r
-    FT_Memory  memory;\r
-\r
-\r
-    if ( face )\r
-    {\r
-      CID_FaceInfo  cid  = &face->cid;\r
-      PS_FontInfo   info = &cid->font_info;\r
-\r
-\r
-      memory = cidface->memory;\r
-\r
-      /* release subrs */\r
-      if ( face->subrs )\r
-      {\r
-        FT_Int  n;\r
-\r
-\r
-        for ( n = 0; n < cid->num_dicts; n++ )\r
-        {\r
-          CID_Subrs  subr = face->subrs + n;\r
-\r
-\r
-          if ( subr->code )\r
-          {\r
-            FT_FREE( subr->code[0] );\r
-            FT_FREE( subr->code );\r
-          }\r
-        }\r
-\r
-        FT_FREE( face->subrs );\r
-      }\r
-\r
-      /* release FontInfo strings */\r
-      FT_FREE( info->version );\r
-      FT_FREE( info->notice );\r
-      FT_FREE( info->full_name );\r
-      FT_FREE( info->family_name );\r
-      FT_FREE( info->weight );\r
-\r
-      /* release font dictionaries */\r
-      FT_FREE( cid->font_dicts );\r
-      cid->num_dicts = 0;\r
-\r
-      /* release other strings */\r
-      FT_FREE( cid->cid_font_name );\r
-      FT_FREE( cid->registry );\r
-      FT_FREE( cid->ordering );\r
-\r
-      cidface->family_name = 0;\r
-      cidface->style_name  = 0;\r
-\r
-      FT_FREE( face->binary_data );\r
-      FT_FREE( face->cid_stream );\r
-    }\r
-  }\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /* <Function>                                                            */\r
-  /*    cid_face_init                                                      */\r
-  /*                                                                       */\r
-  /* <Description>                                                         */\r
-  /*    Initializes a given CID face object.                               */\r
-  /*                                                                       */\r
-  /* <Input>                                                               */\r
-  /*    stream     :: The source font stream.                              */\r
-  /*                                                                       */\r
-  /*    face_index :: The index of the font face in the resource.          */\r
-  /*                                                                       */\r
-  /*    num_params :: Number of additional generic parameters.  Ignored.   */\r
-  /*                                                                       */\r
-  /*    params     :: Additional generic parameters.  Ignored.             */\r
-  /*                                                                       */\r
-  /* <InOut>                                                               */\r
-  /*    face       :: The newly built face object.                         */\r
-  /*                                                                       */\r
-  /* <Return>                                                              */\r
-  /*    FreeType error code.  0 means success.                             */\r
-  /*                                                                       */\r
-  FT_LOCAL_DEF( FT_Error )\r
-  cid_face_init( FT_Stream      stream,\r
-                 FT_Face        cidface,        /* CID_Face */\r
-                 FT_Int         face_index,\r
-                 FT_Int         num_params,\r
-                 FT_Parameter*  params )\r
-  {\r
-    CID_Face          face = (CID_Face)cidface;\r
-    FT_Error          error;\r
-    PSAux_Service     psaux;\r
-    PSHinter_Service  pshinter;\r
-\r
-    FT_UNUSED( num_params );\r
-    FT_UNUSED( params );\r
-    FT_UNUSED( stream );\r
-\r
-\r
-    cidface->num_faces = 1;\r
-\r
-    psaux = (PSAux_Service)face->psaux;\r
-    if ( !psaux )\r
-    {\r
-      psaux = (PSAux_Service)FT_Get_Module_Interface(\r
-                FT_FACE_LIBRARY( face ), "psaux" );\r
-\r
-      face->psaux = psaux;\r
-    }\r
-\r
-    pshinter = (PSHinter_Service)face->pshinter;\r
-    if ( !pshinter )\r
-    {\r
-      pshinter = (PSHinter_Service)FT_Get_Module_Interface(\r
-                   FT_FACE_LIBRARY( face ), "pshinter" );\r
-\r
-      face->pshinter = pshinter;\r
-    }\r
-\r
-    /* open the tokenizer; this will also check the font format */\r
-    if ( FT_STREAM_SEEK( 0 ) )\r
-      goto Exit;\r
-\r
-    error = cid_face_open( face, face_index );\r
-    if ( error )\r
-      goto Exit;\r
-\r
-    /* if we just wanted to check the format, leave successfully now */\r
-    if ( face_index < 0 )\r
-      goto Exit;\r
-\r
-    /* check the face index */\r
-    if ( face_index != 0 )\r
-    {\r
-      FT_ERROR(( "cid_face_init: invalid face index\n" ));\r
-      error = CID_Err_Invalid_Argument;\r
-      goto Exit;\r
-    }\r
-\r
-    /* now load the font program into the face object */\r
-\r
-    /* initialize the face object fields */\r
-\r
-    /* set up root face fields */\r
-    {\r
-      CID_FaceInfo  cid  = &face->cid;\r
-      PS_FontInfo   info = &cid->font_info;\r
-\r
-\r
-      cidface->num_glyphs   = cid->cid_count;\r
-      cidface->num_charmaps = 0;\r
-\r
-      cidface->face_index = face_index;\r
-      cidface->face_flags = FT_FACE_FLAG_SCALABLE   | /* scalable outlines */\r
-                            FT_FACE_FLAG_HORIZONTAL | /* horizontal data   */\r
-                            FT_FACE_FLAG_HINTER;      /* has native hinter */\r
-\r
-      if ( info->is_fixed_pitch )\r
-        cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;\r
-\r
-      /* XXX: TODO: add kerning with .afm support */\r
-\r
-      /* get style name -- be careful, some broken fonts only */\r
-      /* have a /FontName dictionary entry!                   */\r
-      cidface->family_name = info->family_name;\r
-      /* assume "Regular" style if we don't know better */\r
-      cidface->style_name = (char *)"Regular";\r
-      if ( cidface->family_name )\r
-      {\r
-        char*  full   = info->full_name;\r
-        char*  family = cidface->family_name;\r
-\r
-\r
-        if ( full )\r
-        {\r
-          while ( *full )\r
-          {\r
-            if ( *full == *family )\r
-            {\r
-              family++;\r
-              full++;\r
-            }\r
-            else\r
-            {\r
-              if ( *full == ' ' || *full == '-' )\r
-                full++;\r
-              else if ( *family == ' ' || *family == '-' )\r
-                family++;\r
-              else\r
-              {\r
-                if ( !*family )\r
-                  cidface->style_name = full;\r
-                break;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-      else\r
-      {\r
-        /* do we have a `/FontName'? */\r
-        if ( cid->cid_font_name )\r
-          cidface->family_name = cid->cid_font_name;\r
-      }\r
-\r
-      /* compute style flags */\r
-      cidface->style_flags = 0;\r
-      if ( info->italic_angle )\r
-        cidface->style_flags |= FT_STYLE_FLAG_ITALIC;\r
-      if ( info->weight )\r
-      {\r
-        if ( !ft_strcmp( info->weight, "Bold"  ) ||\r
-             !ft_strcmp( info->weight, "Black" ) )\r
-          cidface->style_flags |= FT_STYLE_FLAG_BOLD;\r
-      }\r
-\r
-      /* no embedded bitmap support */\r
-      cidface->num_fixed_sizes = 0;\r
-      cidface->available_sizes = 0;\r
-\r
-      cidface->bbox.xMin =   cid->font_bbox.xMin             >> 16;\r
-      cidface->bbox.yMin =   cid->font_bbox.yMin             >> 16;\r
-      cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;\r
-      cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;\r
-\r
-      if ( !cidface->units_per_EM )\r
-        cidface->units_per_EM = 1000;\r
-\r
-      cidface->ascender  = (FT_Short)( cidface->bbox.yMax );\r
-      cidface->descender = (FT_Short)( cidface->bbox.yMin );\r
-\r
-      cidface->height = (FT_Short)( ( cidface->units_per_EM * 12 ) / 10 );\r
-      if ( cidface->height < cidface->ascender - cidface->descender )\r
-        cidface->height = (FT_Short)( cidface->ascender - cidface->descender );\r
-\r
-      cidface->underline_position  = (FT_Short)info->underline_position;\r
-      cidface->underline_thickness = (FT_Short)info->underline_thickness;\r
-    }\r
-\r
-  Exit:\r
-    return error;\r
-  }\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /* <Function>                                                            */\r
-  /*    cid_driver_init                                                    */\r
-  /*                                                                       */\r
-  /* <Description>                                                         */\r
-  /*    Initializes a given CID driver object.                             */\r
-  /*                                                                       */\r
-  /* <Input>                                                               */\r
-  /*    driver :: A handle to the target driver object.                    */\r
-  /*                                                                       */\r
-  /* <Return>                                                              */\r
-  /*    FreeType error code.  0 means success.                             */\r
-  /*                                                                       */\r
-  FT_LOCAL_DEF( FT_Error )\r
-  cid_driver_init( FT_Module  driver )\r
-  {\r
-    FT_UNUSED( driver );\r
-\r
-    return CID_Err_Ok;\r
-  }\r
-\r
-\r
-  /*************************************************************************/\r
-  /*                                                                       */\r
-  /* <Function>                                                            */\r
-  /*    cid_driver_done                                                    */\r
-  /*                                                                       */\r
-  /* <Description>                                                         */\r
-  /*    Finalizes a given CID driver.                                      */\r
-  /*                                                                       */\r
-  /* <Input>                                                               */\r
-  /*    driver :: A handle to the target CID driver.                       */\r
-  /*                                                                       */\r
-  FT_LOCAL_DEF( void )\r
-  cid_driver_done( FT_Module  driver )\r
-  {\r
-    FT_UNUSED( driver );\r
-  }\r
-\r
-\r
-/* END */\r
+/***************************************************************************/
+/*                                                                         */
+/*  cidobjs.c                                                              */
+/*                                                                         */
+/*    CID objects manager (body).                                          */
+/*                                                                         */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by                   */
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_STREAM_H
+
+#include "cidgload.h"
+#include "cidload.h"
+
+#include FT_SERVICE_POSTSCRIPT_CMAPS_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+
+#include "ciderrs.h"
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
+  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
+  /* messages during execution.                                            */
+  /*                                                                       */
+#undef  FT_COMPONENT
+#define FT_COMPONENT  trace_cidobjs
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*                            SLOT  FUNCTIONS                            */
+  /*                                                                       */
+  /*************************************************************************/
+
+  FT_LOCAL_DEF( void )
+  cid_slot_done( FT_GlyphSlot  slot )
+  {
+    slot->internal->glyph_hints = 0;
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
+  cid_slot_init( FT_GlyphSlot  slot )
+  {
+    CID_Face          face;
+    PSHinter_Service  pshinter;
+
+
+    face     = (CID_Face)slot->face;
+    pshinter = (PSHinter_Service)face->pshinter;
+
+    if ( pshinter )
+    {
+      FT_Module  module;
+
+
+      module = FT_Get_Module( slot->face->driver->root.library,
+                              "pshinter" );
+      if ( module )
+      {
+        T1_Hints_Funcs  funcs;
+
+
+        funcs = pshinter->get_t1_funcs( module );
+        slot->internal->glyph_hints = (void*)funcs;
+      }
+    }
+
+    return 0;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*                           SIZE  FUNCTIONS                             */
+  /*                                                                       */
+  /*************************************************************************/
+
+
+  static PSH_Globals_Funcs
+  cid_size_get_globals_funcs( CID_Size  size )
+  {
+    CID_Face          face     = (CID_Face)size->root.face;
+    PSHinter_Service  pshinter = (PSHinter_Service)face->pshinter;
+    FT_Module         module;
+
+
+    module = FT_Get_Module( size->root.face->driver->root.library,
+                            "pshinter" );
+    return ( module && pshinter && pshinter->get_globals_funcs )
+           ? pshinter->get_globals_funcs( module )
+           : 0;
+  }
+
+
+  FT_LOCAL_DEF( void )
+  cid_size_done( FT_Size  cidsize )         /* CID_Size */
+  {
+    CID_Size  size = (CID_Size)cidsize;
+
+
+    if ( cidsize->internal )
+    {
+      PSH_Globals_Funcs  funcs;
+
+
+      funcs = cid_size_get_globals_funcs( size );
+      if ( funcs )
+        funcs->destroy( (PSH_Globals)cidsize->internal );
+
+      cidsize->internal = 0;
+    }
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
+  cid_size_init( FT_Size  cidsize )     /* CID_Size */
+  {
+    CID_Size           size  = (CID_Size)cidsize;
+    FT_Error           error = 0;
+    PSH_Globals_Funcs  funcs = cid_size_get_globals_funcs( size );
+
+
+    if ( funcs )
+    {
+      PSH_Globals   globals;
+      CID_Face      face = (CID_Face)cidsize->face;
+      CID_FaceDict  dict = face->cid.font_dicts + face->root.face_index;
+      PS_Private    priv = &dict->private_dict;
+
+
+      error = funcs->create( cidsize->face->memory, priv, &globals );
+      if ( !error )
+        cidsize->internal = (FT_Size_Internal)(void*)globals;
+    }
+
+    return error;
+  }
+
+
+  FT_LOCAL( FT_Error )
+  cid_size_request( FT_Size          size,
+                    FT_Size_Request  req )
+  {
+    PSH_Globals_Funcs  funcs;
+
+
+    FT_Request_Metrics( size->face, req );
+
+    funcs = cid_size_get_globals_funcs( (CID_Size)size );
+
+    if ( funcs )
+      funcs->set_scale( (PSH_Globals)size->internal,
+                        size->metrics.x_scale,
+                        size->metrics.y_scale,
+                        0, 0 );
+
+    return CID_Err_Ok;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /*                           FACE  FUNCTIONS                             */
+  /*                                                                       */
+  /*************************************************************************/
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    cid_face_done                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Finalizes a given face object.                                     */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face :: A pointer to the face object to destroy.                   */
+  /*                                                                       */
+  FT_LOCAL_DEF( void )
+  cid_face_done( FT_Face  cidface )         /* CID_Face */
+  {
+    CID_Face   face = (CID_Face)cidface;
+    FT_Memory  memory;
+
+
+    if ( face )
+    {
+      CID_FaceInfo  cid  = &face->cid;
+      PS_FontInfo   info = &cid->font_info;
+
+
+      memory = cidface->memory;
+
+      /* release subrs */
+      if ( face->subrs )
+      {
+        FT_Int  n;
+
+
+        for ( n = 0; n < cid->num_dicts; n++ )
+        {
+          CID_Subrs  subr = face->subrs + n;
+
+
+          if ( subr->code )
+          {
+            FT_FREE( subr->code[0] );
+            FT_FREE( subr->code );
+          }
+        }
+
+        FT_FREE( face->subrs );
+      }
+
+      /* release FontInfo strings */
+      FT_FREE( info->version );
+      FT_FREE( info->notice );
+      FT_FREE( info->full_name );
+      FT_FREE( info->family_name );
+      FT_FREE( info->weight );
+
+      /* release font dictionaries */
+      FT_FREE( cid->font_dicts );
+      cid->num_dicts = 0;
+
+      /* release other strings */
+      FT_FREE( cid->cid_font_name );
+      FT_FREE( cid->registry );
+      FT_FREE( cid->ordering );
+
+      cidface->family_name = 0;
+      cidface->style_name  = 0;
+
+      FT_FREE( face->binary_data );
+      FT_FREE( face->cid_stream );
+    }
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    cid_face_init                                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Initializes a given CID face object.                               */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    stream     :: The source font stream.                              */
+  /*                                                                       */
+  /*    face_index :: The index of the font face in the resource.          */
+  /*                                                                       */
+  /*    num_params :: Number of additional generic parameters.  Ignored.   */
+  /*                                                                       */
+  /*    params     :: Additional generic parameters.  Ignored.             */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    face       :: The newly built face object.                         */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  FT_LOCAL_DEF( FT_Error )
+  cid_face_init( FT_Stream      stream,
+                 FT_Face        cidface,        /* CID_Face */
+                 FT_Int         face_index,
+                 FT_Int         num_params,
+                 FT_Parameter*  params )
+  {
+    CID_Face          face = (CID_Face)cidface;
+    FT_Error          error;
+    PSAux_Service     psaux;
+    PSHinter_Service  pshinter;
+
+    FT_UNUSED( num_params );
+    FT_UNUSED( params );
+    FT_UNUSED( stream );
+
+
+    cidface->num_faces = 1;
+
+    psaux = (PSAux_Service)face->psaux;
+    if ( !psaux )
+    {
+      psaux = (PSAux_Service)FT_Get_Module_Interface(
+                FT_FACE_LIBRARY( face ), "psaux" );
+
+      face->psaux = psaux;
+    }
+
+    pshinter = (PSHinter_Service)face->pshinter;
+    if ( !pshinter )
+    {
+      pshinter = (PSHinter_Service)FT_Get_Module_Interface(
+                   FT_FACE_LIBRARY( face ), "pshinter" );
+
+      face->pshinter = pshinter;
+    }
+
+    /* open the tokenizer; this will also check the font format */
+    if ( FT_STREAM_SEEK( 0 ) )
+      goto Exit;
+
+    error = cid_face_open( face, face_index );
+    if ( error )
+      goto Exit;
+
+    /* if we just wanted to check the format, leave successfully now */
+    if ( face_index < 0 )
+      goto Exit;
+
+    /* check the face index */
+    if ( face_index != 0 )
+    {
+      FT_ERROR(( "cid_face_init: invalid face index\n" ));
+      error = CID_Err_Invalid_Argument;
+      goto Exit;
+    }
+
+    /* now load the font program into the face object */
+
+    /* initialize the face object fields */
+
+    /* set up root face fields */
+    {
+      CID_FaceInfo  cid  = &face->cid;
+      PS_FontInfo   info = &cid->font_info;
+
+
+      cidface->num_glyphs   = cid->cid_count;
+      cidface->num_charmaps = 0;
+
+      cidface->face_index = face_index;
+      cidface->face_flags = FT_FACE_FLAG_SCALABLE   | /* scalable outlines */
+                            FT_FACE_FLAG_HORIZONTAL | /* horizontal data   */
+                            FT_FACE_FLAG_HINTER;      /* has native hinter */
+
+      if ( info->is_fixed_pitch )
+        cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+
+      /* XXX: TODO: add kerning with .afm support */
+
+      /* get style name -- be careful, some broken fonts only */
+      /* have a /FontName dictionary entry!                   */
+      cidface->family_name = info->family_name;
+      /* assume "Regular" style if we don't know better */
+      cidface->style_name = (char *)"Regular";
+      if ( cidface->family_name )
+      {
+        char*  full   = info->full_name;
+        char*  family = cidface->family_name;
+
+
+        if ( full )
+        {
+          while ( *full )
+          {
+            if ( *full == *family )
+            {
+              family++;
+              full++;
+            }
+            else
+            {
+              if ( *full == ' ' || *full == '-' )
+                full++;
+              else if ( *family == ' ' || *family == '-' )
+                family++;
+              else
+              {
+                if ( !*family )
+                  cidface->style_name = full;
+                break;
+              }
+            }
+          }
+        }
+      }
+      else
+      {
+        /* do we have a `/FontName'? */
+        if ( cid->cid_font_name )
+          cidface->family_name = cid->cid_font_name;
+      }
+
+      /* compute style flags */
+      cidface->style_flags = 0;
+      if ( info->italic_angle )
+        cidface->style_flags |= FT_STYLE_FLAG_ITALIC;
+      if ( info->weight )
+      {
+        if ( !ft_strcmp( info->weight, "Bold"  ) ||
+             !ft_strcmp( info->weight, "Black" ) )
+          cidface->style_flags |= FT_STYLE_FLAG_BOLD;
+      }
+
+      /* no embedded bitmap support */
+      cidface->num_fixed_sizes = 0;
+      cidface->available_sizes = 0;
+
+      cidface->bbox.xMin =   cid->font_bbox.xMin             >> 16;
+      cidface->bbox.yMin =   cid->font_bbox.yMin             >> 16;
+      cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
+      cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
+
+      if ( !cidface->units_per_EM )
+        cidface->units_per_EM = 1000;
+
+      cidface->ascender  = (FT_Short)( cidface->bbox.yMax );
+      cidface->descender = (FT_Short)( cidface->bbox.yMin );
+
+      cidface->height = (FT_Short)( ( cidface->units_per_EM * 12 ) / 10 );
+      if ( cidface->height < cidface->ascender - cidface->descender )
+        cidface->height = (FT_Short)( cidface->ascender - cidface->descender );
+
+      cidface->underline_position  = (FT_Short)info->underline_position;
+      cidface->underline_thickness = (FT_Short)info->underline_thickness;
+    }
+
+  Exit:
+    return error;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    cid_driver_init                                                    */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Initializes a given CID driver object.                             */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    driver :: A handle to the target driver object.                    */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0 means success.                             */
+  /*                                                                       */
+  FT_LOCAL_DEF( FT_Error )
+  cid_driver_init( FT_Module  driver )
+  {
+    FT_UNUSED( driver );
+
+    return CID_Err_Ok;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    cid_driver_done                                                    */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Finalizes a given CID driver.                                      */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    driver :: A handle to the target CID driver.                       */
+  /*                                                                       */
+  FT_LOCAL_DEF( void )
+  cid_driver_done( FT_Module  driver )
+  {
+    FT_UNUSED( driver );
+  }
+
+
+/* END */