1 /***************************************************************************/
5 /* High-level Type 42 driver interface (body). */
7 /* Copyright 2002, 2003, 2004, 2006 by Roberto Alameda. */
9 /* This file is part of the FreeType project, and may only be used, */
10 /* modified, and distributed under the terms of the FreeType project */
11 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
12 /* this file you indicate that you have read the license and */
13 /* understand and accept it fully. */
15 /***************************************************************************/
18 /*************************************************************************/
20 /* This driver implements Type42 fonts as described in the */
21 /* Technical Note #5012 from Adobe, with these limitations: */
23 /* 1) CID Fonts are not currently supported. */
24 /* 2) Incremental fonts making use of the GlyphDirectory keyword */
25 /* will be loaded, but the rendering will be using the TrueType */
27 /* 3) As for Type1 fonts, CDevProc is not supported. */
28 /* 4) The Metrics dictionary is not supported. */
29 /* 5) AFM metrics are not supported. */
31 /* In other words, this driver supports Type42 fonts derived from */
32 /* TrueType fonts in a non-CID manner, as done by usual conversion */
35 /*************************************************************************/
41 #include FT_INTERNAL_DEBUG_H
43 #include FT_SERVICE_XFREE86_NAME_H
44 #include FT_SERVICE_GLYPH_DICT_H
45 #include FT_SERVICE_POSTSCRIPT_NAME_H
46 #include FT_SERVICE_POSTSCRIPT_INFO_H
49 #define FT_COMPONENT trace_t42
59 t42_get_glyph_name( T42_Face face
,
67 gname
= face
->type1
.glyph_names
[glyph_index
];
71 FT_UInt len
= (FT_UInt
)( ft_strlen( gname
) );
74 if ( len
>= buffer_max
)
77 FT_MEM_COPY( buffer
, gname
, len
);
78 ((FT_Byte
*)buffer
)[len
] = 0;
86 t42_get_name_index( T42_Face face
,
87 FT_String
* glyph_name
)
93 for ( i
= 0; i
< face
->type1
.num_glyphs
; i
++ )
95 gname
= face
->type1
.glyph_names
[i
];
97 if ( !ft_strcmp( glyph_name
, gname
) )
98 return (FT_UInt
)ft_atol( (const char *)face
->type1
.charstrings
[i
] );
105 static const FT_Service_GlyphDictRec t42_service_glyph_dict
=
107 (FT_GlyphDict_GetNameFunc
) t42_get_glyph_name
,
108 (FT_GlyphDict_NameIndexFunc
)t42_get_name_index
114 * POSTSCRIPT NAME SERVICE
119 t42_get_ps_font_name( T42_Face face
)
121 return (const char*)face
->type1
.font_name
;
125 static const FT_Service_PsFontNameRec t42_service_ps_font_name
=
127 (FT_PsName_GetFunc
)t42_get_ps_font_name
133 * POSTSCRIPT INFO SERVICE
138 t42_ps_get_font_info( FT_Face face
,
139 PS_FontInfoRec
* afont_info
)
141 *afont_info
= ((T42_Face
)face
)->type1
.font_info
;
147 t42_ps_has_glyph_names( FT_Face face
)
155 t42_ps_get_font_private( FT_Face face
,
156 PS_PrivateRec
* afont_private
)
158 *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
,
166 (PS_HasGlyphNamesFunc
) t42_ps_has_glyph_names
,
167 (PS_GetFontPrivateFunc
)t42_ps_get_font_private
177 static const FT_ServiceDescRec t42_services
[] =
179 { FT_SERVICE_ID_GLYPH_DICT
, &t42_service_glyph_dict
},
180 { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME
, &t42_service_ps_font_name
},
181 { FT_SERVICE_ID_POSTSCRIPT_INFO
, &t42_service_ps_info
},
182 { FT_SERVICE_ID_XF86_NAME
, FT_XF86_FORMAT_TYPE_42
},
187 static FT_Module_Interface
188 T42_Get_Interface( FT_Driver driver
,
189 const FT_String
* t42_interface
)
193 return ft_service_list_lookup( t42_services
, t42_interface
);
197 const FT_Driver_ClassRec t42_driver_class
=
200 FT_MODULE_FONT_DRIVER
|
201 FT_MODULE_DRIVER_SCALABLE
|
202 #ifdef TT_USE_BYTECODE_INTERPRETER
203 FT_MODULE_DRIVER_HAS_HINTER
,
208 sizeof ( T42_DriverRec
),
214 0, /* format interface */
216 (FT_Module_Constructor
)T42_Driver_Init
,
217 (FT_Module_Destructor
) T42_Driver_Done
,
218 (FT_Module_Requester
) T42_Get_Interface
,
221 sizeof ( T42_FaceRec
),
222 sizeof ( T42_SizeRec
),
223 sizeof ( T42_GlyphSlotRec
),
225 (FT_Face_InitFunc
) T42_Face_Init
,
226 (FT_Face_DoneFunc
) T42_Face_Done
,
227 (FT_Size_InitFunc
) T42_Size_Init
,
228 (FT_Size_DoneFunc
) T42_Size_Done
,
229 (FT_Slot_InitFunc
) T42_GlyphSlot_Init
,
230 (FT_Slot_DoneFunc
) T42_GlyphSlot_Done
,
232 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
233 ft_stub_set_char_sizes
,
234 ft_stub_set_pixel_sizes
,
236 (FT_Slot_LoadFunc
) T42_GlyphSlot_Load
,
238 (FT_Face_GetKerningFunc
) 0,
239 (FT_Face_AttachFunc
) 0,
241 (FT_Face_GetAdvancesFunc
) 0,
242 (FT_Size_RequestFunc
) T42_Size_Request
,
243 (FT_Size_SelectFunc
) T42_Size_Select