1 /****************************************************************************
5 * High-level Type 42 driver interface (body).
7 * Copyright (C) 2002-2019 by
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.
19 /**************************************************************************
21 * This driver implements Type42 fonts as described in the
22 * Technical Note #5012 from Adobe, with these limitations:
24 * 1) CID Fonts are not currently supported.
25 * 2) Incremental fonts making use of the GlyphDirectory keyword
26 * will be loaded, but the rendering will be using the TrueType
28 * 3) As for Type1 fonts, CDevProc is not supported.
29 * 4) The Metrics dictionary is not supported.
30 * 5) AFM metrics are not supported.
32 * In other words, this driver supports Type42 fonts derived from
33 * TrueType fonts in a non-CID manner, as done by usual conversion
42 #include FT_INTERNAL_DEBUG_H
44 #include FT_SERVICE_FONT_FORMAT_H
45 #include FT_SERVICE_GLYPH_DICT_H
46 #include FT_SERVICE_POSTSCRIPT_NAME_H
47 #include FT_SERVICE_POSTSCRIPT_INFO_H
50 #define FT_COMPONENT t42
60 t42_get_glyph_name( T42_Face face,
65 FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
72 t42_get_name_index( T42_Face face,
73 const FT_String* glyph_name )
78 for ( i = 0; i < face->type1.num_glyphs; i++ )
80 FT_String* gname = face->type1.glyph_names[i];
83 if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
84 return (FT_UInt)ft_strtol( (const char *)face->type1.charstrings[i],
92 static const FT_Service_GlyphDictRec t42_service_glyph_dict =
94 (FT_GlyphDict_GetNameFunc) t42_get_glyph_name, /* get_name */
95 (FT_GlyphDict_NameIndexFunc)t42_get_name_index /* name_index */
101 * POSTSCRIPT NAME SERVICE
106 t42_get_ps_font_name( T42_Face face )
108 return (const char*)face->type1.font_name;
112 static const FT_Service_PsFontNameRec t42_service_ps_font_name =
114 (FT_PsName_GetFunc)t42_get_ps_font_name /* get_ps_font_name */
120 * POSTSCRIPT INFO SERVICE
125 t42_ps_get_font_info( FT_Face face,
126 PS_FontInfoRec* afont_info )
128 *afont_info = ((T42_Face)face)->type1.font_info;
135 t42_ps_get_font_extra( FT_Face face,
136 PS_FontExtraRec* afont_extra )
138 *afont_extra = ((T42_Face)face)->type1.font_extra;
145 t42_ps_has_glyph_names( FT_Face face )
154 t42_ps_get_font_private( FT_Face face,
155 PS_PrivateRec* afont_private )
157 *afont_private = ((T42_Face)face)->type1.private_dict;
163 static const FT_Service_PsInfoRec t42_service_ps_info =
165 (PS_GetFontInfoFunc) t42_ps_get_font_info, /* ps_get_font_info */
166 (PS_GetFontExtraFunc) t42_ps_get_font_extra, /* ps_get_font_extra */
167 (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, /* ps_has_glyph_names */
168 (PS_GetFontPrivateFunc)t42_ps_get_font_private, /* ps_get_font_private */
169 /* not implemented */
170 (PS_GetFontValueFunc) NULL /* ps_get_font_value */
180 static const FT_ServiceDescRec t42_services[] =
182 { FT_SERVICE_ID_GLYPH_DICT, &t42_service_glyph_dict },
183 { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t42_service_ps_font_name },
184 { FT_SERVICE_ID_POSTSCRIPT_INFO, &t42_service_ps_info },
185 { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_42 },
190 FT_CALLBACK_DEF( FT_Module_Interface )
191 T42_Get_Interface( FT_Module module,
192 const FT_String* t42_interface )
196 return ft_service_list_lookup( t42_services, t42_interface );
200 const FT_Driver_ClassRec t42_driver_class =
203 FT_MODULE_FONT_DRIVER |
204 FT_MODULE_DRIVER_SCALABLE |
205 #ifdef TT_USE_BYTECODE_INTERPRETER
206 FT_MODULE_DRIVER_HAS_HINTER,
211 sizeof ( T42_DriverRec ),
217 NULL, /* module-specific interface */
219 T42_Driver_Init, /* FT_Module_Constructor module_init */
220 T42_Driver_Done, /* FT_Module_Destructor module_done */
221 T42_Get_Interface, /* FT_Module_Requester get_interface */
224 sizeof ( T42_FaceRec ),
225 sizeof ( T42_SizeRec ),
226 sizeof ( T42_GlyphSlotRec ),
228 T42_Face_Init, /* FT_Face_InitFunc init_face */
229 T42_Face_Done, /* FT_Face_DoneFunc done_face */
230 T42_Size_Init, /* FT_Size_InitFunc init_size */
231 T42_Size_Done, /* FT_Size_DoneFunc done_size */
232 T42_GlyphSlot_Init, /* FT_Slot_InitFunc init_slot */
233 T42_GlyphSlot_Done, /* FT_Slot_DoneFunc done_slot */
235 T42_GlyphSlot_Load, /* FT_Slot_LoadFunc load_glyph */
237 NULL, /* FT_Face_GetKerningFunc get_kerning */
238 NULL, /* FT_Face_AttachFunc attach_file */
239 NULL, /* FT_Face_GetAdvancesFunc get_advances */
241 T42_Size_Request, /* FT_Size_RequestFunc request_size */
242 T42_Size_Select /* FT_Size_SelectFunc select_size */