ReactOS 0.4.15-dev-7924-g5949c20
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 337 of file cidgload.c.

341 {
342 CID_GlyphSlot glyph = (CID_GlyphSlot)cidglyph;
344#ifdef __REACTOS__
345 T1_DecoderRec *decoder = malloc(sizeof(T1_DecoderRec));
346 if (!decoder) return FT_Err_Out_Of_Memory;
347/* Ugly but it allows us to reduce the diff */
348#define decoder (*decoder)
349 {
350#else
351 T1_DecoderRec decoder;
352#endif
353 CID_Face face = (CID_Face)cidglyph->face;
354 FT_Bool hinting;
355 FT_Bool scaled;
356
357 PSAux_Service psaux = (PSAux_Service)face->psaux;
358 FT_Matrix font_matrix;
359 FT_Vector font_offset;
360 FT_Bool must_finish_decoder = FALSE;
361
362
363 if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
364 {
365 error = FT_THROW( Invalid_Argument );
366 goto Exit;
367 }
368
369 if ( load_flags & FT_LOAD_NO_RECURSE )
370 load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
371
372 glyph->x_scale = cidsize->metrics.x_scale;
373 glyph->y_scale = cidsize->metrics.y_scale;
374
375 cidglyph->outline.n_points = 0;
376 cidglyph->outline.n_contours = 0;
377
378 hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
379 ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
380 scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
381
382 glyph->hint = hinting;
383 glyph->scaled = scaled;
384 cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
385
386 error = psaux->t1_decoder_funcs->init( &decoder,
387 cidglyph->face,
388 cidsize,
389 cidglyph,
390 0, /* glyph names -- XXX */
391 0, /* blend == 0 */
392 hinting,
393 FT_LOAD_TARGET_MODE( load_flags ),
395 if ( error )
396 goto Exit;
397
398 /* TODO: initialize decoder.len_buildchar and decoder.buildchar */
399 /* if we ever support CID-keyed multiple master fonts */
400
401 must_finish_decoder = TRUE;
402
403 /* set up the decoder */
404 decoder.builder.no_recurse = FT_BOOL(
405 ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
406
407 error = cid_load_glyph( &decoder, glyph_index );
408 if ( error )
409 goto Exit;
410
411 /* copy flags back for forced scaling */
412 hinting = glyph->hint;
413 scaled = glyph->scaled;
414
415 font_matrix = decoder.font_matrix;
416 font_offset = decoder.font_offset;
417
418 /* save new glyph tables */
419 psaux->t1_decoder_funcs->done( &decoder );
420
421 must_finish_decoder = FALSE;
422
423 /* now set the metrics -- this is rather simple, as */
424 /* the left side bearing is the xMin, and the top side */
425 /* bearing the yMax */
426 cidglyph->outline.flags &= FT_OUTLINE_OWNER;
427 cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
428
429 /* for composite glyphs, return only left side bearing and */
430 /* advance width */
431 if ( load_flags & FT_LOAD_NO_RECURSE )
432 {
433 FT_Slot_Internal internal = cidglyph->internal;
434
435
436 cidglyph->metrics.horiBearingX =
438 cidglyph->metrics.horiAdvance =
439 FIXED_TO_INT( decoder.builder.advance.x );
440
441 internal->glyph_matrix = font_matrix;
442 internal->glyph_delta = font_offset;
443 internal->glyph_transformed = 1;
444 }
445 else
446 {
447 FT_BBox cbox;
448 FT_Glyph_Metrics* metrics = &cidglyph->metrics;
449
450
451 /* copy the _unscaled_ advance width */
452 metrics->horiAdvance =
453 FIXED_TO_INT( decoder.builder.advance.x );
454 cidglyph->linearHoriAdvance =
455 FIXED_TO_INT( decoder.builder.advance.x );
456 cidglyph->internal->glyph_transformed = 0;
457
458 /* make up vertical ones */
459 metrics->vertAdvance = ( face->cid.font_bbox.yMax -
460 face->cid.font_bbox.yMin ) >> 16;
461 cidglyph->linearVertAdvance = metrics->vertAdvance;
462
463 cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
464
465 if ( cidsize->metrics.y_ppem < 24 )
466 cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
467
468 /* apply the font matrix, if any */
469 if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
470 font_matrix.xy != 0 || font_matrix.yx != 0 )
471 {
472 FT_Outline_Transform( &cidglyph->outline, &font_matrix );
473
474 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
475 font_matrix.xx );
476 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
477 font_matrix.yy );
478 }
479
480 if ( font_offset.x || font_offset.y )
481 {
482 FT_Outline_Translate( &cidglyph->outline,
483 font_offset.x,
484 font_offset.y );
485
486 metrics->horiAdvance += font_offset.x;
487 metrics->vertAdvance += font_offset.y;
488 }
489
490 if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled )
491 {
492 /* scale the outline and the metrics */
493 FT_Int n;
494 FT_Outline* cur = decoder.builder.base;
495 FT_Vector* vec = cur->points;
496 FT_Fixed x_scale = glyph->x_scale;
497 FT_Fixed y_scale = glyph->y_scale;
498
499
500 /* First of all, scale the points */
501 if ( !hinting || !decoder.builder.hints_funcs )
502 for ( n = cur->n_points; n > 0; n--, vec++ )
503 {
504 vec->x = FT_MulFix( vec->x, x_scale );
505 vec->y = FT_MulFix( vec->y, y_scale );
506 }
507
508 /* Then scale the metrics */
509 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
510 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
511 }
512
513 /* compute the other metrics */
514 FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
515
516 metrics->width = cbox.xMax - cbox.xMin;
517 metrics->height = cbox.yMax - cbox.yMin;
518
519 metrics->horiBearingX = cbox.xMin;
520 metrics->horiBearingY = cbox.yMax;
521
522 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
523 {
524 /* make up vertical ones */
526 metrics->vertAdvance );
527 }
528 }
529
530 Exit:
531
532 if ( must_finish_decoder )
533 psaux->t1_decoder_funcs->done( &decoder );
534
535#ifdef __REACTOS__
536 free(&decoder);
537#undef decoder
538 }
539#endif
540 return error;
541 }
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:3013
#define FT_LOAD_TARGET_MODE(x)
Definition: freetype.h:3137
FT_BEGIN_HEADER struct FT_Glyph_Metrics_ FT_Glyph_Metrics
#define FT_LOAD_NO_SCALE
Definition: freetype.h:3009
#define FT_LOAD_NO_RECURSE
Definition: freetype.h:3018
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3010
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
FT_Vector * vec
Definition: ftbbox.c:448
#define FIXED_TO_INT(x)
Definition: ftcalc.h:406
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_OUTLINE_HIGH_PRECISION
Definition: ftimage.h:435
#define FT_OUTLINE_OWNER
Definition: ftimage.h:428
#define FT_OUTLINE_REVERSE_FILL
Definition: ftimage.h:430
ft_synthesize_vertical_metrics(FT_Glyph_Metrics *metrics, FT_Pos advance)
Definition: ftobjs.c:2933
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:528
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:478
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
Definition: ftsmooth.c:426
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
signed long FT_Fixed
Definition: fttypes.h:288
int FT_Error
Definition: fttypes.h:300
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_BOOL(x)
Definition: fttypes.h:578
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:117
FT_Pos yMax
Definition: ftimage.h:118
FT_Pos yMin
Definition: ftimage.h:117
FT_Pos xMax
Definition: ftimage.h:118
FT_Fixed xx
Definition: fttypes.h:387
FT_Fixed yx
Definition: fttypes.h:388
FT_Fixed yy
Definition: fttypes.h:388
FT_Fixed xy
Definition: fttypes.h:387
FT_Pos x
Definition: ftimage.h:76
FT_Pos y
Definition: ftimage.h:77
FT_Bool no_recurse
Definition: psaux.h:798
FT_Vector advance
Definition: psaux.h:793
FT_Outline * base
Definition: psaux.h:786
FT_Vector left_bearing
Definition: psaux.h:792
void * hints_funcs
Definition: psaux.h:802
FT_Matrix font_matrix
Definition: psaux.h:913
T1_BuilderRec builder
Definition: psaux.h:895
FT_Vector font_offset
Definition: psaux.h:914
struct CID_FaceRec_ * CID_Face
Definition: t1types.h:197