ReactOS 0.4.16-dev-1067-ge98bba2
t1gload.h File Reference
#include <ft2build.h>
#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 213 of file t1gload.c.

215 {
217#ifdef __REACTOS__
218 T1_DecoderRec *decoder_allocated = malloc(sizeof(*decoder_allocated));
219 if (!decoder_allocated)
220 return FT_THROW( Out_Of_Memory );
221 {
222/* Ugly but it allows us to reduce the diff */
223#define decoder (*decoder_allocated)
224#else
226#endif
227 FT_Int glyph_index;
228 T1_Font type1 = &face->type1;
229 PSAux_Service psaux = (PSAux_Service)face->psaux;
230
231
232 FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
233
234 *max_advance = 0;
235
236 /* initialize load decoder */
238 (FT_Face)face,
239 0, /* size */
240 0, /* glyph slot */
241 (FT_Byte**)type1->glyph_names,
242 face->blend,
243 0,
246 if ( error )
247#ifdef __REACTOS__
248 {
249 free(decoder_allocated);
250 return error;
251 }
252#else
253 return error;
254#endif
255
256 decoder.builder.metrics_only = 1;
257 decoder.builder.load_points = 0;
258
259 decoder.num_subrs = type1->num_subrs;
260 decoder.subrs = type1->subrs;
261 decoder.subrs_len = type1->subrs_len;
262 decoder.subrs_hash = type1->subrs_hash;
263
264 decoder.buildchar = face->buildchar;
265 decoder.len_buildchar = face->len_buildchar;
266
267 *max_advance = 0;
268
269 FT_TRACE6(( "T1_Compute_Max_Advance:\n" ));
270
271 /* for each glyph, parse the glyph charstring and extract */
272 /* the advance width */
273 for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
274 {
275 /* now get load the unscaled outline */
276 (void)T1_Parse_Glyph( &decoder, (FT_UInt)glyph_index );
277 if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
278 *max_advance = decoder.builder.advance.x;
279
280 /* ignore the error if one occurred - skip to next glyph */
281 }
282
283 FT_TRACE6(( "T1_Compute_Max_Advance: max advance: %f\n",
284 *max_advance / 65536.0 ));
285
286 psaux->t1_decoder_funcs->done( &decoder );
287
288#ifdef __REACTOS__
289 free(decoder_allocated);
290#undef decoder
291 }
292#endif
293 return FT_Err_Ok;
294 }
#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:3256
return FT_Err_Ok
Definition: ftbbox.c:527
#define FT_ASSERT(condition)
Definition: ftdebug.h:239
#define FT_TRACE6(varformat)
Definition: ftdebug.h:191
#define FT_THROW(e)
Definition: ftdebug.h:241
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:1351
void(* done)(T1_Decoder decoder)
Definition: psaux.h:918
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:907
FT_Byte ** subrs
Definition: t1types.h:112
FT_Int num_glyphs
Definition: t1types.h:116
FT_String ** glyph_names
Definition: t1types.h:117
FT_Int num_subrs
Definition: t1types.h:111
FT_Hash subrs_hash
Definition: t1types.h:114
FT_UInt * subrs_len
Definition: t1types.h:113
T1_Parse_Glyph(T1_Decoder decoder, FT_UInt glyph_index)
Definition: t1gload.c:166

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 298 of file t1gload.c.

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

◆ T1_Load_Glyph()

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

Definition at line 393 of file t1gload.c.

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