blob: 84a7c50793c5e77a8bc3fb3e248a13842f2c850e [file] [log] [blame]
David Turner19ed8af2000-12-08 02:42:29 +00001/***************************************************************************/
2/* */
3/* cffobjs.c */
4/* */
5/* OpenType objects manager (body). */
6/* */
Werner Lemberg415235d2001-06-28 17:49:10 +00007/* Copyright 1996-2001 by */
David Turner19ed8af2000-12-08 02:42:29 +00008/* 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
Werner Lembergcc069be2000-12-08 16:17:16 +000018
David Turner19ed8af2000-12-08 02:42:29 +000019#include <ft2build.h>
20#include FT_INTERNAL_DEBUG_H
21#include FT_INTERNAL_CALC_H
22#include FT_INTERNAL_STREAM_H
23#include FT_ERRORS_H
David Turner6ce03ef2001-03-20 14:50:04 +000024#include FT_TRUETYPE_IDS_H
David Turner19ed8af2000-12-08 02:42:29 +000025#include FT_TRUETYPE_TAGS_H
26#include FT_INTERNAL_SFNT_H
27#include FT_INTERNAL_POSTSCRIPT_NAMES_H
David Turnerc8087482001-12-20 13:14:18 +000028#include FT_INTERNAL_POSTSCRIPT_HINTS_H
David Turner8d3a4012001-03-20 11:14:24 +000029#include "cffobjs.h"
30#include "cffload.h"
Werner Lemberg1f7f0e82001-06-06 17:30:41 +000031
32#include "cfferrs.h"
Werner Lembergcc069be2000-12-08 16:17:16 +000033
David Turner19ed8af2000-12-08 02:42:29 +000034#include <string.h> /* for strlen() */
35
36
37 /*************************************************************************/
38 /* */
39 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
40 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
41 /* messages during execution. */
42 /* */
43#undef FT_COMPONENT
Tom Kacvinsky8d1f6042001-01-03 00:21:59 +000044#define FT_COMPONENT trace_cffobjs
David Turner19ed8af2000-12-08 02:42:29 +000045
46
David Turnerc8087482001-12-20 13:14:18 +000047
48
49 /*************************************************************************/
50 /* */
51 /* SIZE FUNCTIONS */
52 /* */
Werner Lembergf41e71a2001-12-20 21:22:02 +000053 /* Note that we store the global hints in the size's "internal" root */
54 /* field. */
David Turnerc8087482001-12-20 13:14:18 +000055 /* */
56 /*************************************************************************/
57
58
59 static PSH_Globals_Funcs
60 CFF_Size_Get_Globals_Funcs( CFF_Size size )
61 {
Werner Lemberg0d9165e2002-03-07 21:59:59 +000062 CFF_Face face = (CFF_Face)size->face;
David Turnerab4fc4d2002-03-14 08:57:10 +000063 CFF_Font font = (CFF_FontRec *)face->extra.data;
Werner Lemberg0d9165e2002-03-07 21:59:59 +000064 PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
65 FT_Module module;
David Turnerc8087482001-12-20 13:14:18 +000066
67
68 module = FT_Get_Module( size->face->driver->root.library,
69 "pshinter" );
70 return ( module && pshinter && pshinter->get_globals_funcs )
71 ? pshinter->get_globals_funcs( module )
Werner Lembergf41e71a2001-12-20 21:22:02 +000072 : 0;
David Turnerc8087482001-12-20 13:14:18 +000073 }
74
75
David Turnerbc82f1b2002-03-01 02:26:22 +000076 FT_LOCAL_DEF( void )
David Turnerc8087482001-12-20 13:14:18 +000077 CFF_Size_Done( CFF_Size size )
78 {
79 if ( size->internal )
80 {
81 PSH_Globals_Funcs funcs;
82
83
84 funcs = CFF_Size_Get_Globals_Funcs( size );
85 if ( funcs )
86 funcs->destroy( (PSH_Globals)size->internal );
87
88 size->internal = 0;
89 }
90 }
91
92
David Turnerbc82f1b2002-03-01 02:26:22 +000093 FT_LOCAL_DEF( FT_Error )
David Turnerc8087482001-12-20 13:14:18 +000094 CFF_Size_Init( CFF_Size size )
95 {
96 FT_Error error = 0;
97 PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size );
98
99
100 if ( funcs )
101 {
David Turner29644172002-02-28 18:59:37 +0000102 PSH_Globals globals;
103 CFF_Face face = (CFF_Face)size->face;
David Turnerab4fc4d2002-03-14 08:57:10 +0000104 CFF_Font font = (CFF_FontRec *)face->extra.data;
105 CFF_SubFont subfont = &font->top_font;
David Turnerc8087482001-12-20 13:14:18 +0000106
David Turner29644172002-02-28 18:59:37 +0000107 CFF_Private cpriv = &subfont->private_dict;
108 PS_PrivateRec priv;
David Turnerc8087482001-12-20 13:14:18 +0000109
Werner Lembergf41e71a2001-12-20 21:22:02 +0000110
111 /* IMPORTANT: The CFF and Type1 private dictionaries have */
112 /* slightly different structures; we need to */
113 /* synthetize a type1 dictionary on the fly here. */
David Turnerc8087482001-12-20 13:14:18 +0000114
115 {
Werner Lembergf41e71a2001-12-20 21:22:02 +0000116 FT_UInt n, count;
David Turnerc8087482001-12-20 13:14:18 +0000117
Werner Lembergf41e71a2001-12-20 21:22:02 +0000118
David Turnere459d742002-03-22 13:52:37 +0000119 FT_MEM_SET( &priv, 0, sizeof ( priv ) );
David Turnerc8087482001-12-20 13:14:18 +0000120
121 count = priv.num_blue_values = cpriv->num_blue_values;
122 for ( n = 0; n < count; n++ )
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000123 priv.blue_values[n] = (FT_Short)cpriv->blue_values[n];
David Turnerc8087482001-12-20 13:14:18 +0000124
125 count = priv.num_other_blues = cpriv->num_other_blues;
126 for ( n = 0; n < count; n++ )
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000127 priv.other_blues[n] = (FT_Short)cpriv->other_blues[n];
David Turnerc8087482001-12-20 13:14:18 +0000128
129 count = priv.num_family_blues = cpriv->num_family_blues;
130 for ( n = 0; n < count; n++ )
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000131 priv.family_blues[n] = (FT_Short)cpriv->family_blues[n];
David Turnerc8087482001-12-20 13:14:18 +0000132
133 count = priv.num_family_other_blues = cpriv->num_family_other_blues;
134 for ( n = 0; n < count; n++ )
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000135 priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
David Turnerc8087482001-12-20 13:14:18 +0000136
137 priv.blue_scale = cpriv->blue_scale;
138 priv.blue_shift = cpriv->blue_shift;
139 priv.blue_fuzz = cpriv->blue_fuzz;
140
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000141 priv.standard_width[0] = (FT_UShort)cpriv->standard_width;
142 priv.standard_height[0] = (FT_UShort)cpriv->standard_height;
Werner Lembergf41e71a2001-12-20 21:22:02 +0000143
David Turnerc8087482001-12-20 13:14:18 +0000144 count = priv.num_snap_widths = cpriv->num_snap_widths;
145 for ( n = 0; n < count; n++ )
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000146 priv.snap_widths[n] = (FT_Short)cpriv->snap_widths[n];
Werner Lembergf41e71a2001-12-20 21:22:02 +0000147
David Turnerc8087482001-12-20 13:14:18 +0000148 count = priv.num_snap_heights = cpriv->num_snap_heights;
149 for ( n = 0; n < count; n++ )
Werner Lemberg3975e2e2002-01-09 21:01:18 +0000150 priv.snap_heights[n] = (FT_Short)cpriv->snap_heights[n];
David Turnerc8087482001-12-20 13:14:18 +0000151
Werner Lembergf41e71a2001-12-20 21:22:02 +0000152 priv.force_bold = cpriv->force_bold;
153 priv.language_group = cpriv->language_group;
154 priv.lenIV = cpriv->lenIV;
David Turnerc8087482001-12-20 13:14:18 +0000155 }
156
157 error = funcs->create( size->face->memory, &priv, &globals );
158 if ( !error )
159 size->internal = (FT_Size_Internal)(void*)globals;
160 }
161
162 return error;
163 }
164
165
David Turnerbc82f1b2002-03-01 02:26:22 +0000166 FT_LOCAL_DEF( FT_Error )
David Turnerc8087482001-12-20 13:14:18 +0000167 CFF_Size_Reset( CFF_Size size )
168 {
169 PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size );
170 FT_Error error = 0;
171
172
173 if ( funcs )
174 error = funcs->set_scale( (PSH_Globals)size->internal,
175 size->metrics.x_scale,
176 size->metrics.y_scale,
177 0, 0 );
178 return error;
179 }
180
181
182 /*************************************************************************/
183 /* */
184 /* SLOT FUNCTIONS */
185 /* */
186 /*************************************************************************/
187
David Turnerbc82f1b2002-03-01 02:26:22 +0000188 FT_LOCAL_DEF( void )
David Turnerc8087482001-12-20 13:14:18 +0000189 CFF_GlyphSlot_Done( CFF_GlyphSlot slot )
190 {
191 slot->root.internal->glyph_hints = 0;
192 }
193
194
David Turnerbc82f1b2002-03-01 02:26:22 +0000195 FT_LOCAL_DEF( FT_Error )
Werner Lembergf41e71a2001-12-20 21:22:02 +0000196 CFF_GlyphSlot_Init( CFF_GlyphSlot slot )
David Turnerc8087482001-12-20 13:14:18 +0000197 {
Werner Lemberg0d9165e2002-03-07 21:59:59 +0000198 CFF_Face face = (CFF_Face)slot->root.face;
David Turnerab4fc4d2002-03-14 08:57:10 +0000199 CFF_Font font = (CFF_FontRec *)face->extra.data;
Werner Lemberg0d9165e2002-03-07 21:59:59 +0000200 PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
David Turnerc8087482001-12-20 13:14:18 +0000201
Werner Lembergf41e71a2001-12-20 21:22:02 +0000202
203 if ( pshinter )
David Turnerc8087482001-12-20 13:14:18 +0000204 {
205 FT_Module module;
206
Werner Lembergf41e71a2001-12-20 21:22:02 +0000207
208 module = FT_Get_Module( slot->root.face->driver->root.library,
209 "pshinter" );
210 if ( module )
David Turnerc8087482001-12-20 13:14:18 +0000211 {
212 T2_Hints_Funcs funcs;
213
Werner Lembergf41e71a2001-12-20 21:22:02 +0000214
David Turnerc8087482001-12-20 13:14:18 +0000215 funcs = pshinter->get_t2_funcs( module );
216 slot->root.internal->glyph_hints = (void*)funcs;
217 }
218 }
Werner Lembergf41e71a2001-12-20 21:22:02 +0000219
David Turnerc8087482001-12-20 13:14:18 +0000220 return 0;
221 }
222
223
David Turner19ed8af2000-12-08 02:42:29 +0000224 /*************************************************************************/
225 /* */
226 /* FACE FUNCTIONS */
227 /* */
228 /*************************************************************************/
229
Werner Lemberg93616ec2001-06-27 19:46:12 +0000230 static FT_String*
231 CFF_StrCopy( FT_Memory memory,
232 const FT_String* source )
David Turner19ed8af2000-12-08 02:42:29 +0000233 {
234 FT_Error error;
235 FT_String* result = 0;
236 FT_Int len = (FT_Int)strlen( source );
237
238
David Turnere459d742002-03-22 13:52:37 +0000239 if ( !FT_ALLOC( result, len + 1 ) )
David Turner19ed8af2000-12-08 02:42:29 +0000240 {
David Turnere459d742002-03-22 13:52:37 +0000241 FT_MEM_COPY( result, source, len );
David Turner19ed8af2000-12-08 02:42:29 +0000242 result[len] = 0;
243 }
Werner Lembergb5349a92002-02-19 16:30:15 +0000244
245 FT_UNUSED( error );
246
David Turner19ed8af2000-12-08 02:42:29 +0000247 return result;
248 }
249
250
David Turner19ed8af2000-12-08 02:42:29 +0000251
252
Werner Lemberg93616ec2001-06-27 19:46:12 +0000253 static FT_Encoding
254 find_encoding( int platform_id,
255 int encoding_id )
David Turner19ed8af2000-12-08 02:42:29 +0000256 {
257 typedef struct TEncoding
258 {
259 int platform_id;
260 int encoding_id;
261 FT_Encoding encoding;
262
263 } TEncoding;
264
265 static
266 const TEncoding tt_encodings[] =
267 {
268 { TT_PLATFORM_ISO, -1, ft_encoding_unicode },
269
270 { TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode },
271
272 { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman },
273
274 { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
275 { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis },
276 { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 },
277 { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 },
278 { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, ft_encoding_wansung },
279 { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, ft_encoding_johab }
280 };
281
282 const TEncoding *cur, *limit;
283
284
285 cur = tt_encodings;
286 limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
287
288 for ( ; cur < limit; cur++ )
289 {
290 if ( cur->platform_id == platform_id )
291 {
292 if ( cur->encoding_id == encoding_id ||
293 cur->encoding_id == -1 )
294 return cur->encoding;
295 }
296 }
297
298 return ft_encoding_none;
299 }
300
301
David Turnerbc82f1b2002-03-01 02:26:22 +0000302 FT_LOCAL_DEF( FT_Error )
David Turnerc8087482001-12-20 13:14:18 +0000303 CFF_Face_Init( FT_Stream stream,
Werner Lemberg93616ec2001-06-27 19:46:12 +0000304 CFF_Face face,
305 FT_Int face_index,
306 FT_Int num_params,
307 FT_Parameter* params )
David Turner19ed8af2000-12-08 02:42:29 +0000308 {
Werner Lembergf41e71a2001-12-20 21:22:02 +0000309 FT_Error error;
David Turner4e7eeee2002-02-28 16:10:29 +0000310 SFNT_Service sfnt;
311 PSNames_Service psnames;
312 PSHinter_Service pshinter;
Werner Lembergf41e71a2001-12-20 21:22:02 +0000313 FT_Bool pure_cff = 1;
314 FT_Bool sfnt_format = 0;
David Turner19ed8af2000-12-08 02:42:29 +0000315
316
David Turner4e7eeee2002-02-28 16:10:29 +0000317 sfnt = (SFNT_Service)FT_Get_Module_Interface(
David Turner19ed8af2000-12-08 02:42:29 +0000318 face->root.driver->root.library, "sfnt" );
319 if ( !sfnt )
320 goto Bad_Format;
321
David Turner4e7eeee2002-02-28 16:10:29 +0000322 psnames = (PSNames_Service)FT_Get_Module_Interface(
David Turner19ed8af2000-12-08 02:42:29 +0000323 face->root.driver->root.library, "psnames" );
324
David Turner4e7eeee2002-02-28 16:10:29 +0000325 pshinter = (PSHinter_Service)FT_Get_Module_Interface(
David Turnerc8087482001-12-20 13:14:18 +0000326 face->root.driver->root.library, "pshinter" );
327
David Turner19ed8af2000-12-08 02:42:29 +0000328 /* create input stream from resource */
David Turner7d3a2642002-03-20 10:49:31 +0000329 if ( FT_STREAM_SEEK( 0 ) )
David Turner19ed8af2000-12-08 02:42:29 +0000330 goto Exit;
331
332 /* check that we have a valid OpenType file */
333 error = sfnt->init_face( stream, face, face_index, num_params, params );
334 if ( !error )
335 {
336 if ( face->format_tag != 0x4F54544FL ) /* `OTTO'; OpenType/CFF font */
337 {
338 FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
339 goto Bad_Format;
340 }
341
Werner Lembergcc069be2000-12-08 16:17:16 +0000342 /* if we are performing a simple font format check, exit immediately */
David Turner19ed8af2000-12-08 02:42:29 +0000343 if ( face_index < 0 )
Tom Kacvinsky8d1f6042001-01-03 00:21:59 +0000344 return CFF_Err_Ok;
David Turner19ed8af2000-12-08 02:42:29 +0000345
346 sfnt_format = 1;
347
Werner Lembergcc069be2000-12-08 16:17:16 +0000348 /* now, the font can be either an OpenType/CFF font, or an SVG CEF */
349 /* font in the later case; it doesn't have a `head' table */
David Turner19ed8af2000-12-08 02:42:29 +0000350 error = face->goto_table( face, TTAG_head, stream, 0 );
351 if ( !error )
352 {
353 pure_cff = 0;
354
Werner Lembergcc069be2000-12-08 16:17:16 +0000355 /* load font directory */
David Turner19ed8af2000-12-08 02:42:29 +0000356 error = sfnt->load_face( stream, face,
357 face_index, num_params, params );
358 if ( error )
359 goto Exit;
360 }
361 else
362 {
363 /* load the `cmap' table by hand */
364 error = sfnt->load_charmaps( face, stream );
365 if ( error )
366 goto Exit;
367
Werner Lembergcc069be2000-12-08 16:17:16 +0000368 /* XXX: we don't load the GPOS table, as OpenType Layout */
369 /* support will be added later to a layout library on top of */
370 /* FreeType 2 */
David Turner19ed8af2000-12-08 02:42:29 +0000371 }
372
373 /* now, load the CFF part of the file */
374 error = face->goto_table( face, TTAG_CFF, stream, 0 );
375 if ( error )
376 goto Exit;
377 }
378 else
379 {
380 /* rewind to start of file; we are going to load a pure-CFF font */
David Turner7d3a2642002-03-20 10:49:31 +0000381 if ( FT_STREAM_SEEK( 0 ) )
David Turner19ed8af2000-12-08 02:42:29 +0000382 goto Exit;
Werner Lemberg1429db62001-04-02 23:54:01 +0000383 error = CFF_Err_Ok;
David Turner19ed8af2000-12-08 02:42:29 +0000384 }
385
386 /* now load and parse the CFF table in the file */
387 {
David Turnerab4fc4d2002-03-14 08:57:10 +0000388 CFF_Font cff;
David Turner19ed8af2000-12-08 02:42:29 +0000389 FT_Memory memory = face->root.memory;
390 FT_Face root;
391 FT_UInt flags;
David Turner19ed8af2000-12-08 02:42:29 +0000392
393
David Turnere459d742002-03-22 13:52:37 +0000394 if ( FT_NEW( cff ) )
David Turner19ed8af2000-12-08 02:42:29 +0000395 goto Exit;
396
David Turner19ed8af2000-12-08 02:42:29 +0000397 face->extra.data = cff;
398 error = CFF_Load_Font( stream, face_index, cff );
399 if ( error )
400 goto Exit;
401
David Turnerc8087482001-12-20 13:14:18 +0000402 cff->pshinter = pshinter;
Werner Lembergf41e71a2001-12-20 21:22:02 +0000403
David Turner19ed8af2000-12-08 02:42:29 +0000404 /* Complement the root flags with some interesting information. */
Werner Lembergcc069be2000-12-08 16:17:16 +0000405 /* Note that this is only necessary for pure CFF and CEF fonts. */
David Turner19ed8af2000-12-08 02:42:29 +0000406
Werner Lembergf41e71a2001-12-20 21:22:02 +0000407 root = &face->root;
David Turnerc8087482001-12-20 13:14:18 +0000408 root->num_glyphs = cff->num_glyphs;
Werner Lembergf41e71a2001-12-20 21:22:02 +0000409
David Turner19ed8af2000-12-08 02:42:29 +0000410 if ( pure_cff )
411 {
David Turnerab4fc4d2002-03-14 08:57:10 +0000412 CFF_FontRecDict dict = &cff->top_font.font_dict;
David Turner19ed8af2000-12-08 02:42:29 +0000413
414
415 /* we need the `PSNames' module for pure-CFF and CEF formats */
416 if ( !psnames )
417 {
David Turnerc8087482001-12-20 13:14:18 +0000418 FT_ERROR(( "CFF_Face_Init:" ));
David Turner19ed8af2000-12-08 02:42:29 +0000419 FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
420 FT_ERROR(( " " ));
421 FT_ERROR(( " without the `PSNames' module\n" ));
422 goto Bad_Format;
423 }
424
425 /* Set up num_faces. */
426 root->num_faces = cff->num_faces;
427
428 /* compute number of glyphs */
429 if ( dict->cid_registry )
430 root->num_glyphs = dict->cid_count;
431 else
432 root->num_glyphs = cff->charstrings_index.count;
433
434 /* set global bbox, as well as EM size */
David Turner7d0f0ba2002-03-05 15:55:28 +0000435 root->bbox.xMin = dict->font_bbox.xMin >> 16;
436 root->bbox.yMin = dict->font_bbox.yMin >> 16;
437 root->bbox.xMax = (dict->font_bbox.xMax + 0xFFFFU) >> 16;
438 root->bbox.yMax = (dict->font_bbox.yMax + 0xFFFFU) >> 16;
439
440
441 root->ascender = (FT_Short)( root->bbox.yMax );
442 root->descender = (FT_Short)( root->bbox.yMin );
Werner Lemberg8eb03532001-06-19 23:03:41 +0000443 root->height = (FT_Short)(
444 ( ( root->ascender - root->descender ) * 12 ) / 10 );
David Turner19ed8af2000-12-08 02:42:29 +0000445
Tom Kacvinskyc97cf172001-02-07 01:08:34 +0000446 if ( dict->units_per_em )
447 root->units_per_EM = dict->units_per_em;
448 else
449 root->units_per_EM = 1000;
450
David Turner19ed8af2000-12-08 02:42:29 +0000451 /* retrieve font family & style name */
452 root->family_name = CFF_Get_Name( &cff->name_index, face_index );
453 if ( dict->cid_registry )
Tom Kacvinsky8d1f6042001-01-03 00:21:59 +0000454 root->style_name = CFF_StrCopy( memory, "Regular" ); /* XXXX */
David Turner19ed8af2000-12-08 02:42:29 +0000455 else
David Turner19ed8af2000-12-08 02:42:29 +0000456 root->style_name = CFF_Get_String( &cff->string_index,
457 dict->weight,
458 psnames );
David Turner19ed8af2000-12-08 02:42:29 +0000459
460 /*******************************************************************/
461 /* */
462 /* Compute face flags. */
463 /* */
464 flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
465 FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
466
467 if ( sfnt_format )
468 flags |= FT_FACE_FLAG_SFNT;
469
470 /* fixed width font? */
471 if ( dict->is_fixed_pitch )
472 flags |= FT_FACE_FLAG_FIXED_WIDTH;
473
Werner Lembergcc069be2000-12-08 16:17:16 +0000474 /* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
David Turner19ed8af2000-12-08 02:42:29 +0000475#if 0
476 /* kerning available? */
477 if ( face->kern_pairs )
478 flags |= FT_FACE_FLAG_KERNING;
479#endif
480
Tom Kacvinskyb9561b72001-03-16 13:40:50 +0000481#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
482 flags |= FT_FACE_FLAG_GLYPH_NAMES;
483#endif
484
David Turner19ed8af2000-12-08 02:42:29 +0000485 root->face_flags = flags;
486
487 /*******************************************************************/
488 /* */
489 /* Compute style flags. */
490 /* */
491 flags = 0;
492
493 if ( dict->italic_angle )
494 flags |= FT_STYLE_FLAG_ITALIC;
495
496 /* XXX: may not be correct */
497 if ( cff->top_font.private_dict.force_bold )
498 flags |= FT_STYLE_FLAG_BOLD;
499
500 root->style_flags = flags;
501
502 /* set the charmaps if any */
503 if ( sfnt_format )
504 {
505 /*****************************************************************/
506 /* */
507 /* Polish the charmaps. */
508 /* */
509 /* Try to set the charmap encoding according to the platform & */
510 /* encoding ID of each charmap. */
511 /* */
512 TT_CharMap charmap;
513 FT_Int n;
514
515
516 charmap = face->charmaps;
517 root->num_charmaps = face->num_charmaps;
518
519 /* allocate table of pointers */
David Turnere459d742002-03-22 13:52:37 +0000520 if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) )
David Turner19ed8af2000-12-08 02:42:29 +0000521 goto Exit;
522
523 for ( n = 0; n < root->num_charmaps; n++, charmap++ )
524 {
525 FT_Int platform = charmap->cmap.platformID;
526 FT_Int encoding = charmap->cmap.platformEncodingID;
527
528
529 charmap->root.face = (FT_Face)face;
David Turner8edbcab2001-06-19 08:28:24 +0000530 charmap->root.platform_id = (FT_UShort)platform;
531 charmap->root.encoding_id = (FT_UShort)encoding;
David Turner19ed8af2000-12-08 02:42:29 +0000532 charmap->root.encoding = find_encoding( platform, encoding );
533
534 /* now, set root->charmap with a unicode charmap */
535 /* wherever available */
536 if ( !root->charmap &&
537 charmap->root.encoding == ft_encoding_unicode )
538 root->charmap = (FT_CharMap)charmap;
539
540 root->charmaps[n] = (FT_CharMap)charmap;
541 }
542 }
543 }
544 }
545
546 Exit:
547 return error;
548
549 Bad_Format:
Werner Lemberg1429db62001-04-02 23:54:01 +0000550 error = CFF_Err_Unknown_File_Format;
David Turner19ed8af2000-12-08 02:42:29 +0000551 goto Exit;
552 }
553
554
David Turnerbc82f1b2002-03-01 02:26:22 +0000555 FT_LOCAL_DEF( void )
David Turnerc8087482001-12-20 13:14:18 +0000556 CFF_Face_Done( CFF_Face face )
David Turner19ed8af2000-12-08 02:42:29 +0000557 {
558 FT_Memory memory = face->root.memory;
David Turner4e7eeee2002-02-28 16:10:29 +0000559 SFNT_Service sfnt = (SFNT_Service)face->sfnt;
David Turner19ed8af2000-12-08 02:42:29 +0000560
561
562 if ( sfnt )
563 sfnt->done_face( face );
564
565 {
David Turnerab4fc4d2002-03-14 08:57:10 +0000566 CFF_Font cff = (CFF_Font)face->extra.data;
David Turner19ed8af2000-12-08 02:42:29 +0000567
568
569 if ( cff )
570 {
571 CFF_Done_Font( cff );
David Turnere459d742002-03-22 13:52:37 +0000572 FT_FREE( face->extra.data );
David Turner19ed8af2000-12-08 02:42:29 +0000573 }
574 }
575 }
576
577
David Turnerbc82f1b2002-03-01 02:26:22 +0000578 FT_LOCAL_DEF( FT_Error )
David Turnerc8087482001-12-20 13:14:18 +0000579 CFF_Driver_Init( CFF_Driver driver )
David Turner19ed8af2000-12-08 02:42:29 +0000580 {
581 /* init extension registry if needed */
582
583#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
584
585 return TT_Init_Extensions( driver );
586
587#else
588
589 FT_UNUSED( driver );
590
Tom Kacvinsky8d1f6042001-01-03 00:21:59 +0000591 return CFF_Err_Ok;
David Turner19ed8af2000-12-08 02:42:29 +0000592
593#endif
594 }
595
596
David Turnerbc82f1b2002-03-01 02:26:22 +0000597 FT_LOCAL_DEF( void )
David Turnerc8087482001-12-20 13:14:18 +0000598 CFF_Driver_Done( CFF_Driver driver )
David Turner19ed8af2000-12-08 02:42:29 +0000599 {
600 /* destroy extensions registry if needed */
601
602#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
603
604 TT_Done_Extensions( driver );
605
606#else
607
608 FT_UNUSED( driver );
609
610#endif
611 }
612
613
614/* END */