1
/***************************************************************************/
5
/* OpenType Glyph Loader (body). */
7
/* Copyright 1996-2001, 2002, 2003, 2004 by */
8
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10
/* This file is part of the FreeType project, and may only be used, */
11
/* modified, and distributed under the terms of the FreeType project */
12
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13
/* this file you indicate that you have read the license and */
14
/* understand and accept it fully. */
16
/***************************************************************************/
20
#include FT_INTERNAL_DEBUG_H
21
#include FT_INTERNAL_CALC_H
22
#include FT_INTERNAL_STREAM_H
23
#include FT_INTERNAL_SFNT_H
25
#include FT_TRUETYPE_TAGS_H
26
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
35
/*************************************************************************/
37
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
38
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
39
/* messages during execution. */
42
#define FT_COMPONENT trace_cffgload
45
typedef enum CFF_Operator_
79
cff_op_dotsection, /* deprecated, acts as no-op */
119
#define CFF_COUNT_CHECK_WIDTH 0x80
120
#define CFF_COUNT_EXACT 0x40
121
#define CFF_COUNT_CLEAR_STACK 0x20
124
static const FT_Byte cff_argument_counts[] =
128
2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */
129
1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
130
1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
132
0 | CFF_COUNT_CLEAR_STACK, /* rlineto */
133
0 | CFF_COUNT_CLEAR_STACK,
134
0 | CFF_COUNT_CLEAR_STACK,
136
0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */
137
0 | CFF_COUNT_CLEAR_STACK,
138
0 | CFF_COUNT_CLEAR_STACK,
139
0 | CFF_COUNT_CLEAR_STACK,
140
0 | CFF_COUNT_CLEAR_STACK,
141
0 | CFF_COUNT_CLEAR_STACK,
142
0 | CFF_COUNT_CLEAR_STACK,
149
0 | CFF_COUNT_CHECK_WIDTH, /* endchar */
151
2 | CFF_COUNT_CHECK_WIDTH, /* hstem */
152
2 | CFF_COUNT_CHECK_WIDTH,
153
2 | CFF_COUNT_CHECK_WIDTH,
154
2 | CFF_COUNT_CHECK_WIDTH,
156
0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */
157
0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */
194
/*************************************************************************/
195
/*************************************************************************/
196
/*************************************************************************/
197
/********** *********/
198
/********** *********/
199
/********** GENERIC CHARSTRING PARSING *********/
200
/********** *********/
201
/********** *********/
202
/*************************************************************************/
203
/*************************************************************************/
204
/*************************************************************************/
207
/*************************************************************************/
210
/* cff_builder_init */
213
/* Initializes a given glyph builder. */
216
/* builder :: A pointer to the glyph builder to initialize. */
219
/* face :: The current face object. */
221
/* size :: The current size object. */
223
/* glyph :: The current glyph object. */
226
cff_builder_init( CFF_Builder* builder,
232
builder->path_begun = 0;
233
builder->load_points = 1;
235
builder->face = face;
236
builder->glyph = glyph;
237
builder->memory = face->root.memory;
241
FT_GlyphLoader loader = glyph->root.internal->loader;
244
builder->loader = loader;
245
builder->base = &loader->base.outline;
246
builder->current = &loader->current.outline;
247
FT_GlyphLoader_Rewind( loader );
249
builder->hints_globals = 0;
250
builder->hints_funcs = 0;
252
if ( hinting && size )
254
builder->hints_globals = size->root.internal;
255
builder->hints_funcs = glyph->root.internal->glyph_hints;
261
builder->scale_x = size->root.metrics.x_scale;
262
builder->scale_y = size->root.metrics.y_scale;
268
builder->left_bearing.x = 0;
269
builder->left_bearing.y = 0;
270
builder->advance.x = 0;
271
builder->advance.y = 0;
275
/*************************************************************************/
278
/* cff_builder_done */
281
/* Finalizes a given glyph builder. Its contents can still be used */
282
/* after the call, but the function saves important information */
283
/* within the corresponding glyph slot. */
286
/* builder :: A pointer to the glyph builder to finalize. */
289
cff_builder_done( CFF_Builder* builder )
291
CFF_GlyphSlot glyph = builder->glyph;
295
glyph->root.outline = *builder->base;
299
/*************************************************************************/
302
/* cff_compute_bias */
305
/* Computes the bias value in dependence of the number of glyph */
309
/* num_subrs :: The number of glyph subroutines. */
312
/* The bias value. */
314
cff_compute_bias( FT_UInt num_subrs )
319
if ( num_subrs < 1240 )
321
else if ( num_subrs < 33900U )
330
/*************************************************************************/
333
/* cff_decoder_init */
336
/* Initializes a given glyph decoder. */
339
/* decoder :: A pointer to the glyph builder to initialize. */
342
/* face :: The current face object. */
344
/* size :: The current size object. */
346
/* slot :: The current glyph object. */
349
cff_decoder_init( CFF_Decoder* decoder,
354
FT_Render_Mode hint_mode )
356
CFF_Font cff = (CFF_Font)face->extra.data;
359
/* clear everything */
360
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
362
/* initialize builder */
363
cff_builder_init( &decoder->builder, face, size, slot, hinting );
365
/* initialize Type2 decoder */
366
decoder->num_globals = cff->num_global_subrs;
367
decoder->globals = cff->global_subrs;
368
decoder->globals_bias = cff_compute_bias( decoder->num_globals );
370
decoder->hint_mode = hint_mode;
374
/* this function is used to select the locals subrs array */
376
cff_decoder_prepare( CFF_Decoder* decoder,
377
FT_UInt glyph_index )
379
CFF_Font cff = (CFF_Font)decoder->builder.face->extra.data;
380
CFF_SubFont sub = &cff->top_font;
383
/* manage CID fonts */
384
if ( cff->num_subfonts >= 1 )
386
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
389
sub = cff->subfonts[fd_index];
392
decoder->num_locals = sub->num_local_subrs;
393
decoder->locals = sub->local_subrs;
394
decoder->locals_bias = cff_compute_bias( decoder->num_locals );
396
decoder->glyph_width = sub->private_dict.default_width;
397
decoder->nominal_width = sub->private_dict.nominal_width;
401
/* check that there is enough space for `count' more points */
403
check_points( CFF_Builder* builder,
406
return FT_GlyphLoader_CheckPoints( builder->loader, count, 0 );
410
/* add a new point, do not check space */
412
cff_builder_add_point( CFF_Builder* builder,
417
FT_Outline* outline = builder->current;
420
if ( builder->load_points )
422
FT_Vector* point = outline->points + outline->n_points;
423
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
428
*control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
430
builder->last = *point;
437
/* check space for a new on-curve point, then add it */
439
cff_builder_add_point1( CFF_Builder* builder,
446
error = check_points( builder, 1 );
448
cff_builder_add_point( builder, x, y, 1 );
454
/* check space for a new contour, then add it */
456
cff_builder_add_contour( CFF_Builder* builder )
458
FT_Outline* outline = builder->current;
462
if ( !builder->load_points )
464
outline->n_contours++;
468
error = FT_GlyphLoader_CheckPoints( builder->loader, 0, 1 );
471
if ( outline->n_contours > 0 )
472
outline->contours[outline->n_contours - 1] =
473
(short)( outline->n_points - 1 );
475
outline->n_contours++;
482
/* if a path was begun, add its first on-curve point */
484
cff_builder_start_point( CFF_Builder* builder,
488
FT_Error error = CFF_Err_Ok;
491
/* test whether we are building a new contour */
492
if ( !builder->path_begun )
494
builder->path_begun = 1;
495
error = cff_builder_add_contour( builder );
497
error = cff_builder_add_point1( builder, x, y );
504
/* close the current contour */
506
cff_builder_close_contour( CFF_Builder* builder )
508
FT_Outline* outline = builder->current;
511
/* XXXX: We must not include the last point in the path if it */
512
/* is located on the first point. */
513
if ( outline->n_points > 1 )
516
FT_Vector* p1 = outline->points + first;
517
FT_Vector* p2 = outline->points + outline->n_points - 1;
518
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
521
if ( outline->n_contours > 1 )
523
first = outline->contours[outline->n_contours - 2] + 1;
524
p1 = outline->points + first;
527
/* `delete' last point only if it coincides with the first */
528
/* point and if it is not a control point (which can happen). */
529
if ( p1->x == p2->x && p1->y == p2->y )
530
if ( *control == FT_CURVE_TAG_ON )
534
if ( outline->n_contours > 0 )
535
outline->contours[outline->n_contours - 1] =
536
(short)( outline->n_points - 1 );
541
cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
548
/* CID-keyed fonts don't have glyph names */
549
if ( !cff->charset.sids )
552
/* check range of standard char code */
553
if ( charcode < 0 || charcode > 255 )
556
/* Get code to SID mapping from `cff_standard_encoding'. */
557
glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode );
559
for ( n = 0; n < cff->num_glyphs; n++ )
561
if ( cff->charset.sids[n] == glyph_sid )
570
cff_get_glyph_data( TT_Face face,
575
#ifdef FT_CONFIG_OPTION_INCREMENTAL
576
/* For incremental fonts get the character data using the */
577
/* callback function. */
578
if ( face->root.internal->incremental_interface )
582
face->root.internal->incremental_interface->funcs->get_glyph_data(
583
face->root.internal->incremental_interface->object,
584
glyph_index, &data );
587
*pointer = (FT_Byte*)data.pointer;
588
*length = data.length;
593
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
596
CFF_Font cff = (CFF_Font)(face->extra.data);
599
return cff_index_access_element( &cff->charstrings_index, glyph_index,
606
cff_free_glyph_data( TT_Face face,
610
#ifndef FT_CONFIG_OPTION_INCREMENTAL
614
#ifdef FT_CONFIG_OPTION_INCREMENTAL
615
/* For incremental fonts get the character data using the */
616
/* callback function. */
617
if ( face->root.internal->incremental_interface )
622
data.pointer = *pointer;
623
data.length = length;
625
face->root.internal->incremental_interface->funcs->free_glyph_data(
626
face->root.internal->incremental_interface->object,&data );
629
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
632
CFF_Font cff = (CFF_Font)(face->extra.data);
635
cff_index_forget_element( &cff->charstrings_index, pointer );
641
cff_operator_seac( CFF_Decoder* decoder,
648
CFF_Builder* builder = &decoder->builder;
649
FT_Int bchar_index, achar_index;
650
TT_Face face = decoder->builder.face;
651
FT_Vector left_bearing, advance;
653
FT_ULong charstring_len;
656
#ifdef FT_CONFIG_OPTION_INCREMENTAL
657
/* Incremental fonts don't necessarily have valid charsets. */
658
/* They use the character code, not the glyph index, in this case. */
659
if ( face->root.internal->incremental_interface )
665
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
667
CFF_Font cff = (CFF_Font)(face->extra.data);
670
bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
671
achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
674
if ( bchar_index < 0 || achar_index < 0 )
676
FT_ERROR(( "cff_operator_seac:" ));
677
FT_ERROR(( " invalid seac character code arguments\n" ));
678
return CFF_Err_Syntax_Error;
681
/* If we are trying to load a composite glyph, do not load the */
682
/* accent character and return the array of subglyphs. */
683
if ( builder->no_recurse )
685
FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph;
686
FT_GlyphLoader loader = glyph->internal->loader;
690
/* reallocate subglyph array if necessary */
691
error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
695
subg = loader->current.subglyphs;
697
/* subglyph 0 = base character */
698
subg->index = bchar_index;
699
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
700
FT_SUBGLYPH_FLAG_USE_MY_METRICS;
705
/* subglyph 1 = accent character */
706
subg->index = achar_index;
707
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
708
subg->arg1 = (FT_Int)( adx >> 16 );
709
subg->arg2 = (FT_Int)( ady >> 16 );
711
/* set up remaining glyph fields */
712
glyph->num_subglyphs = 2;
713
glyph->subglyphs = loader->base.subglyphs;
714
glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
716
loader->current.num_subglyphs = 2;
719
FT_GlyphLoader_Prepare( builder->loader );
721
/* First load `bchar' in builder */
722
error = cff_get_glyph_data( face, bchar_index,
723
&charstring, &charstring_len );
726
error = cff_decoder_parse_charstrings( decoder, charstring,
732
cff_free_glyph_data( face, &charstring, charstring_len );
735
/* Save the left bearing and width of the base character */
736
/* as they will be erased by the next load. */
738
left_bearing = builder->left_bearing;
739
advance = builder->advance;
741
builder->left_bearing.x = 0;
742
builder->left_bearing.y = 0;
744
builder->pos_x = adx;
745
builder->pos_y = ady;
747
/* Now load `achar' on top of the base outline. */
748
error = cff_get_glyph_data( face, achar_index,
749
&charstring, &charstring_len );
752
error = cff_decoder_parse_charstrings( decoder, charstring,
758
cff_free_glyph_data( face, &charstring, charstring_len );
761
/* Restore the left side bearing and advance width */
762
/* of the base character. */
763
builder->left_bearing = left_bearing;
764
builder->advance = advance;
774
/*************************************************************************/
777
/* cff_decoder_parse_charstrings */
780
/* Parses a given Type 2 charstrings program. */
783
/* decoder :: The current Type 1 decoder. */
786
/* charstring_base :: The base of the charstring stream. */
788
/* charstring_len :: The length in bytes of the charstring stream. */
791
/* FreeType error code. 0 means success. */
793
FT_LOCAL_DEF( FT_Error )
794
cff_decoder_parse_charstrings( CFF_Decoder* decoder,
795
FT_Byte* charstring_base,
796
FT_ULong charstring_len )
799
CFF_Decoder_Zone* zone;
802
CFF_Builder* builder = &decoder->builder;
807
T2_Hints_Funcs hinter;
810
/* set default width */
811
decoder->num_hints = 0;
812
decoder->read_width = 1;
814
/* compute random seed from stack address of parameter */
815
seed = (FT_Fixed)(char*)&seed ^
816
(FT_Fixed)(char*)&decoder ^
817
(FT_Fixed)(char*)&charstring_base;
818
seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
822
/* initialize the decoder */
823
decoder->top = decoder->stack;
824
decoder->zone = decoder->zones;
825
zone = decoder->zones;
826
stack = decoder->top;
828
hinter = (T2_Hints_Funcs)builder->hints_funcs;
830
builder->path_begun = 0;
832
zone->base = charstring_base;
833
limit = zone->limit = charstring_base + charstring_len;
834
ip = zone->cursor = zone->base;
841
/* begin hints recording session, if any */
843
hinter->open( hinter->hints );
845
/* now execute loop */
852
/********************************************************************/
854
/* Decode operator or operand */
857
if ( v >= 32 || v == 28 )
863
/* this is an operand, push it on the stack */
866
if ( ip + 1 >= limit )
868
val = (FT_Short)( ( (FT_Short)ip[0] << 8 ) | ip[1] );
872
val = (FT_Long)v - 139;
877
val = ( (FT_Long)v - 247 ) * 256 + *ip++ + 108;
883
val = -( (FT_Long)v - 251 ) * 256 - *ip++ - 108;
887
if ( ip + 3 >= limit )
889
val = ( (FT_Int32)ip[0] << 24 ) |
890
( (FT_Int32)ip[1] << 16 ) |
891
( (FT_Int32)ip[2] << 8 ) |
896
if ( decoder->top - stack >= CFF_MAX_OPERANDS )
900
*decoder->top++ = val;
902
#ifdef FT_DEBUG_LEVEL_TRACE
903
if ( !( val & 0xFFFFL ) )
904
FT_TRACE4(( " %ld", (FT_Int32)( val >> 16 ) ));
906
FT_TRACE4(( " %.2f", val / 65536.0 ));
912
FT_Fixed* args = decoder->top;
913
FT_Int num_args = (FT_Int)( args - decoder->stack );
941
op = cff_op_rrcurveto;
944
op = cff_op_callsubr;
958
op = cff_op_dotsection;
1039
/* decrement ip for syntax error message */
1045
op = cff_op_endchar;
1051
op = cff_op_hstemhm;
1054
op = cff_op_hintmask;
1057
op = cff_op_cntrmask;
1060
op = cff_op_rmoveto;
1063
op = cff_op_hmoveto;
1066
op = cff_op_vstemhm;
1069
op = cff_op_rcurveline;
1072
op = cff_op_rlinecurve;
1075
op = cff_op_vvcurveto;
1078
op = cff_op_hhcurveto;
1081
op = cff_op_callgsubr;
1084
op = cff_op_vhcurveto;
1087
op = cff_op_hvcurveto;
1092
if ( op == cff_op_unknown )
1095
/* check arguments */
1096
req_args = cff_argument_counts[op];
1097
if ( req_args & CFF_COUNT_CHECK_WIDTH )
1101
if ( num_args > 0 && decoder->read_width )
1103
/* If `nominal_width' is non-zero, the number is really a */
1104
/* difference against `nominal_width'. Else, the number here */
1105
/* is truly a width, not a difference against `nominal_width'. */
1106
/* If the font does not set `nominal_width', then */
1107
/* `nominal_width' defaults to zero, and so we can set */
1108
/* `glyph_width' to `nominal_width' plus number on the stack */
1109
/* -- for either case. */
1111
FT_Int set_width_ok;
1116
case cff_op_hmoveto:
1117
case cff_op_vmoveto:
1118
set_width_ok = num_args & 2;
1123
case cff_op_hstemhm:
1124
case cff_op_vstemhm:
1125
case cff_op_rmoveto:
1126
case cff_op_hintmask:
1127
case cff_op_cntrmask:
1128
set_width_ok = num_args & 1;
1131
case cff_op_endchar:
1132
/* If there is a width specified for endchar, we either have */
1133
/* 1 argument or 5 arguments. We like to argue. */
1134
set_width_ok = ( ( num_args == 5 ) || ( num_args == 1 ) );
1144
decoder->glyph_width = decoder->nominal_width +
1147
/* Consumed an argument. */
1153
decoder->read_width = 0;
1158
if ( num_args < req_args )
1159
goto Stack_Underflow;
1161
num_args -= req_args;
1167
case cff_op_hstemhm:
1168
case cff_op_vstemhm:
1169
/* the number of arguments is always even here */
1170
FT_TRACE4(( op == cff_op_hstem ? " hstem" :
1171
( op == cff_op_vstem ? " vstem" :
1172
( op == cff_op_hstemhm ? " hstemhm" : " vstemhm" ) ) ));
1175
hinter->stems( hinter->hints,
1176
( op == cff_op_hstem || op == cff_op_hstemhm ),
1180
decoder->num_hints += num_args / 2;
1184
case cff_op_hintmask:
1185
case cff_op_cntrmask:
1186
FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" ));
1188
/* implement vstem when needed -- */
1189
/* the specification doesn't say it, but this also works */
1190
/* with the 'cntrmask' operator */
1195
hinter->stems( hinter->hints,
1200
decoder->num_hints += num_args / 2;
1205
if ( op == cff_op_hintmask )
1206
hinter->hintmask( hinter->hints,
1207
builder->current->n_points,
1211
hinter->counter( hinter->hints,
1216
#ifdef FT_DEBUG_LEVEL_TRACE
1224
maskbyte < (FT_UInt)(( decoder->num_hints + 7 ) >> 3);
1226
FT_TRACE4(( "0x%02X", *ip ));
1229
ip += ( decoder->num_hints + 7 ) >> 3;
1236
case cff_op_rmoveto:
1237
FT_TRACE4(( " rmoveto" ));
1239
cff_builder_close_contour( builder );
1240
builder->path_begun = 0;
1246
case cff_op_vmoveto:
1247
FT_TRACE4(( " vmoveto" ));
1249
cff_builder_close_contour( builder );
1250
builder->path_begun = 0;
1255
case cff_op_hmoveto:
1256
FT_TRACE4(( " hmoveto" ));
1258
cff_builder_close_contour( builder );
1259
builder->path_begun = 0;
1264
case cff_op_rlineto:
1265
FT_TRACE4(( " rlineto" ));
1267
if ( cff_builder_start_point ( builder, x, y ) ||
1268
check_points( builder, num_args / 2 ) )
1271
if ( num_args < 2 || num_args & 1 )
1272
goto Stack_Underflow;
1275
while ( args < decoder->top )
1279
cff_builder_add_point( builder, x, y, 1 );
1285
case cff_op_hlineto:
1286
case cff_op_vlineto:
1288
FT_Int phase = ( op == cff_op_hlineto );
1291
FT_TRACE4(( op == cff_op_hlineto ? " hlineto"
1294
if ( cff_builder_start_point ( builder, x, y ) ||
1295
check_points( builder, num_args ) )
1299
while (args < decoder->top )
1306
if ( cff_builder_add_point1( builder, x, y ) )
1316
case cff_op_rrcurveto:
1317
FT_TRACE4(( " rrcurveto" ));
1319
/* check number of arguments; must be a multiple of 6 */
1320
if ( num_args % 6 != 0 )
1321
goto Stack_Underflow;
1323
if ( cff_builder_start_point ( builder, x, y ) ||
1324
check_points( builder, num_args / 2 ) )
1328
while ( args < decoder->top )
1332
cff_builder_add_point( builder, x, y, 0 );
1335
cff_builder_add_point( builder, x, y, 0 );
1338
cff_builder_add_point( builder, x, y, 1 );
1344
case cff_op_vvcurveto:
1345
FT_TRACE4(( " vvcurveto" ));
1347
if ( cff_builder_start_point( builder, x, y ) )
1358
if ( num_args % 4 != 0 )
1359
goto Stack_Underflow;
1361
if ( check_points( builder, 3 * ( num_args / 4 ) ) )
1364
while ( args < decoder->top )
1367
cff_builder_add_point( builder, x, y, 0 );
1370
cff_builder_add_point( builder, x, y, 0 );
1372
cff_builder_add_point( builder, x, y, 1 );
1378
case cff_op_hhcurveto:
1379
FT_TRACE4(( " hhcurveto" ));
1381
if ( cff_builder_start_point( builder, x, y ) )
1392
if ( num_args % 4 != 0 )
1393
goto Stack_Underflow;
1395
if ( check_points( builder, 3 * ( num_args / 4 ) ) )
1398
while ( args < decoder->top )
1401
cff_builder_add_point( builder, x, y, 0 );
1404
cff_builder_add_point( builder, x, y, 0 );
1406
cff_builder_add_point( builder, x, y, 1 );
1412
case cff_op_vhcurveto:
1413
case cff_op_hvcurveto:
1418
FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto"
1421
if ( cff_builder_start_point( builder, x, y ) )
1425
if (num_args < 4 || ( num_args % 4 ) > 1 )
1426
goto Stack_Underflow;
1428
if ( check_points( builder, ( num_args / 4 ) * 3 ) )
1429
goto Stack_Underflow;
1431
phase = ( op == cff_op_hvcurveto );
1433
while ( num_args >= 4 )
1439
cff_builder_add_point( builder, x, y, 0 );
1442
cff_builder_add_point( builder, x, y, 0 );
1444
if ( num_args == 1 )
1446
cff_builder_add_point( builder, x, y, 1 );
1451
cff_builder_add_point( builder, x, y, 0 );
1454
cff_builder_add_point( builder, x, y, 0 );
1456
if ( num_args == 1 )
1458
cff_builder_add_point( builder, x, y, 1 );
1467
case cff_op_rlinecurve:
1469
FT_Int num_lines = ( num_args - 6 ) / 2;
1472
FT_TRACE4(( " rlinecurve" ));
1474
if ( num_args < 8 || ( num_args - 6 ) & 1 )
1475
goto Stack_Underflow;
1477
if ( cff_builder_start_point( builder, x, y ) ||
1478
check_points( builder, num_lines + 3 ) )
1483
/* first, add the line segments */
1484
while ( num_lines > 0 )
1488
cff_builder_add_point( builder, x, y, 1 );
1493
/* then the curve */
1496
cff_builder_add_point( builder, x, y, 0 );
1499
cff_builder_add_point( builder, x, y, 0 );
1502
cff_builder_add_point( builder, x, y, 1 );
1507
case cff_op_rcurveline:
1509
FT_Int num_curves = ( num_args - 2 ) / 6;
1512
FT_TRACE4(( " rcurveline" ));
1514
if ( num_args < 8 || ( num_args - 2 ) % 6 )
1515
goto Stack_Underflow;
1517
if ( cff_builder_start_point ( builder, x, y ) ||
1518
check_points( builder, num_curves*3 + 2 ) )
1523
/* first, add the curves */
1524
while ( num_curves > 0 )
1528
cff_builder_add_point( builder, x, y, 0 );
1531
cff_builder_add_point( builder, x, y, 0 );
1534
cff_builder_add_point( builder, x, y, 1 );
1539
/* then the final line */
1542
cff_builder_add_point( builder, x, y, 1 );
1552
FT_TRACE4(( " hflex1" ));
1556
/* adding five more points; 4 control points, 1 on-curve point */
1557
/* make sure we have enough space for the start point if it */
1558
/* needs to be added */
1559
if ( cff_builder_start_point( builder, x, y ) ||
1560
check_points( builder, 6 ) )
1563
/* Record the starting point's y postion for later use */
1566
/* first control point */
1569
cff_builder_add_point( builder, x, y, 0 );
1571
/* second control point */
1574
cff_builder_add_point( builder, x, y, 0 );
1576
/* join point; on curve, with y-value the same as the last */
1577
/* control point's y-value */
1579
cff_builder_add_point( builder, x, y, 1 );
1581
/* third control point, with y-value the same as the join */
1582
/* point's y-value */
1584
cff_builder_add_point( builder, x, y, 0 );
1586
/* fourth control point */
1589
cff_builder_add_point( builder, x, y, 0 );
1591
/* ending point, with y-value the same as the start */
1594
cff_builder_add_point( builder, x, y, 1 );
1605
FT_TRACE4(( " hflex" ));
1609
/* adding six more points; 4 control points, 2 on-curve points */
1610
if ( cff_builder_start_point( builder, x, y ) ||
1611
check_points( builder, 6 ) )
1614
/* record the starting point's y-position for later use */
1617
/* first control point */
1619
cff_builder_add_point( builder, x, y, 0 );
1621
/* second control point */
1624
cff_builder_add_point( builder, x, y, 0 );
1626
/* join point; on curve, with y-value the same as the last */
1627
/* control point's y-value */
1629
cff_builder_add_point( builder, x, y, 1 );
1631
/* third control point, with y-value the same as the join */
1632
/* point's y-value */
1634
cff_builder_add_point( builder, x, y, 0 );
1636
/* fourth control point */
1639
cff_builder_add_point( builder, x, y, 0 );
1641
/* ending point, with y-value the same as the start point's */
1642
/* y-value -- we don't add this point, though */
1644
cff_builder_add_point( builder, x, y, 1 );
1652
FT_Pos start_x, start_y; /* record start x, y values for */
1654
FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */
1655
/* algorithm below */
1656
FT_Int horizontal, count;
1659
FT_TRACE4(( " flex1" ));
1661
/* adding six more points; 4 control points, 2 on-curve points */
1662
if ( cff_builder_start_point( builder, x, y ) ||
1663
check_points( builder, 6 ) )
1666
/* record the starting point's x, y postion for later use */
1670
/* XXX: figure out whether this is supposed to be a horizontal */
1671
/* or vertical flex; the Type 2 specification is vague... */
1675
/* grab up to the last argument */
1676
for ( count = 5; count > 0; count-- )
1686
if ( dx < 0 ) dx = -dx;
1687
if ( dy < 0 ) dy = -dy;
1689
/* strange test, but here it is... */
1690
horizontal = ( dx > dy );
1692
for ( count = 5; count > 0; count-- )
1696
cff_builder_add_point( builder, x, y, (FT_Bool)( count == 3 ) );
1700
/* is last operand an x- or y-delta? */
1712
cff_builder_add_point( builder, x, y, 1 );
1723
FT_TRACE4(( " flex" ));
1725
if ( cff_builder_start_point( builder, x, y ) ||
1726
check_points( builder, 6 ) )
1730
for ( count = 6; count > 0; count-- )
1734
cff_builder_add_point( builder, x, y,
1735
(FT_Bool)( count == 4 || count == 1 ) );
1743
case cff_op_endchar:
1744
FT_TRACE4(( " endchar" ));
1746
/* We are going to emulate the seac operator. */
1747
if ( num_args == 4 )
1749
/* Save glyph width so that the subglyphs don't overwrite it. */
1750
FT_Pos glyph_width = decoder->glyph_width;
1753
error = cff_operator_seac( decoder,
1756
(FT_Int)( args[2] >> 16 ),
1757
(FT_Int)( args[3] >> 16 ) );
1760
decoder->glyph_width = glyph_width;
1767
cff_builder_close_contour( builder );
1769
/* close hints recording session */
1772
if (hinter->close( hinter->hints, builder->current->n_points ) )
1775
/* apply hints to the loaded glyph outline now */
1776
hinter->apply( hinter->hints,
1778
(PSH_Globals)builder->hints_globals,
1779
decoder->hint_mode );
1782
/* add current outline to the glyph slot */
1783
FT_GlyphLoader_Add( builder->loader );
1787
FT_TRACE4(( "\n\n" ));
1791
FT_TRACE4(( " abs" ));
1799
FT_TRACE4(( " add" ));
1806
FT_TRACE4(( " sub" ));
1813
FT_TRACE4(( " div" ));
1815
args[0] = FT_DivFix( args[0], args[1] );
1820
FT_TRACE4(( " neg" ));
1831
FT_TRACE4(( " rand" ));
1834
if ( Rand >= 0x8000L )
1838
seed = FT_MulFix( seed, 0x10000L - seed );
1846
FT_TRACE4(( " mul" ));
1848
args[0] = FT_MulFix( args[0], args[1] );
1853
FT_TRACE4(( " sqrt" ));
1858
FT_Fixed root = args[0];
1864
new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
1865
if ( new_root == root || count <= 0 )
1878
FT_TRACE4(( " drop" ));
1887
FT_TRACE4(( " exch" ));
1898
FT_Int idx = (FT_Int)( args[0] >> 16 );
1901
FT_TRACE4(( " index" ));
1905
else if ( idx > num_args - 2 )
1907
args[0] = args[-( idx + 1 )];
1914
FT_Int count = (FT_Int)( args[0] >> 16 );
1915
FT_Int idx = (FT_Int)( args[1] >> 16 );
1918
FT_TRACE4(( " roll" ));
1925
goto Stack_Underflow;
1931
FT_Fixed tmp = args[count - 1];
1935
for ( i = count - 2; i >= 0; i-- )
1936
args[i + 1] = args[i];
1945
FT_Fixed tmp = args[0];
1949
for ( i = 0; i < count - 1; i++ )
1950
args[i] = args[i + 1];
1951
args[count - 1] = tmp;
1960
FT_TRACE4(( " dup" ));
1968
FT_Fixed val = args[0];
1969
FT_Int idx = (FT_Int)( args[1] >> 16 );
1972
FT_TRACE4(( " put" ));
1974
if ( idx >= 0 && idx < decoder->len_buildchar )
1975
decoder->buildchar[idx] = val;
1981
FT_Int idx = (FT_Int)( args[0] >> 16 );
1985
FT_TRACE4(( " get" ));
1987
if ( idx >= 0 && idx < decoder->len_buildchar )
1988
val = decoder->buildchar[idx];
1996
FT_TRACE4(( " store "));
2001
FT_TRACE4(( " load" ));
2005
case cff_op_dotsection:
2006
/* this operator is deprecated and ignored by the parser */
2007
FT_TRACE4(( " dotsection" ));
2012
FT_Fixed cond = args[0] && args[1];
2015
FT_TRACE4(( " and" ));
2017
args[0] = cond ? 0x10000L : 0;
2024
FT_Fixed cond = args[0] || args[1];
2027
FT_TRACE4(( " or" ));
2029
args[0] = cond ? 0x10000L : 0;
2036
FT_Fixed cond = !args[0];
2039
FT_TRACE4(( " eq" ));
2041
args[0] = cond ? 0x10000L : 0;
2048
FT_Fixed cond = (args[2] <= args[3]);
2051
FT_TRACE4(( " ifelse" ));
2059
case cff_op_callsubr:
2061
FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
2062
decoder->locals_bias );
2065
FT_TRACE4(( " callsubr(%d)", idx ));
2067
if ( idx >= decoder->num_locals )
2069
FT_ERROR(( "cff_decoder_parse_charstrings:" ));
2070
FT_ERROR(( " invalid local subr index\n" ));
2074
if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
2076
FT_ERROR(( "cff_decoder_parse_charstrings:"
2077
" too many nested subrs\n" ));
2081
zone->cursor = ip; /* save current instruction pointer */
2084
zone->base = decoder->locals[idx];
2085
zone->limit = decoder->locals[idx + 1];
2086
zone->cursor = zone->base;
2090
FT_ERROR(( "cff_decoder_parse_charstrings:"
2091
" invoking empty subrs!\n" ));
2095
decoder->zone = zone;
2097
limit = zone->limit;
2101
case cff_op_callgsubr:
2103
FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
2104
decoder->globals_bias );
2107
FT_TRACE4(( " callgsubr(%d)", idx ));
2109
if ( idx >= decoder->num_globals )
2111
FT_ERROR(( "cff_decoder_parse_charstrings:" ));
2112
FT_ERROR(( " invalid global subr index\n" ));
2116
if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
2118
FT_ERROR(( "cff_decoder_parse_charstrings:"
2119
" too many nested subrs\n" ));
2123
zone->cursor = ip; /* save current instruction pointer */
2126
zone->base = decoder->globals[idx];
2127
zone->limit = decoder->globals[idx + 1];
2128
zone->cursor = zone->base;
2132
FT_ERROR(( "cff_decoder_parse_charstrings:"
2133
" invoking empty subrs!\n" ));
2137
decoder->zone = zone;
2139
limit = zone->limit;
2144
FT_TRACE4(( " return" ));
2146
if ( decoder->zone <= decoder->zones )
2148
FT_ERROR(( "cff_decoder_parse_charstrings:"
2149
" unexpected return\n" ));
2154
zone = decoder->zone;
2156
limit = zone->limit;
2161
FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));
2164
FT_ERROR(( " %d", ip[0] ));
2167
return CFF_Err_Unimplemented_Feature;
2170
decoder->top = args;
2172
} /* general operator processing */
2174
} /* while ip < limit */
2176
FT_TRACE4(( "..end..\n\n" ));
2182
FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error!" ));
2183
return CFF_Err_Invalid_File_Format;
2186
FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow!" ));
2187
return CFF_Err_Too_Few_Arguments;
2190
FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow!" ));
2191
return CFF_Err_Stack_Overflow;
2195
/*************************************************************************/
2196
/*************************************************************************/
2197
/*************************************************************************/
2198
/********** *********/
2199
/********** *********/
2200
/********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
2201
/********** *********/
2202
/********** The following code is in charge of computing *********/
2203
/********** the maximum advance width of the font. It *********/
2204
/********** quickly processes each glyph charstring to *********/
2205
/********** extract the value from either a `sbw' or `seac' *********/
2206
/********** operator. *********/
2207
/********** *********/
2208
/*************************************************************************/
2209
/*************************************************************************/
2210
/*************************************************************************/
2213
#if 0 /* unused until we support pure CFF fonts */
2216
FT_LOCAL_DEF( FT_Error )
2217
cff_compute_max_advance( TT_Face face,
2218
FT_Int* max_advance )
2220
FT_Error error = CFF_Err_Ok;
2221
CFF_Decoder decoder;
2223
CFF_Font cff = (CFF_Font)face->other;
2228
/* Initialize load decoder */
2229
cff_decoder_init( &decoder, face, 0, 0, 0, 0 );
2231
decoder.builder.metrics_only = 1;
2232
decoder.builder.load_points = 0;
2234
/* For each glyph, parse the glyph charstring and extract */
2235
/* the advance width. */
2236
for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
2239
FT_Byte* charstring;
2240
FT_ULong charstring_len;
2243
/* now get load the unscaled outline */
2244
error = cff_get_glyph_data( face, glyph_index,
2245
&charstring, &charstring_len );
2248
cff_decoder_prepare( &decoder, glyph_index );
2249
error = cff_decoder_parse_charstrings( &decoder,
2250
charstring, charstring_len );
2252
cff_free_glyph_data( face, &charstring, &charstring_len );
2255
/* ignore the error if one has occurred -- skip to next glyph */
2259
*max_advance = decoder.builder.advance.x;
2268
/*************************************************************************/
2269
/*************************************************************************/
2270
/*************************************************************************/
2271
/********** *********/
2272
/********** *********/
2273
/********** UNHINTED GLYPH LOADER *********/
2274
/********** *********/
2275
/********** The following code is in charge of loading a *********/
2276
/********** single outline. It completely ignores hinting *********/
2277
/********** and is used when FT_LOAD_NO_HINTING is set. *********/
2278
/********** *********/
2279
/*************************************************************************/
2280
/*************************************************************************/
2281
/*************************************************************************/
2284
FT_LOCAL_DEF( FT_Error )
2285
cff_slot_load( CFF_GlyphSlot glyph,
2288
FT_Int32 load_flags )
2291
CFF_Decoder decoder;
2292
TT_Face face = (TT_Face)glyph->root.face;
2294
CFF_Font cff = (CFF_Font)face->extra.data;
2296
FT_Matrix font_matrix;
2297
FT_Vector font_offset;
2300
if ( load_flags & FT_LOAD_NO_RECURSE )
2301
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
2303
glyph->x_scale = 0x10000L;
2304
glyph->y_scale = 0x10000L;
2307
glyph->x_scale = size->root.metrics.x_scale;
2308
glyph->y_scale = size->root.metrics.y_scale;
2311
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
2313
/* try to load embedded bitmap if any */
2315
/* XXX: The convention should be emphasized in */
2316
/* the documents because it can be confusing. */
2319
CFF_Face cff_face = (CFF_Face)size->root.face;
2320
SFNT_Service sfnt = (SFNT_Service)cff_face->sfnt;
2321
FT_Stream stream = cff_face->root.stream;
2324
if ( size->strike_index != 0xFFFFU &&
2326
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
2328
TT_SBit_MetricsRec metrics;
2331
error = sfnt->load_sbit_image( face,
2332
(FT_ULong)size->strike_index,
2333
(FT_UInt)glyph_index,
2336
&glyph->root.bitmap,
2341
glyph->root.outline.n_points = 0;
2342
glyph->root.outline.n_contours = 0;
2344
glyph->root.metrics.width = (FT_Pos)metrics.width << 6;
2345
glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
2347
glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
2348
glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
2349
glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6;
2351
glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
2352
glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
2353
glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
2355
glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
2357
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
2359
glyph->root.bitmap_left = metrics.vertBearingX;
2360
glyph->root.bitmap_top = metrics.vertBearingY;
2364
glyph->root.bitmap_left = metrics.horiBearingX;
2365
glyph->root.bitmap_top = metrics.horiBearingY;
2372
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
2374
/* return immediately if we only want the embedded bitmaps */
2375
if ( load_flags & FT_LOAD_SBITS_ONLY )
2376
return CFF_Err_Invalid_Argument;
2378
glyph->root.outline.n_points = 0;
2379
glyph->root.outline.n_contours = 0;
2381
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
2382
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
2384
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
2387
FT_Byte* charstring;
2388
FT_ULong charstring_len;
2391
/* in a CID-keyed font, consider `glyph_index' as a CID and map */
2392
/* it immediately to the real glyph_index -- if it isn't a */
2393
/* subsetted font, glyph_indices and CIDs are identical, though */
2394
if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
2396
glyph_index = cff->charset.cids[glyph_index];
2398
cff_decoder_init( &decoder, face, size, glyph, hinting,
2399
FT_LOAD_TARGET_MODE( load_flags ) );
2401
decoder.builder.no_recurse =
2402
(FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
2404
/* now load the unscaled outline */
2405
error = cff_get_glyph_data( face, glyph_index,
2406
&charstring, &charstring_len );
2409
cff_decoder_prepare( &decoder, glyph_index );
2410
error = cff_decoder_parse_charstrings( &decoder,
2411
charstring, charstring_len );
2413
cff_free_glyph_data( face, &charstring, charstring_len );
2416
#ifdef FT_CONFIG_OPTION_INCREMENTAL
2417
/* Control data and length may not be available for incremental */
2419
if ( face->root.internal->incremental_interface )
2421
glyph->root.control_data = 0;
2422
glyph->root.control_len = 0;
2425
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
2427
/* We set control_data and control_len if charstrings is loaded. */
2428
/* See how charstring loads at cff_index_access_element() in */
2431
CFF_IndexRec csindex = cff->charstrings_index;
2434
glyph->root.control_data =
2435
csindex.bytes + csindex.offsets[glyph_index] - 1;
2436
glyph->root.control_len =
2441
/* save new glyph tables */
2442
cff_builder_done( &decoder.builder );
2445
#ifdef FT_CONFIG_OPTION_INCREMENTAL
2447
/* Incremental fonts can optionally override the metrics. */
2449
face->root.internal->incremental_interface &&
2450
face->root.internal->incremental_interface->funcs->get_glyph_metrics )
2452
FT_Incremental_MetricsRec metrics;
2455
metrics.bearing_x = decoder.builder.left_bearing.x;
2456
metrics.bearing_y = decoder.builder.left_bearing.y;
2457
metrics.advance = decoder.builder.advance.x;
2458
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
2459
face->root.internal->incremental_interface->object,
2460
glyph_index, FALSE, &metrics );
2461
decoder.builder.left_bearing.x = metrics.bearing_x;
2462
decoder.builder.left_bearing.y = metrics.bearing_y;
2463
decoder.builder.advance.x = metrics.advance;
2464
decoder.builder.advance.y = 0;
2467
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
2469
font_matrix = cff->top_font.font_dict.font_matrix;
2470
font_offset = cff->top_font.font_dict.font_offset;
2472
/* Now, set the metrics -- this is rather simple, as */
2473
/* the left side bearing is the xMin, and the top side */
2474
/* bearing the yMax. */
2477
/* For composite glyphs, return only left side bearing and */
2478
/* advance width. */
2479
if ( load_flags & FT_LOAD_NO_RECURSE )
2481
FT_Slot_Internal internal = glyph->root.internal;
2484
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
2485
glyph->root.metrics.horiAdvance = decoder.glyph_width;
2486
internal->glyph_matrix = font_matrix;
2487
internal->glyph_delta = font_offset;
2488
internal->glyph_transformed = 1;
2493
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
2497
/* copy the _unscaled_ advance width */
2498
metrics->horiAdvance = decoder.glyph_width;
2499
glyph->root.linearHoriAdvance = decoder.glyph_width;
2500
glyph->root.internal->glyph_transformed = 0;
2502
/* make up vertical metrics */
2503
metrics->vertBearingX = 0;
2504
metrics->vertBearingY = 0;
2505
metrics->vertAdvance = 0;
2507
glyph->root.linearVertAdvance = 0;
2509
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
2511
glyph->root.outline.flags = 0;
2512
if ( size && size->root.metrics.y_ppem < 24 )
2513
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
2515
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
2517
/* apply the font matrix */
2518
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
2520
FT_Outline_Translate( &glyph->root.outline,
2524
advance.x = metrics->horiAdvance;
2526
FT_Vector_Transform( &advance, &font_matrix );
2527
metrics->horiAdvance = advance.x + font_offset.x;
2529
advance.y = metrics->vertAdvance;
2530
FT_Vector_Transform( &advance, &font_matrix );
2531
metrics->vertAdvance = advance.y + font_offset.y;
2533
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
2535
/* scale the outline and the metrics */
2537
FT_Outline* cur = &glyph->root.outline;
2538
FT_Vector* vec = cur->points;
2539
FT_Fixed x_scale = glyph->x_scale;
2540
FT_Fixed y_scale = glyph->y_scale;
2543
/* First of all, scale the points */
2545
for ( n = cur->n_points; n > 0; n--, vec++ )
2547
vec->x = FT_MulFix( vec->x, x_scale );
2548
vec->y = FT_MulFix( vec->y, y_scale );
2551
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
2553
/* Then scale the metrics */
2554
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
2555
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
2557
metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
2558
metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
2562
metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance );
2563
metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance );
2565
metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX );
2566
metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY );
2570
/* compute the other metrics */
2571
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
2573
/* grid fit the bounding box if necessary */
2578
cbox.xMax = ( cbox.xMax + 63 ) & -64;
2579
cbox.yMax = ( cbox.yMax + 63 ) & -64;
2582
metrics->width = cbox.xMax - cbox.xMin;
2583
metrics->height = cbox.yMax - cbox.yMin;
2585
metrics->horiBearingX = cbox.xMin;
2586
metrics->horiBearingY = cbox.yMax;