Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /***************************************************************************/ |
2 | /* */ |
||
3 | /* t42drivr.c */ |
||
4 | /* */ |
||
5 | /* High-level Type 42 driver interface (body). */ |
||
6 | /* */ |
||
7 | /* Copyright 2002-2004, 2006, 2007, 2009, 2011, 2013 by */ |
||
8 | /* Roberto Alameda. */ |
||
9 | /* */ |
||
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. */ |
||
15 | /* */ |
||
16 | /***************************************************************************/ |
||
17 | |||
18 | |||
19 | /*************************************************************************/ |
||
20 | /* */ |
||
21 | /* This driver implements Type42 fonts as described in the */ |
||
22 | /* Technical Note #5012 from Adobe, with these limitations: */ |
||
23 | /* */ |
||
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 */ |
||
27 | /* tables. */ |
||
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. */ |
||
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 | /*************************************************************************/ |
||
37 | |||
38 | |||
39 | #include "t42drivr.h" |
||
40 | #include "t42objs.h" |
||
41 | #include "t42error.h" |
||
42 | #include FT_INTERNAL_DEBUG_H |
||
43 | |||
44 | #include FT_SERVICE_XFREE86_NAME_H |
||
45 | #include FT_SERVICE_GLYPH_DICT_H |
||
46 | #include FT_SERVICE_POSTSCRIPT_NAME_H |
||
47 | #include FT_SERVICE_POSTSCRIPT_INFO_H |
||
48 | |||
49 | #undef FT_COMPONENT |
||
50 | #define FT_COMPONENT trace_t42 |
||
51 | |||
52 | |||
53 | /* |
||
54 | * |
||
55 | * GLYPH DICT SERVICE |
||
56 | * |
||
57 | */ |
||
58 | |||
59 | static FT_Error |
||
60 | t42_get_glyph_name( T42_Face face, |
||
61 | FT_UInt glyph_index, |
||
62 | FT_Pointer buffer, |
||
63 | FT_UInt buffer_max ) |
||
64 | { |
||
65 | FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max ); |
||
66 | |||
67 | return FT_Err_Ok; |
||
68 | } |
||
69 | |||
70 | |||
71 | static FT_UInt |
||
72 | t42_get_name_index( T42_Face face, |
||
73 | FT_String* glyph_name ) |
||
74 | { |
||
75 | FT_Int i; |
||
76 | |||
77 | |||
78 | for ( i = 0; i < face->type1.num_glyphs; i++ ) |
||
79 | { |
||
80 | FT_String* gname = face->type1.glyph_names[i]; |
||
81 | |||
82 | |||
83 | if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) ) |
||
84 | return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] ); |
||
85 | } |
||
86 | |||
87 | return 0; |
||
88 | } |
||
89 | |||
90 | |||
91 | static const FT_Service_GlyphDictRec t42_service_glyph_dict = |
||
92 | { |
||
93 | (FT_GlyphDict_GetNameFunc) t42_get_glyph_name, |
||
94 | (FT_GlyphDict_NameIndexFunc)t42_get_name_index |
||
95 | }; |
||
96 | |||
97 | |||
98 | /* |
||
99 | * |
||
100 | * POSTSCRIPT NAME SERVICE |
||
101 | * |
||
102 | */ |
||
103 | |||
104 | static const char* |
||
105 | t42_get_ps_font_name( T42_Face face ) |
||
106 | { |
||
107 | return (const char*)face->type1.font_name; |
||
108 | } |
||
109 | |||
110 | |||
111 | static const FT_Service_PsFontNameRec t42_service_ps_font_name = |
||
112 | { |
||
113 | (FT_PsName_GetFunc)t42_get_ps_font_name |
||
114 | }; |
||
115 | |||
116 | |||
117 | /* |
||
118 | * |
||
119 | * POSTSCRIPT INFO SERVICE |
||
120 | * |
||
121 | */ |
||
122 | |||
123 | static FT_Error |
||
124 | t42_ps_get_font_info( FT_Face face, |
||
125 | PS_FontInfoRec* afont_info ) |
||
126 | { |
||
127 | *afont_info = ((T42_Face)face)->type1.font_info; |
||
128 | |||
129 | return FT_Err_Ok; |
||
130 | } |
||
131 | |||
132 | |||
133 | static FT_Error |
||
134 | t42_ps_get_font_extra( FT_Face face, |
||
135 | PS_FontExtraRec* afont_extra ) |
||
136 | { |
||
137 | *afont_extra = ((T42_Face)face)->type1.font_extra; |
||
138 | |||
139 | return FT_Err_Ok; |
||
140 | } |
||
141 | |||
142 | |||
143 | static FT_Int |
||
144 | t42_ps_has_glyph_names( FT_Face face ) |
||
145 | { |
||
146 | FT_UNUSED( face ); |
||
147 | |||
148 | return 1; |
||
149 | } |
||
150 | |||
151 | |||
152 | static FT_Error |
||
153 | t42_ps_get_font_private( FT_Face face, |
||
154 | PS_PrivateRec* afont_private ) |
||
155 | { |
||
156 | *afont_private = ((T42_Face)face)->type1.private_dict; |
||
157 | |||
158 | return FT_Err_Ok; |
||
159 | } |
||
160 | |||
161 | |||
162 | static const FT_Service_PsInfoRec t42_service_ps_info = |
||
163 | { |
||
164 | (PS_GetFontInfoFunc) t42_ps_get_font_info, |
||
165 | (PS_GetFontExtraFunc) t42_ps_get_font_extra, |
||
166 | (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, |
||
167 | (PS_GetFontPrivateFunc)t42_ps_get_font_private, |
||
168 | (PS_GetFontValueFunc) NULL /* not implemented */ |
||
169 | }; |
||
170 | |||
171 | |||
172 | /* |
||
173 | * |
||
174 | * SERVICE LIST |
||
175 | * |
||
176 | */ |
||
177 | |||
178 | static const FT_ServiceDescRec t42_services[] = |
||
179 | { |
||
180 | { FT_SERVICE_ID_GLYPH_DICT, &t42_service_glyph_dict }, |
||
181 | { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t42_service_ps_font_name }, |
||
182 | { FT_SERVICE_ID_POSTSCRIPT_INFO, &t42_service_ps_info }, |
||
183 | { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_42 }, |
||
184 | { NULL, NULL } |
||
185 | }; |
||
186 | |||
187 | |||
188 | FT_CALLBACK_DEF( FT_Module_Interface ) |
||
189 | T42_Get_Interface( FT_Module module, |
||
190 | const FT_String* t42_interface ) |
||
191 | { |
||
192 | FT_UNUSED( module ); |
||
193 | |||
194 | return ft_service_list_lookup( t42_services, t42_interface ); |
||
195 | } |
||
196 | |||
197 | |||
198 | const FT_Driver_ClassRec t42_driver_class = |
||
199 | { |
||
200 | { |
||
201 | FT_MODULE_FONT_DRIVER | |
||
202 | FT_MODULE_DRIVER_SCALABLE | |
||
203 | #ifdef TT_USE_BYTECODE_INTERPRETER |
||
204 | FT_MODULE_DRIVER_HAS_HINTER, |
||
205 | #else |
||
206 | 0, |
||
207 | #endif |
||
208 | |||
209 | sizeof ( T42_DriverRec ), |
||
210 | |||
211 | "type42", |
||
212 | 0x10000L, |
||
213 | 0x20000L, |
||
214 | |||
215 | 0, /* format interface */ |
||
216 | |||
217 | T42_Driver_Init, |
||
218 | T42_Driver_Done, |
||
219 | T42_Get_Interface, |
||
220 | }, |
||
221 | |||
222 | sizeof ( T42_FaceRec ), |
||
223 | sizeof ( T42_SizeRec ), |
||
224 | sizeof ( T42_GlyphSlotRec ), |
||
225 | |||
226 | T42_Face_Init, |
||
227 | T42_Face_Done, |
||
228 | T42_Size_Init, |
||
229 | T42_Size_Done, |
||
230 | T42_GlyphSlot_Init, |
||
231 | T42_GlyphSlot_Done, |
||
232 | |||
233 | T42_GlyphSlot_Load, |
||
234 | |||
235 | 0, /* FT_Face_GetKerningFunc */ |
||
236 | 0, /* FT_Face_AttachFunc */ |
||
237 | |||
238 | 0, /* FT_Face_GetAdvancesFunc */ |
||
239 | T42_Size_Request, |
||
240 | T42_Size_Select |
||
241 | }; |
||
242 | |||
243 | |||
244 | /* END */> |