ReactOS 0.4.16-dev-1067-ge98bba2
cidgload.h File Reference
#include <ft2build.h>
#include "cidobjs.h"
Include dependency graph for cidgload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FT_BEGIN_HEADER cid_slot_load_glyph (FT_GlyphSlot glyph, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
 

Function Documentation

◆ cid_slot_load_glyph()

FT_BEGIN_HEADER cid_slot_load_glyph ( FT_GlyphSlot  glyph,
FT_Size  size,
FT_UInt  glyph_index,
FT_Int32  load_flags 
)

Definition at line 358 of file cidgload.c.

362 {
363 CID_GlyphSlot glyph = (CID_GlyphSlot)cidglyph;
365#ifdef __REACTOS__
366 T1_DecoderRec *decoder_allocated = malloc(sizeof(*decoder_allocated));
367 if (!decoder_allocated) return FT_Err_Out_Of_Memory;
368/* Ugly but it allows us to reduce the diff */
369#define decoder (*decoder_allocated)
370 {
371#else
373#endif
374 CID_Face face = (CID_Face)cidglyph->face;
375 FT_Bool hinting;
376 FT_Bool scaled;
377
378 PSAux_Service psaux = (PSAux_Service)face->psaux;
379 FT_Matrix font_matrix;
380 FT_Vector font_offset;
381 FT_Bool must_finish_decoder = FALSE;
382
383
384 if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
385 {
386 error = FT_THROW( Invalid_Argument );
387 goto Exit;
388 }
389
390 if ( load_flags & FT_LOAD_NO_RECURSE )
391 load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
392
393 glyph->x_scale = cidsize->metrics.x_scale;
394 glyph->y_scale = cidsize->metrics.y_scale;
395
396 cidglyph->outline.n_points = 0;
397 cidglyph->outline.n_contours = 0;
398
399 hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
400 ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
401 scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
402
403 glyph->hint = hinting;
404 glyph->scaled = scaled;
405 cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
406
407 error = psaux->t1_decoder_funcs->init( &decoder,
408 cidglyph->face,
409 cidsize,
410 cidglyph,
411 0, /* glyph names -- XXX */
412 0, /* blend == 0 */
413 hinting,
414 FT_LOAD_TARGET_MODE( load_flags ),
416 if ( error )
417 goto Exit;
418
419 /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
420 /* if we ever support CID-keyed multiple master fonts */
421
422 must_finish_decoder = TRUE;
423
424 /* set up the decoder */
425 decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE );
426
427 error = cid_load_glyph( &decoder, glyph_index );
428 if ( error )
429 goto Exit;
430
431 /* copy flags back for forced scaling */
432 hinting = glyph->hint;
433 scaled = glyph->scaled;
434
435 font_matrix = decoder.font_matrix;
436 font_offset = decoder.font_offset;
437
438 /* save new glyph tables */
439 psaux->t1_decoder_funcs->done( &decoder );
440
441 must_finish_decoder = FALSE;
442
443 /* now set the metrics -- this is rather simple, as */
444 /* the left side bearing is the xMin, and the top side */
445 /* bearing the yMax */
446 cidglyph->outline.flags &= FT_OUTLINE_OWNER;
447 cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
448
449 /* for composite glyphs, return only left side bearing and */
450 /* advance width */
451 if ( load_flags & FT_LOAD_NO_RECURSE )
452 {
453 FT_Slot_Internal internal = cidglyph->internal;
454
455
456 cidglyph->metrics.horiBearingX =
457 FIXED_TO_INT( decoder.builder.left_bearing.x );
458 cidglyph->metrics.horiAdvance =
459 FIXED_TO_INT( decoder.builder.advance.x );
460
461 internal->glyph_matrix = font_matrix;
462 internal->glyph_delta = font_offset;
463 internal->glyph_transformed = 1;
464 }
465 else
466 {
467 FT_BBox cbox;
468 FT_Glyph_Metrics* metrics = &cidglyph->metrics;
469
470
471 /* copy the _unscaled_ advance width */
472 metrics->horiAdvance =
473 FIXED_TO_INT( decoder.builder.advance.x );
474 cidglyph->linearHoriAdvance =
475 FIXED_TO_INT( decoder.builder.advance.x );
476 cidglyph->internal->glyph_transformed = 0;
477
478 /* make up vertical ones */
479 metrics->vertAdvance = ( face->cid.font_bbox.yMax -
480 face->cid.font_bbox.yMin ) >> 16;
481 cidglyph->linearVertAdvance = metrics->vertAdvance;
482
483 cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
484
485 if ( cidsize->metrics.y_ppem < 24 )
486 cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
487
488 /* apply the font matrix, if any */
489 if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
490 font_matrix.xy != 0 || font_matrix.yx != 0 )
491 {
492 FT_Outline_Transform( &cidglyph->outline, &font_matrix );
493
494 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
495 font_matrix.xx );
496 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
497 font_matrix.yy );
498 }
499
500 if ( font_offset.x || font_offset.y )
501 {
502 FT_Outline_Translate( &cidglyph->outline,
503 font_offset.x,
504 font_offset.y );
505
506 metrics->horiAdvance += font_offset.x;
507 metrics->vertAdvance += font_offset.y;
508 }
509
510 if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled )
511 {
512 /* scale the outline and the metrics */
513 FT_Int n;
514 FT_Outline* cur = decoder.builder.base;
515 FT_Vector* vec = cur->points;
516 FT_Fixed x_scale = glyph->x_scale;
517 FT_Fixed y_scale = glyph->y_scale;
518
519
520 /* First of all, scale the points */
521 if ( !hinting || !decoder.builder.hints_funcs )
522 for ( n = cur->n_points; n > 0; n--, vec++ )
523 {
524 vec->x = FT_MulFix( vec->x, x_scale );
525 vec->y = FT_MulFix( vec->y, y_scale );
526 }
527
528 /* Then scale the metrics */
529 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
530 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
531 }
532
533 /* compute the other metrics */
534 FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
535
536 metrics->width = cbox.xMax - cbox.xMin;
537 metrics->height = cbox.yMax - cbox.yMin;
538
539 metrics->horiBearingX = cbox.xMin;
540 metrics->horiBearingY = cbox.yMax;
541
542 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
543 {
544 /* make up vertical ones */
546 metrics->vertAdvance );
547 }
548 }
549
550 Exit:
551
552 if ( must_finish_decoder )
553 psaux->t1_decoder_funcs->done( &decoder );
554
555#ifdef __REACTOS__
556 free(decoder_allocated);
557#undef decoder
558 }
559#endif
560 return error;
561 }
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
cid_load_glyph(T1_Decoder decoder, FT_UInt glyph_index)
Definition: cidgload.c:45
struct CID_GlyphSlotRec_ * CID_GlyphSlot
Definition: cidobjs.h:67
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FT_LOAD_VERTICAL_LAYOUT
Definition: freetype.h:3031
#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 FIXED_TO_INT(x)
Definition: ftcalc.h:450
#define FT_THROW(e)
Definition: ftdebug.h:241
#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
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_BOOL(x)
Definition: fttypes.h:591
signed int FT_Int
Definition: fttypes.h:220
FxCollectionEntry * cur
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
FT_Fixed x_scale
Definition: cidobjs.h:108
FT_Bool hint
Definition: cidobjs.h:105
FT_Fixed y_scale
Definition: cidobjs.h:109
FT_Bool scaled
Definition: cidobjs.h:106
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
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
struct CID_FaceRec_ * CID_Face
Definition: t1types.h:200