t42drivr.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  t42drivr.c                                                             */
00004 /*                                                                         */
00005 /*    High-level Type 42 driver interface (body).                          */
00006 /*                                                                         */
00007 /*  Copyright 2002, 2003, 2004, 2006, 2007, 2009 by Roberto Alameda.       */
00008 /*                                                                         */
00009 /*  This file is part of the FreeType project, and may only be used,       */
00010 /*  modified, and distributed under the terms of the FreeType project      */
00011 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00012 /*  this file you indicate that you have read the license and              */
00013 /*  understand and accept it fully.                                        */
00014 /*                                                                         */
00015 /***************************************************************************/
00016 
00017 
00018   /*************************************************************************/
00019   /*                                                                       */
00020   /* This driver implements Type42 fonts as described in the               */
00021   /* Technical Note #5012 from Adobe, with these limitations:              */
00022   /*                                                                       */
00023   /* 1) CID Fonts are not currently supported.                             */
00024   /* 2) Incremental fonts making use of the GlyphDirectory keyword         */
00025   /*    will be loaded, but the rendering will be using the TrueType       */
00026   /*    tables.                                                            */
00027   /* 3) As for Type1 fonts, CDevProc is not supported.                     */
00028   /* 4) The Metrics dictionary is not supported.                           */
00029   /* 5) AFM metrics are not supported.                                     */
00030   /*                                                                       */
00031   /* In other words, this driver supports Type42 fonts derived from        */
00032   /* TrueType fonts in a non-CID manner, as done by usual conversion       */
00033   /* programs.                                                             */
00034   /*                                                                       */
00035   /*************************************************************************/
00036 
00037 
00038 #include "t42drivr.h"
00039 #include "t42objs.h"
00040 #include "t42error.h"
00041 #include FT_INTERNAL_DEBUG_H
00042 
00043 #include FT_SERVICE_XFREE86_NAME_H
00044 #include FT_SERVICE_GLYPH_DICT_H
00045 #include FT_SERVICE_POSTSCRIPT_NAME_H
00046 #include FT_SERVICE_POSTSCRIPT_INFO_H
00047 
00048 #undef  FT_COMPONENT
00049 #define FT_COMPONENT  trace_t42
00050 
00051 
00052   /*
00053    *
00054    *  GLYPH DICT SERVICE
00055    *
00056    */
00057 
00058   static FT_Error
00059   t42_get_glyph_name( T42_Face    face,
00060                       FT_UInt     glyph_index,
00061                       FT_Pointer  buffer,
00062                       FT_UInt     buffer_max )
00063   {
00064     FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
00065 
00066     return T42_Err_Ok;
00067   }
00068 
00069 
00070   static FT_UInt
00071   t42_get_name_index( T42_Face    face,
00072                       FT_String*  glyph_name )
00073   {
00074     FT_Int      i;
00075     FT_String*  gname;
00076 
00077 
00078     for ( i = 0; i < face->type1.num_glyphs; i++ )
00079     {
00080       gname = face->type1.glyph_names[i];
00081 
00082       if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
00083         return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] );
00084     }
00085 
00086     return 0;
00087   }
00088 
00089 
00090   static const FT_Service_GlyphDictRec  t42_service_glyph_dict =
00091   {
00092     (FT_GlyphDict_GetNameFunc)  t42_get_glyph_name,
00093     (FT_GlyphDict_NameIndexFunc)t42_get_name_index
00094   };
00095 
00096 
00097   /*
00098    *
00099    *  POSTSCRIPT NAME SERVICE
00100    *
00101    */
00102 
00103   static const char*
00104   t42_get_ps_font_name( T42_Face  face )
00105   {
00106     return (const char*)face->type1.font_name;
00107   }
00108 
00109 
00110   static const FT_Service_PsFontNameRec  t42_service_ps_font_name =
00111   {
00112     (FT_PsName_GetFunc)t42_get_ps_font_name
00113   };
00114 
00115 
00116   /*
00117    *
00118    *  POSTSCRIPT INFO SERVICE
00119    *
00120    */
00121 
00122   static FT_Error
00123   t42_ps_get_font_info( FT_Face          face,
00124                         PS_FontInfoRec*  afont_info )
00125   {
00126     *afont_info = ((T42_Face)face)->type1.font_info;
00127 
00128     return T42_Err_Ok;
00129   }
00130 
00131 
00132   static FT_Error
00133   t42_ps_get_font_extra( FT_Face           face,
00134                          PS_FontExtraRec*  afont_extra )
00135   {
00136     *afont_extra = ((T42_Face)face)->type1.font_extra;
00137 
00138     return T42_Err_Ok;
00139   }
00140 
00141 
00142   static FT_Int
00143   t42_ps_has_glyph_names( FT_Face  face )
00144   {
00145     FT_UNUSED( face );
00146 
00147     return 1;
00148   }
00149 
00150 
00151   static FT_Error
00152   t42_ps_get_font_private( FT_Face         face,
00153                            PS_PrivateRec*  afont_private )
00154   {
00155     *afont_private = ((T42_Face)face)->type1.private_dict;
00156 
00157     return T42_Err_Ok;
00158   }
00159 
00160 
00161   static const FT_Service_PsInfoRec  t42_service_ps_info =
00162   {
00163     (PS_GetFontInfoFunc)   t42_ps_get_font_info,
00164     (PS_GetFontExtraFunc)   t42_ps_get_font_extra,
00165     (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names,
00166     (PS_GetFontPrivateFunc)t42_ps_get_font_private
00167   };
00168 
00169 
00170   /*
00171    *
00172    *  SERVICE LIST
00173    *
00174    */
00175 
00176   static const FT_ServiceDescRec  t42_services[] =
00177   {
00178     { FT_SERVICE_ID_GLYPH_DICT,           &t42_service_glyph_dict },
00179     { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t42_service_ps_font_name },
00180     { FT_SERVICE_ID_POSTSCRIPT_INFO,      &t42_service_ps_info },
00181     { FT_SERVICE_ID_XF86_NAME,            FT_XF86_FORMAT_TYPE_42 },
00182     { NULL, NULL }
00183   };
00184 
00185 
00186   static FT_Module_Interface
00187   T42_Get_Interface( FT_Driver         driver,
00188                      const FT_String*  t42_interface )
00189   {
00190     FT_UNUSED( driver );
00191 
00192     return ft_service_list_lookup( t42_services, t42_interface );
00193   }
00194 
00195 
00196   const FT_Driver_ClassRec  t42_driver_class =
00197   {
00198     {
00199       FT_MODULE_FONT_DRIVER       |
00200       FT_MODULE_DRIVER_SCALABLE   |
00201 #ifdef TT_USE_BYTECODE_INTERPRETER
00202       FT_MODULE_DRIVER_HAS_HINTER,
00203 #else
00204       0,
00205 #endif
00206 
00207       sizeof ( T42_DriverRec ),
00208 
00209       "type42",
00210       0x10000L,
00211       0x20000L,
00212 
00213       0,    /* format interface */
00214 
00215       (FT_Module_Constructor)T42_Driver_Init,
00216       (FT_Module_Destructor) T42_Driver_Done,
00217       (FT_Module_Requester)  T42_Get_Interface,
00218     },
00219 
00220     sizeof ( T42_FaceRec ),
00221     sizeof ( T42_SizeRec ),
00222     sizeof ( T42_GlyphSlotRec ),
00223 
00224     (FT_Face_InitFunc)        T42_Face_Init,
00225     (FT_Face_DoneFunc)        T42_Face_Done,
00226     (FT_Size_InitFunc)        T42_Size_Init,
00227     (FT_Size_DoneFunc)        T42_Size_Done,
00228     (FT_Slot_InitFunc)        T42_GlyphSlot_Init,
00229     (FT_Slot_DoneFunc)        T42_GlyphSlot_Done,
00230 
00231 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
00232     ft_stub_set_char_sizes,
00233     ft_stub_set_pixel_sizes,
00234 #endif
00235     (FT_Slot_LoadFunc)        T42_GlyphSlot_Load,
00236 
00237     (FT_Face_GetKerningFunc)  0,
00238     (FT_Face_AttachFunc)      0,
00239 
00240     (FT_Face_GetAdvancesFunc) 0,
00241     (FT_Size_RequestFunc)     T42_Size_Request,
00242     (FT_Size_SelectFunc)      T42_Size_Select
00243   };
00244 
00245 
00246 /* END */

Generated on Tue Jul 5 14:13:54 2011 for ROOT_528-00b_version by  doxygen 1.5.1