Bringing apdf from vendor into main branch.
[AROS-Contrib.git] / apdf / freetype2 / type42 / t42drivr.c
bloba053318513a83078368317c010ee265b21fab4a1
1 /***************************************************************************/
2 /* */
3 /* t42drivr.c */
4 /* */
5 /* High-level Type 42 driver interface (body). */
6 /* */
7 /* Copyright 2002 by Roberto Alameda. */
8 /* */
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. */
14 /* */
15 /***************************************************************************/
18 /*************************************************************************/
19 /* */
20 /* This driver implements Type42 fonts as described in the */
21 /* Technical Note #5012 from Adobe, with these limitations: */
22 /* */
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 */
26 /* tables. */
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. */
31 /* */
32 /* In other words, this driver supports Type42 fonts derived from */
33 /* TrueType fonts in a non-CID manner, as done by usual conversion */
34 /* programs. */
35 /* */
36 /*************************************************************************/
39 #include "t42drivr.h"
40 #include "t42objs.h"
41 #include "t42error.h"
42 #include FT_INTERNAL_DEBUG_H
45 #undef FT_COMPONENT
46 #define FT_COMPONENT trace_t42
49 static FT_Error
50 t42_get_glyph_name( T42_Face face,
51 FT_UInt glyph_index,
52 FT_Pointer buffer,
53 FT_UInt buffer_max )
55 FT_String* gname;
58 gname = face->type1.glyph_names[glyph_index];
60 if ( buffer_max > 0 )
62 FT_UInt len = (FT_UInt)( ft_strlen( gname ) );
65 if ( len >= buffer_max )
66 len = buffer_max - 1;
68 FT_MEM_COPY( buffer, gname, len );
69 ((FT_Byte*)buffer)[len] = 0;
72 return T42_Err_Ok;
76 static const char*
77 t42_get_ps_name( T42_Face face )
79 return (const char*)face->type1.font_name;
83 static FT_UInt
84 t42_get_name_index( T42_Face face,
85 FT_String* glyph_name )
87 FT_Int i;
88 FT_String* gname;
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] );
99 return 0;
103 static FT_Module_Interface
104 T42_Get_Interface( FT_Driver driver,
105 const FT_String* t42_interface )
107 FT_UNUSED( driver );
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;
119 return 0;
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,
130 #else
132 #endif
134 sizeof ( T42_DriverRec ),
136 "type42",
137 0x10000L,
138 0x20000L,
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,
172 /* END */