< prev index next >

src/java.desktop/share/native/libfreetype/src/type1/t1objs.c

Print this page


   1 /***************************************************************************/
   2 /*                                                                         */
   3 /*  t1objs.c                                                               */
   4 /*                                                                         */
   5 /*    Type 1 objects manager (body).                                       */
   6 /*                                                                         */
   7 /*  Copyright 1996-2018 by                                                 */
   8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
   9 /*                                                                         */
  10 /*  This file is part of the FreeType project, and may only be used,       */
  11 /*  modified, and distributed under the terms of the FreeType project      */
  12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  13 /*  this file you indicate that you have read the license and              */
  14 /*  understand and accept it fully.                                        */
  15 /*                                                                         */
  16 /***************************************************************************/
  17 
  18 
  19 #include <ft2build.h>
  20 #include FT_INTERNAL_CALC_H
  21 #include FT_INTERNAL_DEBUG_H
  22 #include FT_INTERNAL_STREAM_H
  23 #include FT_TRUETYPE_IDS_H
  24 #include FT_DRIVER_H
  25 
  26 #include "t1gload.h"
  27 #include "t1load.h"
  28 
  29 #include "t1errors.h"
  30 
  31 #ifndef T1_CONFIG_OPTION_NO_AFM
  32 #include "t1afm.h"
  33 #endif
  34 
  35 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
  36 #include FT_INTERNAL_POSTSCRIPT_AUX_H
  37 
  38 
  39   /*************************************************************************/
  40   /*                                                                       */
  41   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
  42   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
  43   /* messages during execution.                                            */
  44   /*                                                                       */
  45 #undef  FT_COMPONENT
  46 #define FT_COMPONENT  trace_t1objs
  47 
  48 
  49   /*************************************************************************/
  50   /*                                                                       */
  51   /*                            SIZE FUNCTIONS                             */
  52   /*                                                                       */
  53   /*************************************************************************/
  54 
  55 
  56   static PSH_Globals_Funcs
  57   T1_Size_Get_Globals_Funcs( T1_Size  size )
  58   {
  59     T1_Face           face     = (T1_Face)size->root.face;
  60     PSHinter_Service  pshinter = (PSHinter_Service)face->pshinter;
  61     FT_Module         module;
  62 
  63 
  64     module = FT_Get_Module( size->root.face->driver->root.library,
  65                             "pshinter" );
  66     return ( module && pshinter && pshinter->get_globals_funcs )
  67            ? pshinter->get_globals_funcs( module )
  68            : 0;
  69   }
  70 
  71 
  72   FT_LOCAL_DEF( void )
  73   T1_Size_Done( FT_Size  t1size )          /* T1_Size */


 116   FT_LOCAL_DEF( FT_Error )
 117   T1_Size_Request( FT_Size          t1size,     /* T1_Size */
 118                    FT_Size_Request  req )
 119   {
 120     T1_Size            size  = (T1_Size)t1size;
 121     PSH_Globals_Funcs  funcs = T1_Size_Get_Globals_Funcs( size );
 122 
 123 
 124     FT_Request_Metrics( size->root.face, req );
 125 
 126     if ( funcs )
 127       funcs->set_scale( (PSH_Globals)t1size->internal->module_data,
 128                         size->root.metrics.x_scale,
 129                         size->root.metrics.y_scale,
 130                         0, 0 );
 131 
 132     return FT_Err_Ok;
 133   }
 134 
 135 
 136   /*************************************************************************/
 137   /*                                                                       */
 138   /*                            SLOT  FUNCTIONS                            */
 139   /*                                                                       */
 140   /*************************************************************************/
 141 
 142   FT_LOCAL_DEF( void )
 143   T1_GlyphSlot_Done( FT_GlyphSlot  slot )
 144   {
 145     slot->internal->glyph_hints = NULL;
 146   }
 147 
 148 
 149   FT_LOCAL_DEF( FT_Error )
 150   T1_GlyphSlot_Init( FT_GlyphSlot  slot )
 151   {
 152     T1_Face           face;
 153     PSHinter_Service  pshinter;
 154 
 155 
 156     face     = (T1_Face)slot->face;
 157     pshinter = (PSHinter_Service)face->pshinter;
 158 
 159     if ( pshinter )
 160     {
 161       FT_Module  module;
 162 
 163 
 164       module = FT_Get_Module( slot->face->driver->root.library,
 165                               "pshinter" );
 166       if ( module )
 167       {
 168         T1_Hints_Funcs  funcs;
 169 
 170 
 171         funcs = pshinter->get_t1_funcs( module );
 172         slot->internal->glyph_hints = (void*)funcs;
 173       }
 174     }
 175 
 176     return 0;
 177   }
 178 
 179 
 180   /*************************************************************************/
 181   /*                                                                       */
 182   /*                            FACE  FUNCTIONS                            */
 183   /*                                                                       */
 184   /*************************************************************************/
 185 
 186 
 187   /*************************************************************************/
 188   /*                                                                       */
 189   /* <Function>                                                            */
 190   /*    T1_Face_Done                                                       */
 191   /*                                                                       */
 192   /* <Description>                                                         */
 193   /*    The face object destructor.                                        */
 194   /*                                                                       */
 195   /* <Input>                                                               */
 196   /*    face :: A typeless pointer to the face object to destroy.          */
 197   /*                                                                       */

 198   FT_LOCAL_DEF( void )
 199   T1_Face_Done( FT_Face  t1face )         /* T1_Face */
 200   {
 201     T1_Face    face = (T1_Face)t1face;
 202     FT_Memory  memory;
 203     T1_Font    type1;
 204 
 205 
 206     if ( !face )
 207       return;
 208 
 209     memory = face->root.memory;
 210     type1  = &face->type1;
 211 
 212 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
 213     /* release multiple masters information */
 214     FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
 215 
 216     if ( face->buildchar )
 217     {


 257     FT_FREE( type1->font_name );
 258 
 259 #ifndef T1_CONFIG_OPTION_NO_AFM
 260     /* release afm data if present */
 261     if ( face->afm_data )
 262       T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data );
 263 #endif
 264 
 265     /* release unicode map, if any */
 266 #if 0
 267     FT_FREE( face->unicode_map_rec.maps );
 268     face->unicode_map_rec.num_maps = 0;
 269     face->unicode_map              = NULL;
 270 #endif
 271 
 272     face->root.family_name = NULL;
 273     face->root.style_name  = NULL;
 274   }
 275 
 276 
 277   /*************************************************************************/
 278   /*                                                                       */
 279   /* <Function>                                                            */
 280   /*    T1_Face_Init                                                       */
 281   /*                                                                       */
 282   /* <Description>                                                         */
 283   /*    The face object constructor.                                       */
 284   /*                                                                       */
 285   /* <Input>                                                               */
 286   /*    stream     ::  input stream where to load font data.               */
 287   /*                                                                       */
 288   /*    face_index :: The index of the font face in the resource.          */
 289   /*                                                                       */
 290   /*    num_params :: Number of additional generic parameters.  Ignored.   */
 291   /*                                                                       */
 292   /*    params     :: Additional generic parameters.  Ignored.             */
 293   /*                                                                       */
 294   /* <InOut>                                                               */
 295   /*    face       :: The face record to build.                            */
 296   /*                                                                       */
 297   /* <Return>                                                              */
 298   /*    FreeType error code.  0 means success.                             */
 299   /*                                                                       */





 300   FT_LOCAL_DEF( FT_Error )
 301   T1_Face_Init( FT_Stream      stream,
 302                 FT_Face        t1face,          /* T1_Face */
 303                 FT_Int         face_index,
 304                 FT_Int         num_params,
 305                 FT_Parameter*  params )
 306   {
 307     T1_Face             face = (T1_Face)t1face;
 308     FT_Error            error;
 309     FT_Service_PsCMaps  psnames;
 310     PSAux_Service       psaux;
 311     T1_Font             type1 = &face->type1;
 312     PS_FontInfo         info = &type1->font_info;
 313 
 314     FT_UNUSED( num_params );
 315     FT_UNUSED( params );
 316     FT_UNUSED( stream );
 317 
 318 
 319     face->root.num_faces = 1;


 324     face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
 325                                            "psaux" );
 326     psaux = (PSAux_Service)face->psaux;
 327     if ( !psaux )
 328     {
 329       FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
 330       error = FT_THROW( Missing_Module );
 331       goto Exit;
 332     }
 333 
 334     face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
 335                                               "pshinter" );
 336 
 337     FT_TRACE2(( "Type 1 driver\n" ));
 338 
 339     /* open the tokenizer; this will also check the font format */
 340     error = T1_Open_Face( face );
 341     if ( error )
 342       goto Exit;
 343 




 344     /* if we just wanted to check the format, leave successfully now */
 345     if ( face_index < 0 )
 346       goto Exit;
 347 
 348     /* check the face index */
 349     if ( ( face_index & 0xFFFF ) > 0 )
 350     {
 351       FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
 352       error = FT_THROW( Invalid_Argument );
 353       goto Exit;
 354     }
 355 
 356     /* now load the font program into the face object */
 357 
 358     /* initialize the face object fields */
 359 
 360     /* set up root face fields */
 361     {
 362       FT_Face  root = (FT_Face)&face->root;
 363 


 499     {
 500       FT_Face  root = &face->root;
 501 
 502 
 503       if ( psnames )
 504       {
 505         FT_CharMapRec    charmap;
 506         T1_CMap_Classes  cmap_classes = psaux->t1_cmap_classes;
 507         FT_CMap_Class    clazz;
 508 
 509 
 510         charmap.face = root;
 511 
 512         /* first of all, try to synthesize a Unicode charmap */
 513         charmap.platform_id = TT_PLATFORM_MICROSOFT;
 514         charmap.encoding_id = TT_MS_ID_UNICODE_CS;
 515         charmap.encoding    = FT_ENCODING_UNICODE;
 516 
 517         error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
 518         if ( error                                      &&
 519              FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )

 520           goto Exit;
 521         error = FT_Err_Ok;
 522 
 523         /* now, generate an Adobe Standard encoding when appropriate */
 524         charmap.platform_id = TT_PLATFORM_ADOBE;
 525         clazz               = NULL;
 526 
 527         switch ( type1->encoding_type )
 528         {
 529         case T1_ENCODING_TYPE_STANDARD:
 530           charmap.encoding    = FT_ENCODING_ADOBE_STANDARD;
 531           charmap.encoding_id = TT_ADOBE_ID_STANDARD;
 532           clazz               = cmap_classes->standard;
 533           break;
 534 
 535         case T1_ENCODING_TYPE_EXPERT:
 536           charmap.encoding    = FT_ENCODING_ADOBE_EXPERT;
 537           charmap.encoding_id = TT_ADOBE_ID_EXPERT;
 538           clazz               = cmap_classes->expert;
 539           break;


 547         case T1_ENCODING_TYPE_ISOLATIN1:
 548           charmap.encoding    = FT_ENCODING_ADOBE_LATIN_1;
 549           charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
 550           clazz               = cmap_classes->unicode;
 551           break;
 552 
 553         default:
 554           ;
 555         }
 556 
 557         if ( clazz )
 558           error = FT_CMap_New( clazz, NULL, &charmap, NULL );
 559       }
 560     }
 561 
 562   Exit:
 563     return error;
 564   }
 565 
 566 
 567   /*************************************************************************/
 568   /*                                                                       */
 569   /* <Function>                                                            */
 570   /*    T1_Driver_Init                                                     */
 571   /*                                                                       */
 572   /* <Description>                                                         */
 573   /*    Initializes a given Type 1 driver object.                          */
 574   /*                                                                       */
 575   /* <Input>                                                               */
 576   /*    driver :: A handle to the target driver object.                    */
 577   /*                                                                       */
 578   /* <Return>                                                              */
 579   /*    FreeType error code.  0 means success.                             */
 580   /*                                                                       */

 581   FT_LOCAL_DEF( FT_Error )
 582   T1_Driver_Init( FT_Module  module )
 583   {
 584     PS_Driver  driver = (PS_Driver)module;
 585 
 586     FT_UInt32  seed;
 587 
 588 
 589     /* set default property values, cf. `ftt1drv.h' */
 590 #ifdef T1_CONFIG_OPTION_OLD_ENGINE
 591     driver->hinting_engine = FT_HINTING_FREETYPE;
 592 #else
 593     driver->hinting_engine = FT_HINTING_ADOBE;
 594 #endif
 595 
 596     driver->no_stem_darkening = TRUE;
 597 
 598     driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
 599     driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
 600     driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;


 603     driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
 604     driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
 605     driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
 606 
 607     /* compute random seed from some memory addresses */
 608     seed = (FT_UInt32)( (FT_Offset)(char*)&seed          ^
 609                         (FT_Offset)(char*)&module        ^
 610                         (FT_Offset)(char*)module->memory );
 611     seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
 612 
 613     driver->random_seed = (FT_Int32)seed;
 614     if ( driver->random_seed < 0 )
 615       driver->random_seed = -driver->random_seed;
 616     else if ( driver->random_seed == 0 )
 617       driver->random_seed = 123456789;
 618 
 619     return FT_Err_Ok;
 620   }
 621 
 622 
 623   /*************************************************************************/
 624   /*                                                                       */
 625   /* <Function>                                                            */
 626   /*    T1_Driver_Done                                                     */
 627   /*                                                                       */
 628   /* <Description>                                                         */
 629   /*    Finalizes a given Type 1 driver.                                   */
 630   /*                                                                       */
 631   /* <Input>                                                               */
 632   /*    driver :: A handle to the target Type 1 driver.                    */
 633   /*                                                                       */

 634   FT_LOCAL_DEF( void )
 635   T1_Driver_Done( FT_Module  driver )
 636   {
 637     FT_UNUSED( driver );
 638   }
 639 
 640 
 641 /* END */
   1 /****************************************************************************
   2  *
   3  * t1objs.c
   4  *
   5  *   Type 1 objects manager (body).
   6  *
   7  * Copyright (C) 1996-2019 by
   8  * David Turner, Robert Wilhelm, and Werner Lemberg.
   9  *
  10  * This file is part of the FreeType project, and may only be used,
  11  * modified, and distributed under the terms of the FreeType project
  12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
  13  * this file you indicate that you have read the license and
  14  * understand and accept it fully.
  15  *
  16  */
  17 
  18 
  19 #include <ft2build.h>
  20 #include FT_INTERNAL_CALC_H
  21 #include FT_INTERNAL_DEBUG_H
  22 #include FT_INTERNAL_STREAM_H
  23 #include FT_TRUETYPE_IDS_H
  24 #include FT_DRIVER_H
  25 
  26 #include "t1gload.h"
  27 #include "t1load.h"
  28 
  29 #include "t1errors.h"
  30 
  31 #ifndef T1_CONFIG_OPTION_NO_AFM
  32 #include "t1afm.h"
  33 #endif
  34 
  35 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
  36 #include FT_INTERNAL_POSTSCRIPT_AUX_H
  37 
  38 
  39   /**************************************************************************
  40    *
  41    * The macro FT_COMPONENT is used in trace mode.  It is an implicit
  42    * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
  43    * messages during execution.
  44    */
  45 #undef  FT_COMPONENT
  46 #define FT_COMPONENT  t1objs
  47 
  48 
  49   /**************************************************************************
  50    *
  51    *                           SIZE FUNCTIONS
  52    *
  53    */
  54 
  55 
  56   static PSH_Globals_Funcs
  57   T1_Size_Get_Globals_Funcs( T1_Size  size )
  58   {
  59     T1_Face           face     = (T1_Face)size->root.face;
  60     PSHinter_Service  pshinter = (PSHinter_Service)face->pshinter;
  61     FT_Module         module;
  62 
  63 
  64     module = FT_Get_Module( size->root.face->driver->root.library,
  65                             "pshinter" );
  66     return ( module && pshinter && pshinter->get_globals_funcs )
  67            ? pshinter->get_globals_funcs( module )
  68            : 0;
  69   }
  70 
  71 
  72   FT_LOCAL_DEF( void )
  73   T1_Size_Done( FT_Size  t1size )          /* T1_Size */


 116   FT_LOCAL_DEF( FT_Error )
 117   T1_Size_Request( FT_Size          t1size,     /* T1_Size */
 118                    FT_Size_Request  req )
 119   {
 120     T1_Size            size  = (T1_Size)t1size;
 121     PSH_Globals_Funcs  funcs = T1_Size_Get_Globals_Funcs( size );
 122 
 123 
 124     FT_Request_Metrics( size->root.face, req );
 125 
 126     if ( funcs )
 127       funcs->set_scale( (PSH_Globals)t1size->internal->module_data,
 128                         size->root.metrics.x_scale,
 129                         size->root.metrics.y_scale,
 130                         0, 0 );
 131 
 132     return FT_Err_Ok;
 133   }
 134 
 135 
 136   /**************************************************************************
 137    *
 138    *                           SLOT  FUNCTIONS
 139    *
 140    */
 141 
 142   FT_LOCAL_DEF( void )
 143   T1_GlyphSlot_Done( FT_GlyphSlot  slot )
 144   {
 145     slot->internal->glyph_hints = NULL;
 146   }
 147 
 148 
 149   FT_LOCAL_DEF( FT_Error )
 150   T1_GlyphSlot_Init( FT_GlyphSlot  slot )
 151   {
 152     T1_Face           face;
 153     PSHinter_Service  pshinter;
 154 
 155 
 156     face     = (T1_Face)slot->face;
 157     pshinter = (PSHinter_Service)face->pshinter;
 158 
 159     if ( pshinter )
 160     {
 161       FT_Module  module;
 162 
 163 
 164       module = FT_Get_Module( slot->face->driver->root.library,
 165                               "pshinter" );
 166       if ( module )
 167       {
 168         T1_Hints_Funcs  funcs;
 169 
 170 
 171         funcs = pshinter->get_t1_funcs( module );
 172         slot->internal->glyph_hints = (void*)funcs;
 173       }
 174     }
 175 
 176     return 0;
 177   }
 178 
 179 
 180   /**************************************************************************
 181    *
 182    *                           FACE  FUNCTIONS
 183    *
 184    */
 185 
 186 
 187   /**************************************************************************
 188    *
 189    * @Function:
 190    *   T1_Face_Done
 191    *
 192    * @Description:
 193    *   The face object destructor.
 194    *
 195    * @Input:
 196    *   face ::
 197    *     A typeless pointer to the face object to destroy.
 198    */
 199   FT_LOCAL_DEF( void )
 200   T1_Face_Done( FT_Face  t1face )         /* T1_Face */
 201   {
 202     T1_Face    face = (T1_Face)t1face;
 203     FT_Memory  memory;
 204     T1_Font    type1;
 205 
 206 
 207     if ( !face )
 208       return;
 209 
 210     memory = face->root.memory;
 211     type1  = &face->type1;
 212 
 213 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
 214     /* release multiple masters information */
 215     FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
 216 
 217     if ( face->buildchar )
 218     {


 258     FT_FREE( type1->font_name );
 259 
 260 #ifndef T1_CONFIG_OPTION_NO_AFM
 261     /* release afm data if present */
 262     if ( face->afm_data )
 263       T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data );
 264 #endif
 265 
 266     /* release unicode map, if any */
 267 #if 0
 268     FT_FREE( face->unicode_map_rec.maps );
 269     face->unicode_map_rec.num_maps = 0;
 270     face->unicode_map              = NULL;
 271 #endif
 272 
 273     face->root.family_name = NULL;
 274     face->root.style_name  = NULL;
 275   }
 276 
 277 
 278   /**************************************************************************
 279    *
 280    * @Function:
 281    *   T1_Face_Init
 282    *
 283    * @Description:
 284    *   The face object constructor.
 285    *
 286    * @Input:
 287    *   stream ::
 288    *     input stream where to load font data.
 289    *
 290    *   face_index ::
 291    *     The index of the font face in the resource.
 292    *
 293    *   num_params ::
 294    *     Number of additional generic parameters.  Ignored.
 295    *
 296    *   params ::
 297    *     Additional generic parameters.  Ignored.
 298    *
 299    * @InOut:
 300    *   face ::
 301    *     The face record to build.
 302    *
 303    * @Return:
 304    *   FreeType error code.  0 means success.
 305    */
 306   FT_LOCAL_DEF( FT_Error )
 307   T1_Face_Init( FT_Stream      stream,
 308                 FT_Face        t1face,          /* T1_Face */
 309                 FT_Int         face_index,
 310                 FT_Int         num_params,
 311                 FT_Parameter*  params )
 312   {
 313     T1_Face             face = (T1_Face)t1face;
 314     FT_Error            error;
 315     FT_Service_PsCMaps  psnames;
 316     PSAux_Service       psaux;
 317     T1_Font             type1 = &face->type1;
 318     PS_FontInfo         info = &type1->font_info;
 319 
 320     FT_UNUSED( num_params );
 321     FT_UNUSED( params );
 322     FT_UNUSED( stream );
 323 
 324 
 325     face->root.num_faces = 1;


 330     face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
 331                                            "psaux" );
 332     psaux = (PSAux_Service)face->psaux;
 333     if ( !psaux )
 334     {
 335       FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
 336       error = FT_THROW( Missing_Module );
 337       goto Exit;
 338     }
 339 
 340     face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
 341                                               "pshinter" );
 342 
 343     FT_TRACE2(( "Type 1 driver\n" ));
 344 
 345     /* open the tokenizer; this will also check the font format */
 346     error = T1_Open_Face( face );
 347     if ( error )
 348       goto Exit;
 349 
 350     FT_TRACE2(( "T1_Face_Init: %08p (index %d)\n",
 351                 face,
 352                 face_index ));
 353 
 354     /* if we just wanted to check the format, leave successfully now */
 355     if ( face_index < 0 )
 356       goto Exit;
 357 
 358     /* check the face index */
 359     if ( ( face_index & 0xFFFF ) > 0 )
 360     {
 361       FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
 362       error = FT_THROW( Invalid_Argument );
 363       goto Exit;
 364     }
 365 
 366     /* now load the font program into the face object */
 367 
 368     /* initialize the face object fields */
 369 
 370     /* set up root face fields */
 371     {
 372       FT_Face  root = (FT_Face)&face->root;
 373 


 509     {
 510       FT_Face  root = &face->root;
 511 
 512 
 513       if ( psnames )
 514       {
 515         FT_CharMapRec    charmap;
 516         T1_CMap_Classes  cmap_classes = psaux->t1_cmap_classes;
 517         FT_CMap_Class    clazz;
 518 
 519 
 520         charmap.face = root;
 521 
 522         /* first of all, try to synthesize a Unicode charmap */
 523         charmap.platform_id = TT_PLATFORM_MICROSOFT;
 524         charmap.encoding_id = TT_MS_ID_UNICODE_CS;
 525         charmap.encoding    = FT_ENCODING_UNICODE;
 526 
 527         error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
 528         if ( error                                      &&
 529              FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
 530              FT_ERR_NEQ( error, Unimplemented_Feature ) )
 531           goto Exit;
 532         error = FT_Err_Ok;
 533 
 534         /* now, generate an Adobe Standard encoding when appropriate */
 535         charmap.platform_id = TT_PLATFORM_ADOBE;
 536         clazz               = NULL;
 537 
 538         switch ( type1->encoding_type )
 539         {
 540         case T1_ENCODING_TYPE_STANDARD:
 541           charmap.encoding    = FT_ENCODING_ADOBE_STANDARD;
 542           charmap.encoding_id = TT_ADOBE_ID_STANDARD;
 543           clazz               = cmap_classes->standard;
 544           break;
 545 
 546         case T1_ENCODING_TYPE_EXPERT:
 547           charmap.encoding    = FT_ENCODING_ADOBE_EXPERT;
 548           charmap.encoding_id = TT_ADOBE_ID_EXPERT;
 549           clazz               = cmap_classes->expert;
 550           break;


 558         case T1_ENCODING_TYPE_ISOLATIN1:
 559           charmap.encoding    = FT_ENCODING_ADOBE_LATIN_1;
 560           charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
 561           clazz               = cmap_classes->unicode;
 562           break;
 563 
 564         default:
 565           ;
 566         }
 567 
 568         if ( clazz )
 569           error = FT_CMap_New( clazz, NULL, &charmap, NULL );
 570       }
 571     }
 572 
 573   Exit:
 574     return error;
 575   }
 576 
 577 
 578   /**************************************************************************
 579    *
 580    * @Function:
 581    *   T1_Driver_Init
 582    *
 583    * @Description:
 584    *   Initializes a given Type 1 driver object.
 585    *
 586    * @Input:
 587    *   driver ::
 588    *     A handle to the target driver object.
 589    *
 590    * @Return:
 591    *   FreeType error code.  0 means success.
 592    */
 593   FT_LOCAL_DEF( FT_Error )
 594   T1_Driver_Init( FT_Module  module )
 595   {
 596     PS_Driver  driver = (PS_Driver)module;
 597 
 598     FT_UInt32  seed;
 599 
 600 
 601     /* set default property values, cf. `ftt1drv.h' */
 602 #ifdef T1_CONFIG_OPTION_OLD_ENGINE
 603     driver->hinting_engine = FT_HINTING_FREETYPE;
 604 #else
 605     driver->hinting_engine = FT_HINTING_ADOBE;
 606 #endif
 607 
 608     driver->no_stem_darkening = TRUE;
 609 
 610     driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
 611     driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
 612     driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;


 615     driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
 616     driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
 617     driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
 618 
 619     /* compute random seed from some memory addresses */
 620     seed = (FT_UInt32)( (FT_Offset)(char*)&seed          ^
 621                         (FT_Offset)(char*)&module        ^
 622                         (FT_Offset)(char*)module->memory );
 623     seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
 624 
 625     driver->random_seed = (FT_Int32)seed;
 626     if ( driver->random_seed < 0 )
 627       driver->random_seed = -driver->random_seed;
 628     else if ( driver->random_seed == 0 )
 629       driver->random_seed = 123456789;
 630 
 631     return FT_Err_Ok;
 632   }
 633 
 634 
 635   /**************************************************************************
 636    *
 637    * @Function:
 638    *   T1_Driver_Done
 639    *
 640    * @Description:
 641    *   Finalizes a given Type 1 driver.
 642    *
 643    * @Input:
 644    *   driver ::
 645    *     A handle to the target Type 1 driver.
 646    */
 647   FT_LOCAL_DEF( void )
 648   T1_Driver_Done( FT_Module  driver )
 649   {
 650     FT_UNUSED( driver );
 651   }
 652 
 653 
 654 /* END */
< prev index next >