ReactOS 0.4.16-dev-2357-g35d0dfe
t1gload.h File Reference
#include "t1objs.h"
Include dependency graph for t1gload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FT_BEGIN_HEADER T1_Compute_Max_Advance (T1_Face face, FT_Pos *max_advance)
 
 T1_Get_Advances (FT_Face face, FT_UInt first, FT_UInt count, FT_Int32 load_flags, FT_Fixed *advances)
 
 T1_Load_Glyph (FT_GlyphSlot glyph, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
 

Function Documentation

◆ T1_Compute_Max_Advance()

FT_BEGIN_HEADER T1_Compute_Max_Advance ( T1_Face  face,
FT_Pos max_advance 
)

Definition at line 212 of file t1gload.c.

214 {
216#ifdef __REACTOS__
217 T1_DecoderRec *decoder_allocated = malloc(sizeof(*decoder_allocated));
218 if (!decoder_allocated)
219 return FT_THROW( Out_Of_Memory );
220 {
221/* Ugly but it allows us to reduce the diff */
222#define decoder (*decoder_allocated)
223#else
225#endif
226 FT_Int glyph_index;
227 T1_Font type1 = &face->type1;
228 PSAux_Service psaux = (PSAux_Service)face->psaux;
229
230
231 FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
232
233 *max_advance = 0;
234
235 /* initialize load decoder */
237 (FT_Face)face,
238 0, /* size */
239 0, /* glyph slot */
240 (FT_Byte**)type1->glyph_names,
241 face->blend,
242 0,
245 if ( error )
246#ifdef __REACTOS__
247 {
248 free(decoder_allocated);
249 return error;
250 }
251#else
252 return error;
253#endif
254
255 decoder.builder.metrics_only = 1;
256 decoder.builder.load_points = 0;
257
258 decoder.num_subrs = type1->num_subrs;
259 decoder.subrs = type1->subrs;
260 decoder.subrs_len = type1->subrs_len;
261 decoder.subrs_hash = type1->subrs_hash;
262
263 decoder.buildchar = face->buildchar;
264 decoder.len_buildchar = face->len_buildchar;
265
266 *max_advance = 0;
267
268 FT_TRACE6(( "T1_Compute_Max_Advance:\n" ));
269
270 /* for each glyph, parse the glyph charstring and extract */
271 /* the advance width */
272 for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
273 {
274 /* now get load the unscaled outline */
275 (void)T1_Parse_Glyph( &decoder, (FT_UInt)glyph_index );
276 if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
277 *max_advance = decoder.builder.advance.x;
278
279 /* ignore the error if one occurred - skip to next glyph */
280 }
281
282 FT_TRACE6(( "T1_Compute_Max_Advance: max advance: %f\n",
283 *max_advance / 65536.0 ));
284
285 psaux->t1_decoder_funcs->done( &decoder );
286
287#ifdef __REACTOS__
288 free(decoder_allocated);
289#undef decoder
290 }
291#endif
292 return FT_Err_Ok;
293 }
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
WORD face[3]
Definition: mesh.c:4747
@ FT_RENDER_MODE_NORMAL
Definition: freetype.h:3249
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_ASSERT(condition)
Definition: ftdebug.h:241
#define FT_TRACE6(varformat)
Definition: ftdebug.h:193
#define FT_THROW(e)
Definition: ftdebug.h:243
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define error(str)
Definition: mkdosfs.c:1605
struct PSAux_ServiceRec_ * PSAux_Service
const T1_Decoder_FuncsRec * t1_decoder_funcs
Definition: psaux.h:1350
void(* done)(T1_Decoder decoder)
Definition: psaux.h:917
FT_Error(* init)(T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte **glyph_names, PS_Blend blend, FT_Bool hinting, FT_Render_Mode hint_mode, T1_Decoder_Callback callback)
Definition: psaux.h:906
FT_Byte ** subrs
Definition: t1types.h:111
FT_Int num_glyphs
Definition: t1types.h:115
FT_String ** glyph_names
Definition: t1types.h:116
FT_Int num_subrs
Definition: t1types.h:110
FT_Hash subrs_hash
Definition: t1types.h:113
FT_UInt * subrs_len
Definition: t1types.h:112
T1_Parse_Glyph(T1_Decoder decoder, FT_UInt glyph_index)
Definition: t1gload.c:165

Referenced by T1_Face_Init().

◆ T1_Get_Advances()

T1_Get_Advances ( FT_Face  face,
FT_UInt  first,
FT_UInt  count,
FT_Int32  load_flags,
FT_Fixed advances 
)

Definition at line 297 of file t1gload.c.

302 {
303 T1_Face face = (T1_Face)t1face;
304#ifdef __REACTOS__
305 T1_DecoderRec *decoder_allocated = malloc(sizeof(*decoder_allocated));
306 if (!decoder_allocated)
307 return FT_THROW( Out_Of_Memory );
308/* Ugly but it allows us to reduce the diff */
309#define decoder (*decoder_allocated)
310 {
311#else
313#endif
314 T1_Font type1 = &face->type1;
315 PSAux_Service psaux = (PSAux_Service)face->psaux;
316 FT_UInt nn;
318
319
320 FT_TRACE5(( "T1_Get_Advances:\n" ));
321
322 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
323 {
324 for ( nn = 0; nn < count; nn++ )
325 {
326 advances[nn] = 0;
327
328 FT_TRACE5(( " idx %d: advance height 0 font units\n",
329 first + nn ));
330 }
331
332#ifdef __REACTOS__
333 free(decoder_allocated);
334#endif
335 return FT_Err_Ok;
336 }
337
339 (FT_Face)face,
340 0, /* size */
341 0, /* glyph slot */
342 (FT_Byte**)type1->glyph_names,
343 face->blend,
344 0,
347 if ( error )
348#ifdef __REACTOS__
349 {
350 free(decoder_allocated);
351 return error;
352 }
353#else
354 return error;
355#endif
356
357 decoder.builder.metrics_only = 1;
358 decoder.builder.load_points = 0;
359
360 decoder.num_subrs = type1->num_subrs;
361 decoder.subrs = type1->subrs;
362 decoder.subrs_len = type1->subrs_len;
363 decoder.subrs_hash = type1->subrs_hash;
364
365 decoder.buildchar = face->buildchar;
366 decoder.len_buildchar = face->len_buildchar;
367
368 for ( nn = 0; nn < count; nn++ )
369 {
370 error = T1_Parse_Glyph( &decoder, first + nn );
371 if ( !error )
372 advances[nn] = FIXED_TO_INT( decoder.builder.advance.x );
373 else
374 advances[nn] = 0;
375
376 FT_TRACE5(( " idx %d: advance width %ld font unit%s\n",
377 first + nn,
378 advances[nn],
379 advances[nn] == 1 ? "" : "s" ));
380 }
381
382#ifdef __REACTOS__
383 free(decoder_allocated);
384#undef decoder
385 }
386#endif
387 return FT_Err_Ok;
388 }
#define FT_LOAD_VERTICAL_LAYOUT
Definition: freetype.h:3026
#define FIXED_TO_INT(x)
Definition: ftcalc.h:450
#define FT_TRACE5(varformat)
Definition: ftdebug.h:192
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLint * first
Definition: glext.h:5794
struct T1_FaceRec_ * T1_Face
Definition: t1types.h:198

◆ T1_Load_Glyph()

T1_Load_Glyph ( FT_GlyphSlot  glyph,
FT_Size  size,
FT_UInt  glyph_index,
FT_Int32  load_flags 
)

Definition at line 392 of file t1gload.c.

396 {
397 T1_GlyphSlot glyph = (T1_GlyphSlot)t1glyph;
399#ifdef __REACTOS__
400 T1_DecoderRec *decoder_allocated = malloc(sizeof(*decoder_allocated));
401 if (!decoder_allocated)
402 return FT_THROW( Out_Of_Memory );
403/* Ugly but it allows us to reduce the diff */
404#define decoder (*decoder_allocated)
405 {
406#else
408#endif
409 T1_Face face = (T1_Face)t1glyph->face;
410 FT_Bool hinting;
411 FT_Bool scaled;
412 FT_Bool force_scaling = FALSE;
413 T1_Font type1 = &face->type1;
414 PSAux_Service psaux = (PSAux_Service)face->psaux;
415 const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
416
417 FT_Matrix font_matrix;
418 FT_Vector font_offset;
419 FT_Data glyph_data;
420 FT_Bool must_finish_decoder = FALSE;
421#ifdef FT_CONFIG_OPTION_INCREMENTAL
422 FT_Bool glyph_data_loaded = 0;
423#endif
424
425
426#ifdef FT_CONFIG_OPTION_INCREMENTAL
427 if ( glyph_index >= (FT_UInt)face->root.num_glyphs &&
428 !face->root.internal->incremental_interface )
429#else
430 if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
431#endif /* FT_CONFIG_OPTION_INCREMENTAL */
432 {
433 error = FT_THROW( Invalid_Argument );
434 goto Exit;
435 }
436
437 FT_TRACE1(( "T1_Load_Glyph: glyph index %d\n", glyph_index ));
438
439 FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
440
441 if ( load_flags & FT_LOAD_NO_RECURSE )
442 load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
443
444 if ( t1size )
445 {
446 glyph->x_scale = t1size->metrics.x_scale;
447 glyph->y_scale = t1size->metrics.y_scale;
448 }
449 else
450 {
451 glyph->x_scale = 0x10000L;
452 glyph->y_scale = 0x10000L;
453 }
454
455 t1glyph->outline.n_points = 0;
456 t1glyph->outline.n_contours = 0;
457
458 hinting = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) &&
459 !( load_flags & FT_LOAD_NO_HINTING ) );
460 scaled = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) );
461
462 glyph->hint = hinting;
463 glyph->scaled = scaled;
464 t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
465
466 error = decoder_funcs->init( &decoder,
467 t1glyph->face,
468 t1size,
469 t1glyph,
470 (FT_Byte**)type1->glyph_names,
471 face->blend,
472 hinting,
473 FT_LOAD_TARGET_MODE( load_flags ),
475 if ( error )
476 goto Exit;
477
478 must_finish_decoder = TRUE;
479
480 decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE );
481
482 decoder.num_subrs = type1->num_subrs;
483 decoder.subrs = type1->subrs;
484 decoder.subrs_len = type1->subrs_len;
485 decoder.subrs_hash = type1->subrs_hash;
486
487 decoder.buildchar = face->buildchar;
488 decoder.len_buildchar = face->len_buildchar;
489
490 /* now load the unscaled outline */
492 &glyph_data,
493 &force_scaling );
494 if ( error )
495 goto Exit;
496#ifdef FT_CONFIG_OPTION_INCREMENTAL
497 glyph_data_loaded = 1;
498#endif
499
500 hinting = glyph->hint;
501 font_matrix = decoder.font_matrix;
502 font_offset = decoder.font_offset;
503
504 /* save new glyph tables */
505 decoder_funcs->done( &decoder );
506
507 must_finish_decoder = FALSE;
508
509 /* now, set the metrics -- this is rather simple, as */
510 /* the left side bearing is the xMin, and the top side */
511 /* bearing the yMax */
512 if ( !error )
513 {
514 t1glyph->outline.flags &= FT_OUTLINE_OWNER;
515 t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
516
517 /* for composite glyphs, return only left side bearing and */
518 /* advance width */
519 if ( load_flags & FT_LOAD_NO_RECURSE )
520 {
521 FT_Slot_Internal internal = t1glyph->internal;
522
523
524 t1glyph->metrics.horiBearingX =
525 FIXED_TO_INT( decoder.builder.left_bearing.x );
526 t1glyph->metrics.horiAdvance =
527 FIXED_TO_INT( decoder.builder.advance.x );
528
529 internal->glyph_matrix = font_matrix;
530 internal->glyph_delta = font_offset;
531 internal->glyph_transformed = 1;
532 }
533 else
534 {
535 FT_BBox cbox;
536 FT_Glyph_Metrics* metrics = &t1glyph->metrics;
537
538
539 /* copy the _unscaled_ advance width */
540 metrics->horiAdvance =
541 FIXED_TO_INT( decoder.builder.advance.x );
542 t1glyph->linearHoriAdvance =
543 FIXED_TO_INT( decoder.builder.advance.x );
544 t1glyph->internal->glyph_transformed = 0;
545
546 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
547 {
548 /* make up vertical ones */
549 metrics->vertAdvance = ( face->type1.font_bbox.yMax -
550 face->type1.font_bbox.yMin ) >> 16;
551 t1glyph->linearVertAdvance = metrics->vertAdvance;
552 }
553 else
554 {
555 metrics->vertAdvance =
556 FIXED_TO_INT( decoder.builder.advance.y );
557 t1glyph->linearVertAdvance =
558 FIXED_TO_INT( decoder.builder.advance.y );
559 }
560
561 t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
562
563 if ( t1size && t1size->metrics.y_ppem < 24 )
564 t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
565
566#if 1
567 /* apply the font matrix, if any */
568 if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
569 font_matrix.xy != 0 || font_matrix.yx != 0 )
570 {
571 FT_Outline_Transform( &t1glyph->outline, &font_matrix );
572
573 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
574 font_matrix.xx );
575 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
576 font_matrix.yy );
577 }
578
579 if ( font_offset.x || font_offset.y )
580 {
581 FT_Outline_Translate( &t1glyph->outline,
582 font_offset.x,
583 font_offset.y );
584
585 metrics->horiAdvance += font_offset.x;
586 metrics->vertAdvance += font_offset.y;
587 }
588#endif
589
590 if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
591 {
592 /* scale the outline and the metrics */
593 FT_Int n;
594 FT_Outline* cur = decoder.builder.base;
595 FT_Vector* vec = cur->points;
596 FT_Fixed x_scale = glyph->x_scale;
597 FT_Fixed y_scale = glyph->y_scale;
598
599
600 /* First of all, scale the points, if we are not hinting */
601 if ( !hinting || !decoder.builder.hints_funcs )
602 for ( n = cur->n_points; n > 0; n--, vec++ )
603 {
604 vec->x = FT_MulFix( vec->x, x_scale );
605 vec->y = FT_MulFix( vec->y, y_scale );
606 }
607
608 /* Then scale the metrics */
609 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
610 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
611 }
612
613 /* compute the other metrics */
614 FT_Outline_Get_CBox( &t1glyph->outline, &cbox );
615
616 metrics->width = cbox.xMax - cbox.xMin;
617 metrics->height = cbox.yMax - cbox.yMin;
618
619 metrics->horiBearingX = cbox.xMin;
620 metrics->horiBearingY = cbox.yMax;
621
622 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
623 {
624 /* make up vertical ones */
626 metrics->vertAdvance );
627 }
628 }
629
630 /* Set control data to the glyph charstrings. Note that this is */
631 /* _not_ zero-terminated. */
632 t1glyph->control_data = (FT_Byte*)glyph_data.pointer;
633 t1glyph->control_len = glyph_data.length;
634 }
635
636
637 Exit:
638
639#ifdef FT_CONFIG_OPTION_INCREMENTAL
640 if ( glyph_data_loaded && face->root.internal->incremental_interface )
641 {
642 face->root.internal->incremental_interface->funcs->free_glyph_data(
643 face->root.internal->incremental_interface->object,
644 &glyph_data );
645
646 /* Set the control data to null - it is no longer available if */
647 /* loaded incrementally. */
648 t1glyph->control_data = NULL;
649 t1glyph->control_len = 0;
650 }
651#endif
652
653 if ( must_finish_decoder )
654 decoder_funcs->done( &decoder );
655
656#ifdef __REACTOS__
657 free(decoder_allocated);
658#undef decoder
659 }
660#endif
661 return error;
662 }
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FT_LOAD_TARGET_MODE(x)
Definition: freetype.h:3154
FT_BEGIN_HEADER struct FT_Glyph_Metrics_ FT_Glyph_Metrics
#define FT_LOAD_NO_SCALE
Definition: freetype.h:3022
#define FT_LOAD_NO_RECURSE
Definition: freetype.h:3031
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3023
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:508
FT_Vector * vec
Definition: ftbbox.c:469
#define FT_TRACE1(varformat)
Definition: ftdebug.h:188
#define FT_OUTLINE_HIGH_PRECISION
Definition: ftimage.h:443
#define FT_OUTLINE_OWNER
Definition: ftimage.h:435
#define FT_OUTLINE_REVERSE_FILL
Definition: ftimage.h:437
ft_synthesize_vertical_metrics(FT_Glyph_Metrics *metrics, FT_Pos advance)
Definition: ftobjs.c:2997
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:507
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:706
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:457
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
signed long FT_Fixed
Definition: fttypes.h:287
#define FT_BOOL(x)
Definition: fttypes.h:591
FxCollectionEntry * cur
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
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
const FT_Byte * pointer
Definition: fttypes.h:415
FT_Int length
Definition: fttypes.h:416
FT_Fixed xx
Definition: fttypes.h:392
FT_Fixed yx
Definition: fttypes.h:393
FT_Fixed yy
Definition: fttypes.h:393
FT_Fixed xy
Definition: fttypes.h:392
FT_Pos x
Definition: ftimage.h:77
FT_Pos y
Definition: ftimage.h:78
FT_Bool scaled
Definition: t1objs.h:121
FT_Bool hint
Definition: t1objs.h:120
FT_Fixed x_scale
Definition: t1objs.h:123
FT_Fixed y_scale
Definition: t1objs.h:124
static FT_Error T1_Parse_Glyph_And_Get_Char_String(T1_Decoder decoder, FT_UInt glyph_index, FT_Data *char_string, FT_Bool *force_scaling)
Definition: t1gload.c:42
struct T1_GlyphSlotRec_ * T1_GlyphSlot
Definition: t1objs.h:56