]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/freetype/sfnt/sfdriver.c
more MS-DOS stuff in generic wxFileDialog
[wxWidgets.git] / src / freetype / sfnt / sfdriver.c
... / ...
CommitLineData
1/***************************************************************************/
2/* */
3/* sfdriver.c */
4/* */
5/* High-level SFNT driver interface (body). */
6/* */
7/* Copyright 1996-2000 by */
8/* David Turner, Robert Wilhelm, and Werner Lemberg. */
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#include <freetype/internal/sfnt.h>
20#include <freetype/internal/ftobjs.h>
21
22
23#ifdef FT_FLAT_COMPILE
24
25#include "sfdriver.h"
26#include "ttload.h"
27#include "ttsbit.h"
28#include "ttpost.h"
29#include "ttcmap.h"
30#include "sfobjs.h"
31
32#else
33
34#include <sfnt/sfdriver.h>
35#include <sfnt/ttload.h>
36#include <sfnt/ttsbit.h>
37#include <sfnt/ttpost.h>
38#include <sfnt/ttcmap.h>
39#include <sfnt/sfobjs.h>
40
41#endif
42
43
44#include <string.h> /* for strcmp() */
45
46
47 static
48 void* get_sfnt_table( TT_Face face,
49 FT_Sfnt_Tag tag )
50 {
51 void* table;
52
53
54 switch ( tag )
55 {
56 case ft_sfnt_head:
57 table = &face->header;
58 break;
59
60 case ft_sfnt_hhea:
61 table = &face->horizontal;
62 break;
63
64 case ft_sfnt_vhea:
65 table = face->vertical_info ? &face->vertical : 0;
66 break;
67
68 case ft_sfnt_os2:
69 table = face->os2.version == 0xFFFF ? 0 : &face->os2;
70 break;
71
72 case ft_sfnt_post:
73 table = &face->postscript;
74 break;
75
76 case ft_sfnt_maxp:
77 table = &face->max_profile;
78 break;
79
80 case ft_sfnt_pclt:
81 table = face->pclt.Version ? &face->pclt : 0;
82 break;
83
84 default:
85 table = 0;
86 }
87
88 return table;
89 }
90
91
92#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
93
94
95 static
96 FT_Error get_sfnt_glyph_name( TT_Face face,
97 FT_UInt glyph_index,
98 FT_Pointer buffer,
99 FT_UInt buffer_max )
100 {
101 FT_String* gname;
102 FT_Error error;
103
104
105 error = TT_Get_PS_Name( face, glyph_index, &gname );
106 if ( !error && buffer_max > 0 )
107 {
108 FT_UInt len = strlen( gname );
109
110
111 if ( len >= buffer_max )
112 len = buffer_max - 1;
113
114 MEM_Copy( buffer, gname, len );
115 ((FT_Byte*)buffer)[len] = 0;
116 }
117
118 return error;
119 }
120
121
122#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
123
124
125 static
126 FT_Module_Interface SFNT_Get_Interface( FT_Module module,
127 const char* interface )
128 {
129 FT_UNUSED( module );
130
131 if ( strcmp( interface, "get_sfnt" ) == 0 )
132 return (FT_Module_Interface)get_sfnt_table;
133
134#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
135 if ( strcmp( interface, "glyph_name" ) == 0 )
136 return (FT_Module_Interface)get_sfnt_glyph_name;
137#endif
138 return 0;
139 }
140
141
142 static
143 const SFNT_Interface sfnt_interface =
144 {
145 TT_Goto_Table,
146
147 SFNT_Init_Face,
148 SFNT_Load_Face,
149 SFNT_Done_Face,
150 SFNT_Get_Interface,
151
152 TT_Load_Any,
153 TT_Load_SFNT_Header,
154 TT_Load_Directory,
155
156 TT_Load_Header,
157 TT_Load_Metrics_Header,
158 TT_Load_CMap,
159 TT_Load_MaxProfile,
160 TT_Load_OS2,
161 TT_Load_PostScript,
162
163 TT_Load_Names,
164 TT_Free_Names,
165
166 TT_Load_Hdmx,
167 TT_Free_Hdmx,
168
169 TT_Load_Kern,
170 TT_Load_Gasp,
171 TT_Load_PCLT,
172
173#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
174
175 /* see `ttsbit.h' */
176 TT_Load_SBit_Strikes,
177 TT_Load_SBit_Image,
178 TT_Free_SBit_Strikes,
179
180#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
181
182 0,
183 0,
184 0,
185
186#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
187
188#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
189
190 /* see `ttpost.h' */
191 TT_Get_PS_Name,
192 TT_Free_Post_Names,
193
194#else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
195
196 0,
197 0,
198
199#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
200
201 /* see `ttcmap.h' */
202 TT_CharMap_Load,
203 TT_CharMap_Free,
204 };
205
206
207 const
208 FT_Module_Class sfnt_module_class =
209 {
210 0, /* not a font driver or renderer */
211 sizeof( FT_ModuleRec ),
212
213 "sfnt", /* driver name */
214 0x10000L, /* driver version 1.0 */
215 0x20000L, /* driver requires FreeType 2.0 or higher */
216
217 (const void*)&sfnt_interface, /* module specific interface */
218
219 (FT_Module_Constructor)0,
220 (FT_Module_Destructor) 0,
221 (FT_Module_Requester) SFNT_Get_Interface
222 };
223
224
225/* END */