ReactOS 0.4.16-dev-2332-g4cba65d
t1objs.c File Reference
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   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   t1objs

Definition at line 45 of file t1objs.c.

Function Documentation

◆ T1_Driver_Done()

T1_Driver_Done ( FT_Module  driver)

Definition at line 647 of file t1objs.c.

648 {
649 FT_UNUSED( driver );
650 }
struct @1789::@1790 driver
#define FT_UNUSED(arg)

◆ T1_Driver_Init()

T1_Driver_Init ( FT_Module  module)

Definition at line 593 of file t1objs.c.

594 {
596
597 FT_UInt32 seed;
598
599
600 /* set default property values, cf. `ftt1drv.h' */
601#ifdef T1_CONFIG_OPTION_OLD_ENGINE
602 driver->hinting_engine = FT_HINTING_FREETYPE;
603#else
604 driver->hinting_engine = FT_HINTING_ADOBE;
605#endif
606
607 driver->no_stem_darkening = TRUE;
608
617
618 /* compute random seed from some memory addresses */
619 seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
620 (FT_Offset)(char*)&module ^
621 (FT_Offset)(char*)module->memory );
622 seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
623
624 driver->random_seed = (FT_Int32)seed;
625 if ( driver->random_seed < 0 )
626 driver->random_seed = -driver->random_seed;
627 else if ( driver->random_seed == 0 )
628 driver->random_seed = 123456789;
629
630 return FT_Err_Ok;
631 }
#define TRUE
Definition: types.h:120
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_HINTING_FREETYPE
Definition: ftdriver.h:343
#define FT_HINTING_ADOBE
Definition: ftdriver.h:344
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1
Definition: ftoption.h:827
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4
Definition: ftoption.h:837
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4
Definition: ftoption.h:836
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2
Definition: ftoption.h:830
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2
Definition: ftoption.h:831
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1
Definition: ftoption.h:828
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3
Definition: ftoption.h:833
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3
Definition: ftoption.h:834
size_t FT_Offset
Definition: fttypes.h:323
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:241
#define ft_hash_num_free
Definition: fthash.h:106
#define FT_FREE(ptr)
Definition: ftmemory.h:337
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
static char memory[1024 *256]
Definition: process.c:122
PS_FontInfoRec font_info
Definition: t1types.h:98
FT_Byte * subrs_block
Definition: t1types.h:106
FT_Byte ** subrs
Definition: t1types.h:111
FT_UInt * charstrings_len
Definition: t1types.h:118
FT_String ** glyph_names
Definition: t1types.h:116
T1_EncodingRec encoding
Definition: t1types.h:104
FT_String * font_name
Definition: t1types.h:101
FT_Byte * charstrings_block
Definition: t1types.h:107
FT_Hash subrs_hash
Definition: t1types.h:113
FT_Byte ** charstrings
Definition: t1types.h:117
FT_UInt * subrs_len
Definition: t1types.h:112
FT_Byte * glyph_names_block
Definition: t1types.h:108
T1_Done_Metrics(FT_Memory memory, AFM_FontInfo fi)
Definition: t1afm.c:39
T1_Done_Blend(T1_Face face)
Definition: t1load.c:734
struct T1_FaceRec_ * T1_Face
Definition: t1types.h:198

◆ 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 306 of file t1objs.c.

311 {
312 T1_Face face = (T1_Face)t1face;
314 FT_Service_PsCMaps psnames;
315 PSAux_Service psaux;
316 T1_Font type1 = &face->type1;
317 PS_FontInfo info = &type1->font_info;
318
319 FT_UNUSED( num_params );
320 FT_UNUSED( params );
321 FT_UNUSED( stream );
322
323
324 face->root.num_faces = 1;
325
326 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
327 face->psnames = psnames;
328
330 "psaux" );
331 psaux = (PSAux_Service)face->psaux;
332 if ( !psaux )
333 {
334 FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
335 error = FT_THROW( Missing_Module );
336 goto Exit;
337 }
338
340 "pshinter" );
341
342 FT_TRACE2(( "Type 1 driver\n" ));
343
344 /* open the tokenizer; this will also check the font format */
346 if ( error )
347 goto Exit;
348
349 FT_TRACE2(( "T1_Face_Init: %p (index %d)\n",
350 (void *)face,
351 face_index ));
352
353 /* if we just wanted to check the format, leave successfully now */
354 if ( face_index < 0 )
355 goto Exit;
356
357 /* check the face index */
358 if ( ( face_index & 0xFFFF ) > 0 )
359 {
360 FT_ERROR(( "T1_Face_Init: invalid face index\n" ));
361 error = FT_THROW( Invalid_Argument );
362 goto Exit;
363 }
364
365 /* now load the font program into the face object */
366
367 /* initialize the face object fields */
368
369 /* set up root face fields */
370 {
371 FT_Face root = (FT_Face)&face->root;
372
373
374 root->num_glyphs = type1->num_glyphs;
375 root->face_index = 0;
376
377 root->face_flags |= FT_FACE_FLAG_SCALABLE |
381
382 if ( info->is_fixed_pitch )
383 root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
384
385 if ( face->blend )
386 root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
387
388 /* The following code to extract the family and the style is very */
389 /* simplistic and might get some things wrong. For a full-featured */
390 /* algorithm you might have a look at the whitepaper given at */
391 /* */
392 /* https://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */
393
394 /* get style name -- be careful, some broken fonts only */
395 /* have a `/FontName' dictionary entry! */
396 root->family_name = info->family_name;
397 root->style_name = NULL;
398
399 if ( root->family_name )
400 {
401 char* full = info->full_name;
402 char* family = root->family_name;
403
404
405 if ( full )
406 {
407 FT_Bool the_same = TRUE;
408
409
410 while ( *full )
411 {
412 if ( *full == *family )
413 {
414 family++;
415 full++;
416 }
417 else
418 {
419 if ( *full == ' ' || *full == '-' )
420 full++;
421 else if ( *family == ' ' || *family == '-' )
422 family++;
423 else
424 {
425 the_same = FALSE;
426
427 if ( !*family )
428 root->style_name = full;
429 break;
430 }
431 }
432 }
433
434 if ( the_same )
435 root->style_name = (char *)"Regular";
436 }
437 }
438 else
439 {
440 /* do we have a `/FontName'? */
441 if ( type1->font_name )
442 root->family_name = type1->font_name;
443 }
444
445 if ( !root->style_name )
446 {
447 if ( info->weight )
448 root->style_name = info->weight;
449 else
450 /* assume `Regular' style because we don't know better */
451 root->style_name = (char *)"Regular";
452 }
453
454 /* compute style flags */
455 root->style_flags = 0;
456 if ( info->italic_angle )
457 root->style_flags |= FT_STYLE_FLAG_ITALIC;
458 if ( info->weight )
459 {
460 if ( !ft_strcmp( info->weight, "Bold" ) ||
461 !ft_strcmp( info->weight, "Black" ) )
462 root->style_flags |= FT_STYLE_FLAG_BOLD;
463 }
464
465 /* no embedded bitmap support */
466 root->num_fixed_sizes = 0;
467 root->available_sizes = NULL;
468
469 root->bbox.xMin = type1->font_bbox.xMin >> 16;
470 root->bbox.yMin = type1->font_bbox.yMin >> 16;
471 /* no `U' suffix here to 0xFFFF! */
472 root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFF ) >> 16;
473 root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFF ) >> 16;
474
475 /* Set units_per_EM if we didn't set it in t1_parse_font_matrix. */
476 if ( !root->units_per_EM )
477 root->units_per_EM = 1000;
478
479 root->ascender = (FT_Short)( root->bbox.yMax );
480 root->descender = (FT_Short)( root->bbox.yMin );
481
482 root->height = (FT_Short)( ( root->units_per_EM * 12 ) / 10 );
483 if ( root->height < root->ascender - root->descender )
484 root->height = (FT_Short)( root->ascender - root->descender );
485
486 /* now compute the maximum advance width */
487 root->max_advance_width =
488 (FT_Short)( root->bbox.xMax );
489 {
490 FT_Pos max_advance;
491
492
493 error = T1_Compute_Max_Advance( face, &max_advance );
494
495 /* in case of error, keep the standard width */
496 if ( !error )
497 root->max_advance_width = (FT_Short)FIXED_TO_INT( max_advance );
498 else
499 error = FT_Err_Ok; /* clear error */
500 }
501
502 root->max_advance_height = root->height;
503
504 root->underline_position = (FT_Short)info->underline_position;
505 root->underline_thickness = (FT_Short)info->underline_thickness;
506 }
507
508 {
509 FT_Face root = &face->root;
510
511
512 if ( psnames )
513 {
514 FT_CharMapRec charmap;
515 T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
516 FT_CMap_Class clazz;
517
518
519 charmap.face = root;
520
521 /* first of all, try to synthesize a Unicode charmap */
524 charmap.encoding = FT_ENCODING_UNICODE;
525
526 error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
527 if ( error &&
528 FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) &&
529 FT_ERR_NEQ( error, Unimplemented_Feature ) )
530 goto Exit;
532
533 /* now, generate an Adobe Standard encoding when appropriate */
535 clazz = NULL;
536
537 switch ( type1->encoding_type )
538 {
540 charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
542 clazz = cmap_classes->standard;
543 break;
544
546 charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
548 clazz = cmap_classes->expert;
549 break;
550
552 charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
554 clazz = cmap_classes->custom;
555 break;
556
558 charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
560 clazz = cmap_classes->unicode;
561 break;
562
563 default:
564 ;
565 }
566
567 if ( clazz )
568 error = FT_CMap_New( clazz, NULL, &charmap, NULL );
569 }
570 }
571
572 Exit:
573 return error;
574 }
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:1475
#define FT_FACE_FLAG_SCALABLE
Definition: freetype.h:1197
#define FT_FACE_FLAG_HINTER
Definition: freetype.h:1208
#define FT_FACE_FLAG_FIXED_WIDTH
Definition: freetype.h:1199
struct FT_FaceRec_ * FT_Face
Definition: freetype.h:483
#define FT_FACE_FLAG_GLYPH_NAMES
Definition: freetype.h:1206
#define FT_FACE_FLAG_MULTIPLE_MASTERS
Definition: freetype.h:1205
#define FT_STYLE_FLAG_BOLD
Definition: freetype.h:1476
#define FT_FACE_FLAG_HORIZONTAL
Definition: freetype.h:1201
#define FIXED_TO_INT(x)
Definition: ftcalc.h:450
#define FT_ERROR(varformat)
Definition: ftdebug.h:211
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_TRACE2(varformat)
Definition: ftdebug.h:189
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:57
#define FT_FACE_LIBRARY(x)
Definition: ftobjs.h:602
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3677
FT_Get_Module_Interface(FT_Library library, const char *mod_name)
Definition: ftobjs.c:5012
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
Definition: ftserv.h:128
#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:299
#define FT_ERR_NEQ(x, e)
Definition: fttypes.h:606
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:120
FT_Pos yMax
Definition: ftimage.h:121
FT_Pos yMin
Definition: ftimage.h:120
FT_Pos xMax
Definition: ftimage.h:121
FT_Face face
Definition: freetype.h:819
FT_Encoding encoding
Definition: freetype.h:820
FT_UShort platform_id
Definition: freetype.h:821
FT_UShort encoding_id
Definition: freetype.h:822
T1_CMap_Classes t1_cmap_classes
Definition: psaux.h:1370
FT_CMap_Class standard
Definition: psaux.h:1328
FT_CMap_Class custom
Definition: psaux.h:1330
FT_CMap_Class expert
Definition: psaux.h:1329
FT_CMap_Class unicode
Definition: psaux.h:1331
T1_EncodingType encoding_type
Definition: t1types.h:103
FT_Int num_glyphs
Definition: t1types.h:115
FT_BBox font_bbox
Definition: t1types.h:124
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:2499
@ T1_ENCODING_TYPE_ISOLATIN1
Definition: t1tables.h:568
@ T1_ENCODING_TYPE_STANDARD
Definition: t1tables.h:567
@ T1_ENCODING_TYPE_ARRAY
Definition: t1tables.h:566
@ T1_ENCODING_TYPE_EXPERT
Definition: t1tables.h:569
#define TT_ADOBE_ID_EXPERT
Definition: ttnameid.h:281
#define TT_ADOBE_ID_STANDARD
Definition: ttnameid.h:280
#define TT_PLATFORM_ADOBE
Definition: ttnameid.h:91
#define TT_ADOBE_ID_LATIN_1
Definition: ttnameid.h:283
#define TT_ADOBE_ID_CUSTOM
Definition: ttnameid.h:282

◆ T1_GlyphSlot_Done()

T1_GlyphSlot_Done ( FT_GlyphSlot  slot)

Definition at line 142 of file t1objs.c.

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

◆ T1_GlyphSlot_Init()

T1_GlyphSlot_Init ( FT_GlyphSlot  slot)

Definition at line 149 of file t1objs.c.

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

◆ T1_Size_Done()

T1_Size_Done ( FT_Size  t1size)

Definition at line 72 of file t1objs.c.

73 {
74 T1_Size size = (T1_Size)t1size;
75
76
77 if ( t1size->internal->module_data )
78 {
80
81
83 if ( funcs )
84 funcs->destroy( (PSH_Globals)t1size->internal->module_data );
85
86 t1size->internal->module_data = NULL;
87 }
88 }
GLsizeiptr size
Definition: glext.h:5919
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
Definition: pshints.h:40
FT_Size_Internal internal
Definition: freetype.h:1637
void * module_data
Definition: ftobjs.h:459
static PSH_Globals_Funcs T1_Size_Get_Globals_Funcs(T1_Size size)
Definition: t1objs.c:56
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 56 of file t1objs.c.

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

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

◆ T1_Size_Init()

T1_Size_Init ( FT_Size  t1size)

Definition at line 92 of file t1objs.c.

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

◆ T1_Size_Request()

T1_Size_Request ( FT_Size  t1size,
FT_Size_Request  req 
)

Definition at line 116 of file t1objs.c.

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