1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
/***************************************************************************/
/* */
/* sfdriver.c */
/* */
/* High-level SFNT driver interface (body). */
/* */
/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "ft2build.h"
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_OBJECTS_H
#include FT_TRUETYPE_IDS_H
#include "sfdriver.h"
#include "ttload.h"
#include "sfobjs.h"
#include "sferrors.h"
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#include "ttsbit.h"
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.h"
#endif
#include "ttcmap.h"
#include "ttmtx.h"
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_TT_CMAP_H
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_MULTIPLE_MASTERS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#endif
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_sfdriver
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
/*
* GLYPH DICT SERVICE
*
*/
static FT_Error
sfnt_get_glyph_name( FT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
FT_Error error;
error = tt_face_get_ps_name( (TT_Face)face, glyph_index, &gname );
if ( !error )
FT_STRCPYN( buffer, gname, buffer_max );
return error;
}
FT_DEFINE_SERVICE_GLYPHDICTREC(
sfnt_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name /* get_name */
)
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
/*
* TT CMAP INFO
*/
FT_DEFINE_SERVICE_TTCMAPSREC(
tt_service_get_cmap_info,
(TT_CMap_Info_GetFunc)tt_get_cmap_info /* get_cmap_info */
)
/*
* SERVICE LIST
*/
#if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_DEFINE_SERVICEDESCREC2(
sfnt_services,
FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict,
FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
#else
FT_DEFINE_SERVICEDESCREC2(
sfnt_services,
FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table,
FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info )
#endif
FT_CALLBACK_DEF( FT_Module_Interface )
sfnt_get_interface( FT_Module module,
const char* module_interface )
{
FT_UNUSED( module );
return ft_service_list_lookup( sfnt_services, module_interface );
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#define PUT_EMBEDDED_BITMAPS( a ) a
#else
#define PUT_EMBEDDED_BITMAPS( a ) NULL
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#define PUT_PS_NAMES( a ) a
#else
#define PUT_PS_NAMES( a ) NULL
#endif
FT_DEFINE_SFNT_INTERFACE(
sfnt_interface,
tt_face_goto_table, /* TT_Loader_GotoTableFunc goto_table */
sfnt_init_face, /* TT_Init_Face_Func init_face */
sfnt_load_face, /* TT_Load_Face_Func load_face */
sfnt_done_face, /* TT_Done_Face_Func done_face */
sfnt_get_interface, /* FT_Module_Requester get_interface */
tt_face_load_any, /* TT_Load_Any_Func load_any */
tt_face_load_head, /* TT_Load_Table_Func load_head */
tt_face_load_hhea, /* TT_Load_Metrics_Func load_hhea */
tt_face_load_cmap, /* TT_Load_Table_Func load_cmap */
tt_face_load_maxp, /* TT_Load_Table_Func load_maxp */
tt_face_load_os2, /* TT_Load_Table_Func load_os2 */
tt_face_load_post, /* TT_Load_Table_Func load_post */
tt_face_load_name, /* TT_Load_Table_Func load_name */
tt_face_free_name, /* TT_Free_Table_Func free_name */
NULL, /* TT_Load_Table_Func load_kern */
NULL, /* TT_Load_Table_Func load_gasp */
NULL, /* TT_Load_Table_Func load_init */
/* see `ttload.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
/* TT_Load_Table_Func load_bhed */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ),
/* TT_Load_SBit_Image_Func load_sbit_image */
/* see `ttpost.h' */
PUT_PS_NAMES( tt_face_get_ps_name ),
/* TT_Get_PS_Name_Func get_psname */
PUT_PS_NAMES( tt_face_free_ps_names ),
/* TT_Free_Table_Func free_psnames */
/* since version 2.1.8 */
NULL, /* TT_Face_GetKerningFunc get_kerning */
/* since version 2.2 */
tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */
tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */
/* see `ttsbit.h' and `sfnt.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ),
/* TT_Load_Table_Func load_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ),
/* TT_Free_Table_Func free_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
/* TT_Set_SBit_Strike_Func set_sbit_strike */
PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
/* TT_Load_Strike_Metrics_Func load_strike_metrics */
tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */
tt_face_get_name /* TT_Get_Name_Func get_name */
)
FT_DEFINE_MODULE(
sfnt_module_class,
0, /* not a font driver or renderer */
sizeof ( FT_ModuleRec ),
"sfnt", /* driver name */
0x10000L, /* driver version 1.0 */
0x20000L, /* driver requires FreeType 2.0 or higher */
(const void*)&sfnt_interface, /* module specific interface */
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) sfnt_get_interface /* get_interface */
)
/* END */
|