Home | History | Annotate | Download | only in type1
      1 /****************************************************************************
      2  *
      3  * t1driver.c
      4  *
      5  *   Type 1 driver interface (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 "t1driver.h"
     21 #include "t1gload.h"
     22 #include "t1load.h"
     23 
     24 #include "t1errors.h"
     25 
     26 #ifndef T1_CONFIG_OPTION_NO_AFM
     27 #include "t1afm.h"
     28 #endif
     29 
     30 #include FT_INTERNAL_DEBUG_H
     31 #include FT_INTERNAL_STREAM_H
     32 #include FT_INTERNAL_HASH_H
     33 #include FT_INTERNAL_POSTSCRIPT_PROPS_H
     34 #include FT_DRIVER_H
     35 
     36 #include FT_SERVICE_MULTIPLE_MASTERS_H
     37 #include FT_SERVICE_GLYPH_DICT_H
     38 #include FT_SERVICE_FONT_FORMAT_H
     39 #include FT_SERVICE_POSTSCRIPT_NAME_H
     40 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
     41 #include FT_SERVICE_POSTSCRIPT_INFO_H
     42 #include FT_SERVICE_PROPERTIES_H
     43 #include FT_SERVICE_KERNING_H
     44 
     45 
     46   /**************************************************************************
     47    *
     48    * The macro FT_COMPONENT is used in trace mode.  It is an implicit
     49    * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
     50    * messages during execution.
     51    */
     52 #undef  FT_COMPONENT
     53 #define FT_COMPONENT  trace_t1driver
     54 
     55   /*
     56    * GLYPH DICT SERVICE
     57    *
     58    */
     59 
     60   static FT_Error
     61   t1_get_glyph_name( T1_Face     face,
     62                      FT_UInt     glyph_index,
     63                      FT_Pointer  buffer,
     64                      FT_UInt     buffer_max )
     65   {
     66     FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
     67 
     68     return FT_Err_Ok;
     69   }
     70 
     71 
     72   static FT_UInt
     73   t1_get_name_index( T1_Face     face,
     74                      FT_String*  glyph_name )
     75   {
     76     FT_Int  i;
     77 
     78 
     79     for ( i = 0; i < face->type1.num_glyphs; i++ )
     80     {
     81       FT_String*  gname = face->type1.glyph_names[i];
     82 
     83 
     84       if ( !ft_strcmp( glyph_name, gname ) )
     85         return (FT_UInt)i;
     86     }
     87 
     88     return 0;
     89   }
     90 
     91 
     92   static const FT_Service_GlyphDictRec  t1_service_glyph_dict =
     93   {
     94     (FT_GlyphDict_GetNameFunc)  t1_get_glyph_name,    /* get_name   */
     95     (FT_GlyphDict_NameIndexFunc)t1_get_name_index     /* name_index */
     96   };
     97 
     98 
     99   /*
    100    * POSTSCRIPT NAME SERVICE
    101    *
    102    */
    103 
    104   static const char*
    105   t1_get_ps_name( T1_Face  face )
    106   {
    107     return (const char*) face->type1.font_name;
    108   }
    109 
    110 
    111   static const FT_Service_PsFontNameRec  t1_service_ps_name =
    112   {
    113     (FT_PsName_GetFunc)t1_get_ps_name     /* get_ps_font_name */
    114   };
    115 
    116 
    117   /*
    118    * MULTIPLE MASTERS SERVICE
    119    *
    120    */
    121 
    122 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
    123   static const FT_Service_MultiMastersRec  t1_service_multi_masters =
    124   {
    125     (FT_Get_MM_Func)        T1_Get_Multi_Master,   /* get_mm         */
    126     (FT_Set_MM_Design_Func) T1_Set_MM_Design,      /* set_mm_design  */
    127     (FT_Set_MM_Blend_Func)  T1_Set_MM_Blend,       /* set_mm_blend   */
    128     (FT_Get_MM_Blend_Func)  T1_Get_MM_Blend,       /* get_mm_blend   */
    129     (FT_Get_MM_Var_Func)    T1_Get_MM_Var,         /* get_mm_var     */
    130     (FT_Set_Var_Design_Func)T1_Set_Var_Design,     /* set_var_design */
    131     (FT_Get_Var_Design_Func)T1_Get_Var_Design,     /* get_var_design */
    132     (FT_Set_Instance_Func)  T1_Reset_MM_Blend,     /* set_instance   */
    133 
    134     (FT_Get_Var_Blend_Func) NULL,                  /* get_var_blend  */
    135     (FT_Done_Blend_Func)    T1_Done_Blend          /* done_blend     */
    136   };
    137 #endif
    138 
    139 
    140   /*
    141    * POSTSCRIPT INFO SERVICE
    142    *
    143    */
    144 
    145   static FT_Error
    146   t1_ps_get_font_info( FT_Face          face,
    147                        PS_FontInfoRec*  afont_info )
    148   {
    149     *afont_info = ((T1_Face)face)->type1.font_info;
    150 
    151     return FT_Err_Ok;
    152   }
    153 
    154 
    155   static FT_Error
    156   t1_ps_get_font_extra( FT_Face           face,
    157                         PS_FontExtraRec*  afont_extra )
    158   {
    159     *afont_extra = ((T1_Face)face)->type1.font_extra;
    160 
    161     return FT_Err_Ok;
    162   }
    163 
    164 
    165   static FT_Int
    166   t1_ps_has_glyph_names( FT_Face  face )
    167   {
    168     FT_UNUSED( face );
    169 
    170     return 1;
    171   }
    172 
    173 
    174   static FT_Error
    175   t1_ps_get_font_private( FT_Face         face,
    176                           PS_PrivateRec*  afont_private )
    177   {
    178     *afont_private = ((T1_Face)face)->type1.private_dict;
    179 
    180     return FT_Err_Ok;
    181   }
    182 
    183 
    184   static FT_Long
    185   t1_ps_get_font_value( FT_Face       face,
    186                         PS_Dict_Keys  key,
    187                         FT_UInt       idx,
    188                         void         *value,
    189                         FT_Long       value_len_ )
    190   {
    191     FT_ULong  retval    = 0; /* always >= 1 if valid */
    192     FT_ULong  value_len = value_len_ < 0 ? 0 : (FT_ULong)value_len_;
    193 
    194     T1_Face  t1face = (T1_Face)face;
    195     T1_Font  type1  = &t1face->type1;
    196 
    197 
    198     switch ( key )
    199     {
    200     case PS_DICT_FONT_TYPE:
    201       retval = sizeof ( type1->font_type );
    202       if ( value && value_len >= retval )
    203         *((FT_Byte *)value) = type1->font_type;
    204       break;
    205 
    206     case PS_DICT_FONT_MATRIX:
    207       if ( idx < sizeof ( type1->font_matrix ) /
    208                    sizeof ( type1->font_matrix.xx ) )
    209       {
    210         FT_Fixed  val = 0;
    211 
    212 
    213         retval = sizeof ( val );
    214         if ( value && value_len >= retval )
    215         {
    216           switch ( idx )
    217           {
    218           case 0:
    219             val = type1->font_matrix.xx;
    220             break;
    221           case 1:
    222             val = type1->font_matrix.xy;
    223             break;
    224           case 2:
    225             val = type1->font_matrix.yx;
    226             break;
    227           case 3:
    228             val = type1->font_matrix.yy;
    229             break;
    230           }
    231           *((FT_Fixed *)value) = val;
    232         }
    233       }
    234       break;
    235 
    236     case PS_DICT_FONT_BBOX:
    237       if ( idx < sizeof ( type1->font_bbox ) /
    238                    sizeof ( type1->font_bbox.xMin ) )
    239       {
    240         FT_Fixed  val = 0;
    241 
    242 
    243         retval = sizeof ( val );
    244         if ( value && value_len >= retval )
    245         {
    246           switch ( idx )
    247           {
    248           case 0:
    249             val = type1->font_bbox.xMin;
    250             break;
    251           case 1:
    252             val = type1->font_bbox.yMin;
    253             break;
    254           case 2:
    255             val = type1->font_bbox.xMax;
    256             break;
    257           case 3:
    258             val = type1->font_bbox.yMax;
    259             break;
    260           }
    261           *((FT_Fixed *)value) = val;
    262         }
    263       }
    264       break;
    265 
    266     case PS_DICT_PAINT_TYPE:
    267       retval = sizeof ( type1->paint_type );
    268       if ( value && value_len >= retval )
    269         *((FT_Byte *)value) = type1->paint_type;
    270       break;
    271 
    272     case PS_DICT_FONT_NAME:
    273       if ( type1->font_name )
    274       {
    275         retval = ft_strlen( type1->font_name ) + 1;
    276         if ( value && value_len >= retval )
    277           ft_memcpy( value, (void *)( type1->font_name ), retval );
    278       }
    279       break;
    280 
    281     case PS_DICT_UNIQUE_ID:
    282       retval = sizeof ( type1->private_dict.unique_id );
    283       if ( value && value_len >= retval )
    284         *((FT_Int *)value) = type1->private_dict.unique_id;
    285       break;
    286 
    287     case PS_DICT_NUM_CHAR_STRINGS:
    288       retval = sizeof ( type1->num_glyphs );
    289       if ( value && value_len >= retval )
    290         *((FT_Int *)value) = type1->num_glyphs;
    291       break;
    292 
    293     case PS_DICT_CHAR_STRING_KEY:
    294       if ( idx < (FT_UInt)type1->num_glyphs )
    295       {
    296         retval = ft_strlen( type1->glyph_names[idx] ) + 1;
    297         if ( value && value_len >= retval )
    298         {
    299           ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
    300           ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
    301         }
    302       }
    303       break;
    304 
    305     case PS_DICT_CHAR_STRING:
    306       if ( idx < (FT_UInt)type1->num_glyphs )
    307       {
    308         retval = type1->charstrings_len[idx] + 1;
    309         if ( value && value_len >= retval )
    310         {
    311           ft_memcpy( value, (void *)( type1->charstrings[idx] ),
    312                      retval - 1 );
    313           ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
    314         }
    315       }
    316       break;
    317 
    318     case PS_DICT_ENCODING_TYPE:
    319       retval = sizeof ( type1->encoding_type );
    320       if ( value && value_len >= retval )
    321         *((T1_EncodingType *)value) = type1->encoding_type;
    322       break;
    323 
    324     case PS_DICT_ENCODING_ENTRY:
    325       if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
    326            idx < (FT_UInt)type1->encoding.num_chars       )
    327       {
    328         retval = ft_strlen( type1->encoding.char_name[idx] ) + 1;
    329         if ( value && value_len >= retval )
    330         {
    331           ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
    332                      retval - 1 );
    333           ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
    334         }
    335       }
    336       break;
    337 
    338     case PS_DICT_NUM_SUBRS:
    339       retval = sizeof ( type1->num_subrs );
    340       if ( value && value_len >= retval )
    341         *((FT_Int *)value) = type1->num_subrs;
    342       break;
    343 
    344     case PS_DICT_SUBR:
    345       {
    346         FT_Bool  ok = 0;
    347 
    348 
    349         if ( type1->subrs_hash )
    350         {
    351           /* convert subr index to array index */
    352           size_t*  val = ft_hash_num_lookup( (FT_Int)idx,
    353                                              type1->subrs_hash );
    354 
    355 
    356           if ( val )
    357           {
    358             idx = *val;
    359             ok  = 1;
    360           }
    361         }
    362         else
    363         {
    364           if ( idx < (FT_UInt)type1->num_subrs )
    365             ok = 1;
    366         }
    367 
    368         if ( ok && type1->subrs )
    369         {
    370           retval = type1->subrs_len[idx] + 1;
    371           if ( value && value_len >= retval )
    372           {
    373             ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
    374             ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
    375           }
    376         }
    377       }
    378       break;
    379 
    380     case PS_DICT_STD_HW:
    381       retval = sizeof ( type1->private_dict.standard_width[0] );
    382       if ( value && value_len >= retval )
    383         *((FT_UShort *)value) = type1->private_dict.standard_width[0];
    384       break;
    385 
    386     case PS_DICT_STD_VW:
    387       retval = sizeof ( type1->private_dict.standard_height[0] );
    388       if ( value && value_len >= retval )
    389         *((FT_UShort *)value) = type1->private_dict.standard_height[0];
    390       break;
    391 
    392     case PS_DICT_NUM_BLUE_VALUES:
    393       retval = sizeof ( type1->private_dict.num_blue_values );
    394       if ( value && value_len >= retval )
    395         *((FT_Byte *)value) = type1->private_dict.num_blue_values;
    396       break;
    397 
    398     case PS_DICT_BLUE_VALUE:
    399       if ( idx < type1->private_dict.num_blue_values )
    400       {
    401         retval = sizeof ( type1->private_dict.blue_values[idx] );
    402         if ( value && value_len >= retval )
    403           *((FT_Short *)value) = type1->private_dict.blue_values[idx];
    404       }
    405       break;
    406 
    407     case PS_DICT_BLUE_SCALE:
    408       retval = sizeof ( type1->private_dict.blue_scale );
    409       if ( value && value_len >= retval )
    410         *((FT_Fixed *)value) = type1->private_dict.blue_scale;
    411       break;
    412 
    413     case PS_DICT_BLUE_FUZZ:
    414       retval = sizeof ( type1->private_dict.blue_fuzz );
    415       if ( value && value_len >= retval )
    416         *((FT_Int *)value) = type1->private_dict.blue_fuzz;
    417       break;
    418 
    419     case PS_DICT_BLUE_SHIFT:
    420       retval = sizeof ( type1->private_dict.blue_shift );
    421       if ( value && value_len >= retval )
    422         *((FT_Int *)value) = type1->private_dict.blue_shift;
    423       break;
    424 
    425     case PS_DICT_NUM_OTHER_BLUES:
    426       retval = sizeof ( type1->private_dict.num_other_blues );
    427       if ( value && value_len >= retval )
    428         *((FT_Byte *)value) = type1->private_dict.num_other_blues;
    429       break;
    430 
    431     case PS_DICT_OTHER_BLUE:
    432       if ( idx < type1->private_dict.num_other_blues )
    433       {
    434         retval = sizeof ( type1->private_dict.other_blues[idx] );
    435         if ( value && value_len >= retval )
    436           *((FT_Short *)value) = type1->private_dict.other_blues[idx];
    437       }
    438       break;
    439 
    440     case PS_DICT_NUM_FAMILY_BLUES:
    441       retval = sizeof ( type1->private_dict.num_family_blues );
    442       if ( value && value_len >= retval )
    443         *((FT_Byte *)value) = type1->private_dict.num_family_blues;
    444       break;
    445 
    446     case PS_DICT_FAMILY_BLUE:
    447       if ( idx < type1->private_dict.num_family_blues )
    448       {
    449         retval = sizeof ( type1->private_dict.family_blues[idx] );
    450         if ( value && value_len >= retval )
    451           *((FT_Short *)value) = type1->private_dict.family_blues[idx];
    452       }
    453       break;
    454 
    455     case PS_DICT_NUM_FAMILY_OTHER_BLUES:
    456       retval = sizeof ( type1->private_dict.num_family_other_blues );
    457       if ( value && value_len >= retval )
    458         *((FT_Byte *)value) = type1->private_dict.num_family_other_blues;
    459       break;
    460 
    461     case PS_DICT_FAMILY_OTHER_BLUE:
    462       if ( idx < type1->private_dict.num_family_other_blues )
    463       {
    464         retval = sizeof ( type1->private_dict.family_other_blues[idx] );
    465         if ( value && value_len >= retval )
    466           *((FT_Short *)value) = type1->private_dict.family_other_blues[idx];
    467       }
    468       break;
    469 
    470     case PS_DICT_NUM_STEM_SNAP_H:
    471       retval = sizeof ( type1->private_dict.num_snap_widths );
    472       if ( value && value_len >= retval )
    473         *((FT_Byte *)value) = type1->private_dict.num_snap_widths;
    474       break;
    475 
    476     case PS_DICT_STEM_SNAP_H:
    477       if ( idx < type1->private_dict.num_snap_widths )
    478       {
    479         retval = sizeof ( type1->private_dict.snap_widths[idx] );
    480         if ( value && value_len >= retval )
    481           *((FT_Short *)value) = type1->private_dict.snap_widths[idx];
    482       }
    483       break;
    484 
    485     case PS_DICT_NUM_STEM_SNAP_V:
    486       retval = sizeof ( type1->private_dict.num_snap_heights );
    487       if ( value && value_len >= retval )
    488         *((FT_Byte *)value) = type1->private_dict.num_snap_heights;
    489       break;
    490 
    491     case PS_DICT_STEM_SNAP_V:
    492       if ( idx < type1->private_dict.num_snap_heights )
    493       {
    494         retval = sizeof ( type1->private_dict.snap_heights[idx] );
    495         if ( value && value_len >= retval )
    496           *((FT_Short *)value) = type1->private_dict.snap_heights[idx];
    497       }
    498       break;
    499 
    500     case PS_DICT_RND_STEM_UP:
    501       retval = sizeof ( type1->private_dict.round_stem_up );
    502       if ( value && value_len >= retval )
    503         *((FT_Bool *)value) = type1->private_dict.round_stem_up;
    504       break;
    505 
    506     case PS_DICT_FORCE_BOLD:
    507       retval = sizeof ( type1->private_dict.force_bold );
    508       if ( value && value_len >= retval )
    509         *((FT_Bool *)value) = type1->private_dict.force_bold;
    510       break;
    511 
    512     case PS_DICT_MIN_FEATURE:
    513       if ( idx < sizeof ( type1->private_dict.min_feature ) /
    514                    sizeof ( type1->private_dict.min_feature[0] ) )
    515       {
    516         retval = sizeof ( type1->private_dict.min_feature[idx] );
    517         if ( value && value_len >= retval )
    518           *((FT_Short *)value) = type1->private_dict.min_feature[idx];
    519       }
    520       break;
    521 
    522     case PS_DICT_LEN_IV:
    523       retval = sizeof ( type1->private_dict.lenIV );
    524       if ( value && value_len >= retval )
    525         *((FT_Int *)value) = type1->private_dict.lenIV;
    526       break;
    527 
    528     case PS_DICT_PASSWORD:
    529       retval = sizeof ( type1->private_dict.password );
    530       if ( value && value_len >= retval )
    531         *((FT_Long *)value) = type1->private_dict.password;
    532       break;
    533 
    534     case PS_DICT_LANGUAGE_GROUP:
    535       retval = sizeof ( type1->private_dict.language_group );
    536       if ( value && value_len >= retval )
    537         *((FT_Long *)value) = type1->private_dict.language_group;
    538       break;
    539 
    540     case PS_DICT_IS_FIXED_PITCH:
    541       retval = sizeof ( type1->font_info.is_fixed_pitch );
    542       if ( value && value_len >= retval )
    543         *((FT_Bool *)value) = type1->font_info.is_fixed_pitch;
    544       break;
    545 
    546     case PS_DICT_UNDERLINE_POSITION:
    547       retval = sizeof ( type1->font_info.underline_position );
    548       if ( value && value_len >= retval )
    549         *((FT_Short *)value) = type1->font_info.underline_position;
    550       break;
    551 
    552     case PS_DICT_UNDERLINE_THICKNESS:
    553       retval = sizeof ( type1->font_info.underline_thickness );
    554       if ( value && value_len >= retval )
    555         *((FT_UShort *)value) = type1->font_info.underline_thickness;
    556       break;
    557 
    558     case PS_DICT_FS_TYPE:
    559       retval = sizeof ( type1->font_extra.fs_type );
    560       if ( value && value_len >= retval )
    561         *((FT_UShort *)value) = type1->font_extra.fs_type;
    562       break;
    563 
    564     case PS_DICT_VERSION:
    565       if ( type1->font_info.version )
    566       {
    567         retval = ft_strlen( type1->font_info.version ) + 1;
    568         if ( value && value_len >= retval )
    569           ft_memcpy( value, (void *)( type1->font_info.version ), retval );
    570       }
    571       break;
    572 
    573     case PS_DICT_NOTICE:
    574       if ( type1->font_info.notice )
    575       {
    576         retval = ft_strlen( type1->font_info.notice ) + 1;
    577         if ( value && value_len >= retval )
    578           ft_memcpy( value, (void *)( type1->font_info.notice ), retval );
    579       }
    580       break;
    581 
    582     case PS_DICT_FULL_NAME:
    583       if ( type1->font_info.full_name )
    584       {
    585         retval = ft_strlen( type1->font_info.full_name ) + 1;
    586         if ( value && value_len >= retval )
    587           ft_memcpy( value, (void *)( type1->font_info.full_name ), retval );
    588       }
    589       break;
    590 
    591     case PS_DICT_FAMILY_NAME:
    592       if ( type1->font_info.family_name )
    593       {
    594         retval = ft_strlen( type1->font_info.family_name ) + 1;
    595         if ( value && value_len >= retval )
    596           ft_memcpy( value, (void *)( type1->font_info.family_name ),
    597                      retval );
    598       }
    599       break;
    600 
    601     case PS_DICT_WEIGHT:
    602       if ( type1->font_info.weight )
    603       {
    604         retval = ft_strlen( type1->font_info.weight ) + 1;
    605         if ( value && value_len >= retval )
    606           ft_memcpy( value, (void *)( type1->font_info.weight ), retval );
    607       }
    608       break;
    609 
    610     case PS_DICT_ITALIC_ANGLE:
    611       retval = sizeof ( type1->font_info.italic_angle );
    612       if ( value && value_len >= retval )
    613         *((FT_Long *)value) = type1->font_info.italic_angle;
    614       break;
    615     }
    616 
    617     return retval == 0 ? -1 : (FT_Long)retval;
    618   }
    619 
    620 
    621   static const FT_Service_PsInfoRec  t1_service_ps_info =
    622   {
    623     (PS_GetFontInfoFunc)   t1_ps_get_font_info,    /* ps_get_font_info    */
    624     (PS_GetFontExtraFunc)  t1_ps_get_font_extra,   /* ps_get_font_extra   */
    625     (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,  /* ps_has_glyph_names  */
    626     (PS_GetFontPrivateFunc)t1_ps_get_font_private, /* ps_get_font_private */
    627     (PS_GetFontValueFunc)  t1_ps_get_font_value,   /* ps_get_font_value   */
    628   };
    629 
    630 
    631 #ifndef T1_CONFIG_OPTION_NO_AFM
    632   static const FT_Service_KerningRec  t1_service_kerning =
    633   {
    634     T1_Get_Track_Kerning,       /* get_track */
    635   };
    636 #endif
    637 
    638 
    639   /*
    640    * PROPERTY SERVICE
    641    *
    642    */
    643 
    644   FT_DEFINE_SERVICE_PROPERTIESREC(
    645     t1_service_properties,
    646 
    647     (FT_Properties_SetFunc)ps_property_set,      /* set_property */
    648     (FT_Properties_GetFunc)ps_property_get )     /* get_property */
    649 
    650 
    651   /*
    652    * SERVICE LIST
    653    *
    654    */
    655 
    656   static const FT_ServiceDescRec  t1_services[] =
    657   {
    658     { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name },
    659     { FT_SERVICE_ID_GLYPH_DICT,           &t1_service_glyph_dict },
    660     { FT_SERVICE_ID_FONT_FORMAT,          FT_FONT_FORMAT_TYPE_1 },
    661     { FT_SERVICE_ID_POSTSCRIPT_INFO,      &t1_service_ps_info },
    662     { FT_SERVICE_ID_PROPERTIES,           &t1_service_properties },
    663 
    664 #ifndef T1_CONFIG_OPTION_NO_AFM
    665     { FT_SERVICE_ID_KERNING,              &t1_service_kerning },
    666 #endif
    667 
    668 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
    669     { FT_SERVICE_ID_MULTI_MASTERS,        &t1_service_multi_masters },
    670 #endif
    671     { NULL, NULL }
    672   };
    673 
    674 
    675   FT_CALLBACK_DEF( FT_Module_Interface )
    676   Get_Interface( FT_Module         module,
    677                  const FT_String*  t1_interface )
    678   {
    679     FT_UNUSED( module );
    680 
    681     return ft_service_list_lookup( t1_services, t1_interface );
    682   }
    683 
    684 
    685 #ifndef T1_CONFIG_OPTION_NO_AFM
    686 
    687   /**************************************************************************
    688    *
    689    * @Function:
    690    *   Get_Kerning
    691    *
    692    * @Description:
    693    *   A driver method used to return the kerning vector between two
    694    *   glyphs of the same face.
    695    *
    696    * @Input:
    697    *   face ::
    698    *     A handle to the source face object.
    699    *
    700    *   left_glyph ::
    701    *     The index of the left glyph in the kern pair.
    702    *
    703    *   right_glyph ::
    704    *     The index of the right glyph in the kern pair.
    705    *
    706    * @Output:
    707    *   kerning ::
    708    *     The kerning vector.  This is in font units for
    709    *     scalable formats, and in pixels for fixed-sizes
    710    *     formats.
    711    *
    712    * @Return:
    713    *   FreeType error code.  0 means success.
    714    *
    715    * @Note:
    716    *   Only horizontal layouts (left-to-right & right-to-left) are
    717    *   supported by this function.  Other layouts, or more sophisticated
    718    *   kernings are out of scope of this method (the basic driver
    719    *   interface is meant to be simple).
    720    *
    721    *   They can be implemented by format-specific interfaces.
    722    */
    723   static FT_Error
    724   Get_Kerning( FT_Face     t1face,        /* T1_Face */
    725                FT_UInt     left_glyph,
    726                FT_UInt     right_glyph,
    727                FT_Vector*  kerning )
    728   {
    729     T1_Face  face = (T1_Face)t1face;
    730 
    731 
    732     kerning->x = 0;
    733     kerning->y = 0;
    734 
    735     if ( face->afm_data )
    736       T1_Get_Kerning( (AFM_FontInfo)face->afm_data,
    737                       left_glyph,
    738                       right_glyph,
    739                       kerning );
    740 
    741     return FT_Err_Ok;
    742   }
    743 
    744 
    745 #endif /* T1_CONFIG_OPTION_NO_AFM */
    746 
    747 
    748   FT_CALLBACK_TABLE_DEF
    749   const FT_Driver_ClassRec  t1_driver_class =
    750   {
    751     {
    752       FT_MODULE_FONT_DRIVER       |
    753       FT_MODULE_DRIVER_SCALABLE   |
    754       FT_MODULE_DRIVER_HAS_HINTER,
    755 
    756       sizeof ( PS_DriverRec ),
    757 
    758       "type1",
    759       0x10000L,
    760       0x20000L,
    761 
    762       NULL,    /* module-specific interface */
    763 
    764       T1_Driver_Init,           /* FT_Module_Constructor  module_init   */
    765       T1_Driver_Done,           /* FT_Module_Destructor   module_done   */
    766       Get_Interface,            /* FT_Module_Requester    get_interface */
    767     },
    768 
    769     sizeof ( T1_FaceRec ),
    770     sizeof ( T1_SizeRec ),
    771     sizeof ( T1_GlyphSlotRec ),
    772 
    773     T1_Face_Init,               /* FT_Face_InitFunc  init_face */
    774     T1_Face_Done,               /* FT_Face_DoneFunc  done_face */
    775     T1_Size_Init,               /* FT_Size_InitFunc  init_size */
    776     T1_Size_Done,               /* FT_Size_DoneFunc  done_size */
    777     T1_GlyphSlot_Init,          /* FT_Slot_InitFunc  init_slot */
    778     T1_GlyphSlot_Done,          /* FT_Slot_DoneFunc  done_slot */
    779 
    780     T1_Load_Glyph,              /* FT_Slot_LoadFunc  load_glyph */
    781 
    782 #ifdef T1_CONFIG_OPTION_NO_AFM
    783     NULL,                       /* FT_Face_GetKerningFunc   get_kerning  */
    784     NULL,                       /* FT_Face_AttachFunc       attach_file  */
    785 #else
    786     Get_Kerning,                /* FT_Face_GetKerningFunc   get_kerning  */
    787     T1_Read_Metrics,            /* FT_Face_AttachFunc       attach_file  */
    788 #endif
    789     T1_Get_Advances,            /* FT_Face_GetAdvancesFunc  get_advances */
    790 
    791     T1_Size_Request,            /* FT_Size_RequestFunc  request_size */
    792     NULL                        /* FT_Size_SelectFunc   select_size  */
    793   };
    794 
    795 
    796 /* END */
    797