ReactOS 0.4.15-dev-7931-gfd331f1
t1objs.c File Reference
#include <ft2build.h>
#include "t1gload.h"
#include "t1load.h"
#include "t1errors.h"
#include "t1afm.h"
Include dependency graph for t1objs.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_t1objs
 

Functions

static PSH_Globals_Funcs T1_Size_Get_Globals_Funcs (T1_Size size)
 
 T1_Size_Done (FT_Size t1size)
 
 T1_Size_Init (FT_Size t1size)
 
 T1_Size_Request (FT_Size t1size, FT_Size_Request req)
 
 T1_GlyphSlot_Done (FT_GlyphSlot slot)
 
 T1_GlyphSlot_Init (FT_GlyphSlot slot)
 
 T1_Face_Done (FT_Face t1face)
 
 T1_Face_Init (FT_Stream stream, FT_Face t1face, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
 
 T1_Driver_Init (FT_Module module)
 
 T1_Driver_Done (FT_Module driver)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_t1objs

Definition at line 46 of file t1objs.c.

Function Documentation

◆ T1_Driver_Done()

T1_Driver_Done ( FT_Module  driver)

Definition at line 635 of file t1objs.c.

636 {
637 FT_UNUSED( driver );
638 }
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
struct @1669::@1670 driver

◆ T1_Driver_Init()

T1_Driver_Init ( FT_Module  module)

Definition at line 582 of file t1objs.c.

583 {
585
586 FT_UInt32 seed;
587
588
589 /* set default property values, cf. `ftt1drv.h' */
590#ifdef T1_CONFIG_OPTION_OLD_ENGINE
591 driver->hinting_engine = FT_HINTING_FREETYPE;
592#else
593 driver->hinting_engine = FT_HINTING_ADOBE;
594#endif
595
596 driver->no_stem_darkening = TRUE;
597
606
607 /* compute random seed from some memory addresses */
608 seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
609 (FT_Offset)(char*)&module ^
610 (FT_Offset)(char*)module->memory );
611 seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
612
613 driver->random_seed = (FT_Int32)seed;
614 if ( driver->random_seed < 0 )
615 driver->random_seed = -driver->random_seed;
616 else if ( driver->random_seed == 0 )
617 driver->random_seed = 123456789;
618
619 return FT_Err_Ok;
620 }
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1
Definition: ftoption.h:777
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4
Definition: ftoption.h:787
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4
Definition: ftoption.h:786
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2
Definition: ftoption.h:780
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2
Definition: ftoption.h:781
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1
Definition: ftoption.h:778
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3
Definition: ftoption.h:783
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3
Definition: ftoption.h:784
#define TRUE
Definition: types.h:120
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_HINTING_FREETYPE
Definition: ftdriver.h:345
#define FT_HINTING_ADOBE
Definition: ftdriver.h:346
size_t FT_Offset
Definition: fttypes.h:324
FT_BEGIN_HEADER struct PS_DriverRec_ * PS_Driver

◆ T1_Face_Done()

T1_Face_Done ( FT_Face  t1face)

Definition at line 199 of file t1objs.c.

200 {
201 T1_Face face = (T1_Face)t1face;
203 T1_Font type1;
204
205
206 if ( !face )
207 return;
208
209 memory = face->root.memory;
210 type1 = &face->type1;
211
212#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
213 /* release multiple masters information */
214 FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
215
216 if ( face->buildchar )
217 {
218 FT_FREE( face->buildchar );
219
220 face->buildchar = NULL;
221 face->len_buildchar = 0;
222 }
223
225 face->blend = NULL;
226#endif
227
228 /* release font info strings */
229 {
230 PS_FontInfo info = &type1->font_info;
231
232
233 FT_FREE( info->version );
234 FT_FREE( info->notice );
235 FT_FREE( info->full_name );
236 FT_FREE( info->family_name );
237 FT_FREE( info->weight );
238 }
239
240 /* release top dictionary */
241 FT_FREE( type1->charstrings_len );
242 FT_FREE( type1->charstrings );
243 FT_FREE( type1->glyph_names );
244
245 FT_FREE( type1->subrs );
246 FT_FREE( type1->subrs_len );
247
249 FT_FREE( type1->subrs_hash );
250
251 FT_FREE( type1->subrs_block );
252 FT_FREE( type1->charstrings_block );
253 FT_FREE( type1->glyph_names_block );
254
255 FT_FREE( type1->encoding.char_index );
256 FT_FREE( type1->encoding.char_name );
257 FT_FREE( type1->font_name );
258
259#ifndef T1_CONFIG_OPTION_NO_AFM
260 /* release afm data if present */
261 if ( face->afm_data )
263#endif
264
265 /* release unicode map, if any */
266#if 0
267 FT_FREE( face->unicode_map_rec.maps );
268 face->unicode_map_rec.num_maps = 0;
269 face->unicode_map = NULL;
270#endif
271
272 face->root.family_name = NULL;
273 face->root.style_name = NULL;
274 }
#define NULL
Definition: types.h:112
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define ft_hash_num_free
Definition: fthash.h:107
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
static char memory[1024 *256]
Definition: process.c:116
PS_FontInfoRec font_info
Definition: t1types.h:96
FT_Byte * subrs_block
Definition: t1types.h:104
FT_Byte ** subrs
Definition: t1types.h:109
FT_UInt * charstrings_len
Definition: t1types.h:116
FT_String ** glyph_names
Definition: t1types.h:114
T1_EncodingRec encoding
Definition: t1types.h:102
FT_String * font_name
Definition: t1types.h:99
FT_Byte * charstrings_block
Definition: t1types.h:105
FT_Hash subrs_hash
Definition: t1types.h:111
FT_Byte ** charstrings
Definition: t1types.h:115
FT_UInt * subrs_len
Definition: t1types.h:110
FT_Byte * glyph_names_block
Definition: t1types.h:106
T1_Done_Metrics(FT_Memory memory, AFM_FontInfo fi)
Definition: t1afm.c:40
T1_Done_Blend(T1_Face face)
Definition: t1load.c:637
struct T1_FaceRec_ * T1_Face
Definition: t1types.h:196

◆ T1_Face_Init()

T1_Face_Init ( FT_Stream  stream,
FT_Face  t1face,
FT_Int  face_index,
FT_Int  num_params,
FT_Parameter params 
)

Definition at line 301 of file t1objs.c.

306 {
307 T1_Face face = (T1_Face)t1face;
309 FT_Service_PsCMaps psnames;
310 PSAux_Service psaux;
311 T1_Font type1 = &face->type1;
312 PS_FontInfo info = &type1->font_info;
313
314 FT_UNUSED( num_params );
315 FT_UNUSED( params );
316 FT_UNUSED( stream );
317
318
319 face->root.num_faces = 1;
320
321 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
322 face->psnames = psnames;
323
325 "psaux" );
326 psaux = (PSAux_Service)face->psaux;
327 if ( !psaux )
328 {
329 FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
330 error = FT_THROW( Missing_Module );
331 goto Exit;
332 }
333
335 "pshinter" );
336
337 FT_TRACE2(( "Type 1 driver\n" ));
338
339 /* open the tokenizer; this will also check the font format */
341 if ( error )
342 goto Exit;
343
344 /* if we just wanted to check the format, leave successfully now */
345 if ( face_index < 0 )
346 goto Exit;
347
348 /* check the face index */
349 if ( ( face_index & 0xFFFF ) > 0 )
350 {
351 FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
352 error = FT_THROW( Invalid_Argument );
353 goto Exit;
354 }
355
356 /* now load the font program into the face object */
357
358 /* initialize the face object fields */
359
360 /* set up root face fields */
361 {
362 FT_Face root = (FT_Face)&face->root;
363
364
365 root->num_glyphs = type1->num_glyphs;
366 root->face_index = 0;
367
368 root->face_flags |= FT_FACE_FLAG_SCALABLE |
372
373 if ( info->is_fixed_pitch )
374 root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
375
376 if ( face->blend )
377 root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
378
379 /* The following code to extract the family and the style is very */
380 /* simplistic and might get some things wrong. For a full-featured */
381 /* algorithm you might have a look at the whitepaper given at */
382 /* */
383 /* https://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */
384
385 /* get style name -- be careful, some broken fonts only */
386 /* have a `/FontName' dictionary entry! */
387 root->family_name = info->family_name;
388 root->style_name = NULL;
389
390 if ( root->family_name )
391 {
392 char* full = info->full_name;
393 char* family = root->family_name;
394
395
396 if ( full )
397 {
398 FT_Bool the_same = TRUE;
399
400
401 while ( *full )
402 {
403 if ( *full == *family )
404 {
405 family++;
406 full++;
407 }
408 else
409 {
410 if ( *full == ' ' || *full == '-' )
411 full++;
412 else if ( *family == ' ' || *family == '-' )
413 family++;
414 else
415 {
416 the_same = FALSE;
417
418 if ( !*family )
419 root->style_name = full;
420 break;
421 }
422 }
423 }
424
425 if ( the_same )
426 root->style_name = (char *)"Regular";
427 }
428 }
429 else
430 {
431 /* do we have a `/FontName'? */
432 if ( type1->font_name )
433 root->family_name = type1->font_name;
434 }
435
436 if ( !root->style_name )
437 {
438 if ( info->weight )
439 root->style_name = info->weight;
440 else
441 /* assume `Regular' style because we don't know better */
442 root->style_name = (char *)"Regular";
443 }
444
445 /* compute style flags */
446 root->style_flags = 0;
447 if ( info->italic_angle )
448 root->style_flags |= FT_STYLE_FLAG_ITALIC;
449 if ( info->weight )
450 {
451 if ( !ft_strcmp( info->weight, "Bold" ) ||
452 !ft_strcmp( info->weight, "Black" ) )
453 root->style_flags |= FT_STYLE_FLAG_BOLD;
454 }
455
456 /* no embedded bitmap support */
457 root->num_fixed_sizes = 0;
458 root->available_sizes = NULL;
459
460 root->bbox.xMin = type1->font_bbox.xMin >> 16;
461 root->bbox.yMin = type1->font_bbox.yMin >> 16;
462 /* no `U' suffix here to 0xFFFF! */
463 root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFF ) >> 16;
464 root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFF ) >> 16;
465
466 /* Set units_per_EM if we didn't set it in t1_parse_font_matrix. */
467 if ( !root->units_per_EM )
468 root->units_per_EM = 1000;
469
470 root->ascender = (FT_Short)( root->bbox.yMax );
471 root->descender = (FT_Short)( root->bbox.yMin );
472
473 root->height = (FT_Short)( ( root->units_per_EM * 12 ) / 10 );
474 if ( root->height < root->ascender - root->descender )
475 root->height = (FT_Short)( root->ascender - root->descender );
476
477 /* now compute the maximum advance width */
478 root->max_advance_width =
479 (FT_Short)( root->bbox.xMax );
480 {
481 FT_Pos max_advance;
482
483
484 error = T1_Compute_Max_Advance( face, &max_advance );
485
486 /* in case of error, keep the standard width */
487 if ( !error )
488 root->max_advance_width = (FT_Short)FIXED_TO_INT( max_advance );
489 else
490 error = FT_Err_Ok; /* clear error */
491 }
492
493 root->max_advance_height = root->height;
494
495 root->underline_position = (FT_Short)info->underline_position;
496 root->underline_thickness = (FT_Short)info->underline_thickness;
497 }
498
499 {
500 FT_Face root = &face->root;
501
502
503 if ( psnames )
504 {
505 FT_CharMapRec charmap;
506 T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
507 FT_CMap_Class clazz;
508
509
510 charmap.face = root;
511
512 /* first of all, try to synthesize a Unicode charmap */
515 charmap.encoding = FT_ENCODING_UNICODE;
516
517 error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
518 if ( error &&
519 FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
520 goto Exit;
522
523 /* now, generate an Adobe Standard encoding when appropriate */
525 clazz = NULL;
526
527 switch ( type1->encoding_type )
528 {
530 charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
532 clazz = cmap_classes->standard;
533 break;
534
536 charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
538 clazz = cmap_classes->expert;
539 break;
540
542 charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
544 clazz = cmap_classes->custom;
545 break;
546
548 charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
550 clazz = cmap_classes->unicode;
551 break;
552
553 default:
554 ;
555 }
556
557 if ( clazz )
558 error = FT_CMap_New( clazz, NULL, &charmap, NULL );
559 }
560 }
561
562 Exit:
563 return error;
564 }
struct _root root
#define FALSE
Definition: types.h:117
#define TT_MS_ID_UNICODE_CS
Definition: font.c:1181
#define TT_PLATFORM_MICROSOFT
Definition: font.c:1174
#define FT_STYLE_FLAG_ITALIC
Definition: freetype.h:1517
#define FT_FACE_FLAG_SCALABLE
Definition: freetype.h:1238
#define FT_FACE_FLAG_HINTER
Definition: freetype.h:1249
#define FT_FACE_FLAG_FIXED_WIDTH
Definition: freetype.h:1240
struct FT_FaceRec_ * FT_Face
Definition: freetype.h:503
#define FT_FACE_FLAG_GLYPH_NAMES
Definition: freetype.h:1247
#define FT_FACE_FLAG_MULTIPLE_MASTERS
Definition: freetype.h:1246
#define FT_STYLE_FLAG_BOLD
Definition: freetype.h:1518
#define FT_FACE_FLAG_HORIZONTAL
Definition: freetype.h:1242
#define FIXED_TO_INT(x)
Definition: ftcalc.h:406
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:58
#define FT_FACE_LIBRARY(x)
Definition: ftobjs.h:635
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3614
FT_Get_Module_Interface(FT_Library library, const char *mod_name)
Definition: ftobjs.c:4865
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
Definition: ftserv.h:125
#define ft_strcmp
Definition: ftstdlib.h:86
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
int FT_Error
Definition: fttypes.h:300
#define FT_ERR_NEQ(x, e)
Definition: fttypes.h:593
signed short FT_Short
Definition: fttypes.h:198
GLenum const GLfloat * params
Definition: glext.h:5645
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
struct PSAux_ServiceRec_ * PSAux_Service
static void Exit(void)
Definition: sock.c:1330
FT_Pos xMin
Definition: ftimage.h:117
FT_Pos yMax
Definition: ftimage.h:118
FT_Pos yMin
Definition: ftimage.h:117
FT_Pos xMax
Definition: ftimage.h:118
FT_Face face
Definition: freetype.h:842
FT_Encoding encoding
Definition: freetype.h:843
FT_UShort platform_id
Definition: freetype.h:844
FT_UShort encoding_id
Definition: freetype.h:845
T1_CMap_Classes t1_cmap_classes
Definition: psaux.h:1304
FT_CMap_Class standard
Definition: psaux.h:1262
FT_CMap_Class custom
Definition: psaux.h:1264
FT_CMap_Class expert
Definition: psaux.h:1263
FT_CMap_Class unicode
Definition: psaux.h:1265
T1_EncodingType encoding_type
Definition: t1types.h:101
FT_Int num_glyphs
Definition: t1types.h:113
FT_BBox font_bbox
Definition: t1types.h:122
Definition: parse.h:23
T1_Compute_Max_Advance(T1_Face face, FT_Pos *max_advance)
Definition: t1gload.c:212
T1_Open_Face(T1_Face face)
Definition: t1load.c:2301
@ T1_ENCODING_TYPE_ISOLATIN1
Definition: t1tables.h:565
@ T1_ENCODING_TYPE_STANDARD
Definition: t1tables.h:564
@ T1_ENCODING_TYPE_ARRAY
Definition: t1tables.h:563
@ T1_ENCODING_TYPE_EXPERT
Definition: t1tables.h:566
#define TT_ADOBE_ID_EXPERT
Definition: ttnameid.h:282
#define TT_ADOBE_ID_STANDARD
Definition: ttnameid.h:281
#define TT_PLATFORM_ADOBE
Definition: ttnameid.h:91
#define TT_ADOBE_ID_LATIN_1
Definition: ttnameid.h:284
#define TT_ADOBE_ID_CUSTOM
Definition: ttnameid.h:283

◆ T1_GlyphSlot_Done()

T1_GlyphSlot_Done ( FT_GlyphSlot  slot)

Definition at line 143 of file t1objs.c.

144 {
145 slot->internal->glyph_hints = NULL;
146 }
Definition: vfat.h:185

◆ T1_GlyphSlot_Init()

T1_GlyphSlot_Init ( FT_GlyphSlot  slot)

Definition at line 150 of file t1objs.c.

151 {
153 PSHinter_Service pshinter;
154
155
156 face = (T1_Face)slot->face;
157 pshinter = (PSHinter_Service)face->pshinter;
158
159 if ( pshinter )
160 {
162
163
164 module = FT_Get_Module( slot->face->driver->root.library,
165 "pshinter" );
166 if ( module )
167 {
169
170
171 funcs = pshinter->get_t1_funcs( module );
172 slot->internal->glyph_hints = (void*)funcs;
173 }
174 }
175
176 return 0;
177 }
WORD face[3]
Definition: mesh.c:4747
FT_Get_Module(FT_Library library, const char *module_name)
Definition: ftobjs.c:4837
static struct __wine_debug_functions funcs
Definition: debug.c:59
T1_Hints_Funcs(* get_t1_funcs)(FT_Module module)
Definition: pshints.h:675

◆ T1_Size_Done()

T1_Size_Done ( FT_Size  t1size)

Definition at line 73 of file t1objs.c.

74 {
75 T1_Size size = (T1_Size)t1size;
76
77
78 if ( t1size->internal->module_data )
79 {
81
82
84 if ( funcs )
85 funcs->destroy( (PSH_Globals)t1size->internal->module_data );
86
87 t1size->internal->module_data = NULL;
88 }
89 }
GLsizeiptr size
Definition: glext.h:5919
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
Definition: pshints.h:41
FT_Size_Internal internal
Definition: freetype.h:1678
void * module_data
Definition: ftobjs.h:497
static PSH_Globals_Funcs T1_Size_Get_Globals_Funcs(T1_Size size)
Definition: t1objs.c:57
struct T1_SizeRec_ * T1_Size
Definition: t1objs.h:45

◆ T1_Size_Get_Globals_Funcs()

static PSH_Globals_Funcs T1_Size_Get_Globals_Funcs ( T1_Size  size)
static

Definition at line 57 of file t1objs.c.

58 {
59 T1_Face face = (T1_Face)size->root.face;
60 PSHinter_Service pshinter = (PSHinter_Service)face->pshinter;
62
63
64 module = FT_Get_Module( size->root.face->driver->root.library,
65 "pshinter" );
66 return ( module && pshinter && pshinter->get_globals_funcs )
67 ? pshinter->get_globals_funcs( module )
68 : 0;
69 }
FT_FaceRec root
Definition: t1types.h:202

Referenced by T1_Size_Done(), T1_Size_Init(), and T1_Size_Request().

◆ T1_Size_Init()

T1_Size_Init ( FT_Size  t1size)

Definition at line 93 of file t1objs.c.

94 {
95 T1_Size size = (T1_Size)t1size;
98
99
100 if ( funcs )
101 {
102 PSH_Globals globals;
103 T1_Face face = (T1_Face)size->root.face;
104
105
106 error = funcs->create( size->root.face->memory,
107 &face->type1.private_dict, &globals );
108 if ( !error )
109 t1size->internal->module_data = globals;
110 }
111
112 return error;
113 }

◆ T1_Size_Request()

T1_Size_Request ( FT_Size  t1size,
FT_Size_Request  req 
)

Definition at line 117 of file t1objs.c.

119 {
120 T1_Size size = (T1_Size)t1size;
122
123
124 FT_Request_Metrics( size->root.face, req );
125
126 if ( funcs )
127 funcs->set_scale( (PSH_Globals)t1size->internal->module_data,
128 size->root.metrics.x_scale,
129 size->root.metrics.y_scale,
130 0, 0 );
131
132 return FT_Err_Ok;
133 }
FT_Request_Metrics(FT_Face face, FT_Size_Request req)
Definition: ftobjs.c:3028