ReactOS 0.4.15-dev-7674-gc0b4db1
t42drivr.c
Go to the documentation of this file.
1/***************************************************************************/
2/* */
3/* t42drivr.c */
4/* */
5/* High-level Type 42 driver interface (body). */
6/* */
7/* Copyright 2002-2018 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_FONT_FORMAT_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
61 FT_UInt glyph_index,
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
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_strtol( (const char *)face->type1.charstrings[i],
85 NULL, 10 );
86 }
87
88 return 0;
89 }
90
91
92 static const FT_Service_GlyphDictRec t42_service_glyph_dict =
93 {
96 };
97
98
99 /*
100 *
101 * POSTSCRIPT NAME SERVICE
102 *
103 */
104
105 static const char*
107 {
108 return (const char*)face->type1.font_name;
109 }
110
111
112 static const FT_Service_PsFontNameRec t42_service_ps_font_name =
113 {
114 (FT_PsName_GetFunc)t42_get_ps_font_name /* get_ps_font_name */
115 };
116
117
118 /*
119 *
120 * POSTSCRIPT INFO SERVICE
121 *
122 */
123
124 static FT_Error
126 PS_FontInfoRec* afont_info )
127 {
128 *afont_info = ((T42_Face)face)->type1.font_info;
129
130 return FT_Err_Ok;
131 }
132
133
134 static FT_Error
136 PS_FontExtraRec* afont_extra )
137 {
138 *afont_extra = ((T42_Face)face)->type1.font_extra;
139
140 return FT_Err_Ok;
141 }
142
143
144 static FT_Int
146 {
147 FT_UNUSED( face );
148
149 return 1;
150 }
151
152
153 static FT_Error
155 PS_PrivateRec* afont_private )
156 {
157 *afont_private = ((T42_Face)face)->type1.private_dict;
158
159 return FT_Err_Ok;
160 }
161
162
163 static const FT_Service_PsInfoRec t42_service_ps_info =
164 {
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 */
171 };
172
173
174 /*
175 *
176 * SERVICE LIST
177 *
178 */
179
181 {
186 { NULL, NULL }
187 };
188
189
192 const FT_String* t42_interface )
193 {
194 FT_UNUSED( module );
195
196 return ft_service_list_lookup( t42_services, t42_interface );
197 }
198
199
201 {
202 {
205#ifdef TT_USE_BYTECODE_INTERPRETER
207#else
208 0,
209#endif
210
211 sizeof ( T42_DriverRec ),
212
213 "type42",
214 0x10000L,
215 0x20000L,
216
217 NULL, /* module-specific interface */
218
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 */
222 },
223
224 sizeof ( T42_FaceRec ),
225 sizeof ( T42_SizeRec ),
226 sizeof ( T42_GlyphSlotRec ),
227
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 */
234
235 T42_GlyphSlot_Load, /* FT_Slot_LoadFunc load_glyph */
236
237 NULL, /* FT_Face_GetKerningFunc get_kerning */
238 NULL, /* FT_Face_AttachFunc attach_file */
239 NULL, /* FT_Face_GetAdvancesFunc get_advances */
240
241 T42_Size_Request, /* FT_Size_RequestFunc request_size */
242 T42_Size_Select /* FT_Size_SelectFunc select_size */
243 };
244
245
246/* END */
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:533
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define FT_STRCPYN(dst, src, size)
Definition: ftmemory.h:382
#define FT_MODULE_FONT_DRIVER
Definition: ftmodapi.h:110
#define FT_MODULE_DRIVER_HAS_HINTER
Definition: ftmodapi.h:119
#define FT_MODULE_DRIVER_SCALABLE
Definition: ftmodapi.h:115
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
Definition: ftobjs.c:98
#define ft_strcmp
Definition: ftstdlib.h:86
#define ft_strtol
Definition: ftstdlib.h:145
int FT_Error
Definition: fttypes.h:300
char FT_String
Definition: fttypes.h:187
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FT_SERVICE_ID_FONT_FORMAT
Definition: svfntfmt.h:34
#define FT_FONT_FORMAT_TYPE_42
Definition: svfntfmt.h:40
#define FT_SERVICE_ID_GLYPH_DICT
Definition: svgldict.h:34
FT_UInt(* FT_GlyphDict_NameIndexFunc)(FT_Face face, FT_String *glyph_name)
Definition: svgldict.h:44
FT_Error(* FT_GlyphDict_GetNameFunc)(FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max)
Definition: svgldict.h:38
#define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME
Definition: svpostnm.h:37
const char *(* FT_PsName_GetFunc)(FT_Face face)
Definition: svpostnm.h:41
FT_Long(* PS_GetFontValueFunc)(FT_Face face, PS_Dict_Keys key, FT_UInt idx, void *value, FT_Long value_len)
Definition: svpsinfo.h:48
FT_Error(* PS_GetFontInfoFunc)(FT_Face face, PS_FontInfoRec *afont_info)
Definition: svpsinfo.h:33
FT_Int(* PS_HasGlyphNamesFunc)(FT_Face face)
Definition: svpsinfo.h:41
FT_Error(* PS_GetFontExtraFunc)(FT_Face face, PS_FontExtraRec *afont_extra)
Definition: svpsinfo.h:37
FT_Error(* PS_GetFontPrivateFunc)(FT_Face face, PS_PrivateRec *afont_private)
Definition: svpsinfo.h:44
#define FT_SERVICE_ID_POSTSCRIPT_INFO
Definition: svpsinfo.h:29
FT_BEGIN_HEADER struct PS_FontInfoRec_ PS_FontInfoRec
const FT_Driver_ClassRec t42_driver_class
Definition: t42drivr.c:200
static FT_Error t42_ps_get_font_extra(FT_Face face, PS_FontExtraRec *afont_extra)
Definition: t42drivr.c:135
static const char * t42_get_ps_font_name(T42_Face face)
Definition: t42drivr.c:106
static const FT_Service_PsFontNameRec t42_service_ps_font_name
Definition: t42drivr.c:112
static const FT_Service_GlyphDictRec t42_service_glyph_dict
Definition: t42drivr.c:92
static FT_Error t42_get_glyph_name(T42_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max)
Definition: t42drivr.c:60
static FT_UInt t42_get_name_index(T42_Face face, FT_String *glyph_name)
Definition: t42drivr.c:72
static const FT_ServiceDescRec t42_services[]
Definition: t42drivr.c:180
static const FT_Service_PsInfoRec t42_service_ps_info
Definition: t42drivr.c:163
static FT_Error t42_ps_get_font_info(FT_Face face, PS_FontInfoRec *afont_info)
Definition: t42drivr.c:125
static FT_Error t42_ps_get_font_private(FT_Face face, PS_PrivateRec *afont_private)
Definition: t42drivr.c:154
static FT_Int t42_ps_has_glyph_names(FT_Face face)
Definition: t42drivr.c:145
T42_Get_Interface(FT_Module module, const FT_String *t42_interface)
Definition: t42drivr.c:191
T42_GlyphSlot_Init(FT_GlyphSlot t42slot)
Definition: t42objs.c:578
T42_Size_Done(FT_Size t42size)
Definition: t42objs.c:560
T42_Size_Init(FT_Size size)
Definition: t42objs.c:502
T42_Driver_Done(FT_Module module)
Definition: t42objs.c:495
T42_Driver_Init(FT_Module module)
Definition: t42objs.c:475
T42_GlyphSlot_Load(FT_GlyphSlot glyph, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: t42objs.c:638
T42_Face_Done(FT_Face t42face)
Definition: t42objs.c:405
T42_Size_Select(FT_Size t42size, FT_ULong strike_index)
Definition: t42objs.c:540
T42_Size_Request(FT_Size t42size, FT_Size_Request req)
Definition: t42objs.c:521
T42_GlyphSlot_Done(FT_GlyphSlot t42slot)
Definition: t42objs.c:603
T42_Face_Init(FT_Stream stream, FT_Face t42face, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
Definition: t42objs.c:164
FT_BEGIN_HEADER struct T42_SizeRec_ T42_SizeRec
struct T42_GlyphSlotRec_ T42_GlyphSlotRec
struct T42_DriverRec_ T42_DriverRec
FT_BEGIN_HEADER struct T42_FaceRec_ * T42_Face
FT_BEGIN_HEADER struct T42_FaceRec_ T42_FaceRec
#define const
Definition: zconf.h:233