1 /***************************************************************************/
5 /* High-level Type 42 driver interface (body). */
7 /* Copyright 2002 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) The sfnts array is expected to be ASCII, not binary. */
28 /* 4) As for Type1 fonts, CDevProc is not supported. */
29 /* 5) The Metrics dictionary is not supported. */
30 /* 6) 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 */
36 /*************************************************************************/
42 #include FT_INTERNAL_DEBUG_H
46 #define FT_COMPONENT trace_t42
50 t42_get_glyph_name( T42_Face face
,
58 gname
= face
->type1
.glyph_names
[glyph_index
];
62 FT_UInt len
= (FT_UInt
)( ft_strlen( gname
) );
65 if ( len
>= buffer_max
)
68 FT_MEM_COPY( buffer
, gname
, len
);
69 ((FT_Byte
*)buffer
)[len
] = 0;
77 t42_get_ps_name( T42_Face face
)
79 return (const char*)face
->type1
.font_name
;
84 t42_get_name_index( T42_Face face
,
85 FT_String
* glyph_name
)
91 for ( i
= 0; i
< face
->type1
.num_glyphs
; i
++ )
93 gname
= face
->type1
.glyph_names
[i
];
95 if ( !ft_strcmp( glyph_name
, gname
) )
96 return ft_atoi( (const char *)face
->type1
.charstrings
[i
] );
103 static FT_Module_Interface
104 T42_Get_Interface( FT_Driver driver
,
105 const FT_String
* t42_interface
)
109 /* Any additional interface are defined here */
110 if (ft_strcmp( (const char*)t42_interface
, "glyph_name" ) == 0 )
111 return (FT_Module_Interface
)t42_get_glyph_name
;
113 if ( ft_strcmp( (const char*)t42_interface
, "name_index" ) == 0 )
114 return (FT_Module_Interface
)t42_get_name_index
;
116 if ( ft_strcmp( (const char*)t42_interface
, "postscript_name" ) == 0 )
117 return (FT_Module_Interface
)t42_get_ps_name
;
123 const FT_Driver_ClassRec t42_driver_class
=
126 ft_module_font_driver
|
127 ft_module_driver_scalable
|
128 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
129 ft_module_driver_has_hinter
,
134 sizeof ( T42_DriverRec
),
140 0, /* format interface */
142 (FT_Module_Constructor
)T42_Driver_Init
,
143 (FT_Module_Destructor
) T42_Driver_Done
,
144 (FT_Module_Requester
) T42_Get_Interface
,
147 sizeof ( T42_FaceRec
),
148 sizeof ( T42_SizeRec
),
149 sizeof ( T42_GlyphSlotRec
),
151 (FT_Face_InitFunc
) T42_Face_Init
,
152 (FT_Face_DoneFunc
) T42_Face_Done
,
153 (FT_Size_InitFunc
) T42_Size_Init
,
154 (FT_Size_DoneFunc
) T42_Size_Done
,
155 (FT_Slot_InitFunc
) T42_GlyphSlot_Init
,
156 (FT_Slot_DoneFunc
) T42_GlyphSlot_Done
,
158 (FT_Size_ResetPointsFunc
) T42_Size_SetChars
,
159 (FT_Size_ResetPixelsFunc
) T42_Size_SetPixels
,
160 (FT_Slot_LoadFunc
) T42_GlyphSlot_Load
,
161 (FT_CharMap_CharIndexFunc
)T42_CMap_CharIndex
,
163 (FT_Face_GetKerningFunc
) 0,
164 (FT_Face_AttachFunc
) 0,
166 (FT_Face_GetAdvancesFunc
) 0,
168 (FT_CharMap_CharNextFunc
) T42_CMap_CharNext
,