From ac39ecdca8db98fcca49f56a615cd84d796bd9bc Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 30 Jun 2000 22:24:36 +0000 Subject: [PATCH] Formatting... Fixing incorrect scaling of vertical advance width. --- src/cff/t2gload.c | 4 +- src/cid/cidafm.c | 16 +++----- src/cid/cidafm.h | 4 -- src/cid/cidgload.c | 96 +++++++++++++++++++++++++------------------- src/cid/cidload.c | 23 ++++++----- src/cid/cidobjs.c | 8 ++-- src/cid/cidobjs.h | 20 ++++----- src/cid/cidparse.c | 20 +++++---- src/type1/t1gload.c | 5 ++- src/type1z/z1gload.c | 2 +- 10 files changed, 107 insertions(+), 91 deletions(-) diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c index 47f979484..dfde78b14 100644 --- a/src/cff/t2gload.c +++ b/src/cff/t2gload.c @@ -1659,7 +1659,7 @@ T2_Forget_Element( &cff->charstrings_index, &charstring ); } - /* ignore the error if one has occured - skip to next glyph */ + /* ignore the error if one has occurred -- skip to next glyph */ error = 0; } @@ -1800,10 +1800,10 @@ /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); + metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale ); } #if 0 diff --git a/src/cid/cidafm.c b/src/cid/cidafm.c index 3b1bd2673..ce2739b99 100644 --- a/src/cid/cidafm.c +++ b/src/cid/cidafm.c @@ -36,8 +36,6 @@ #define FT_COMPONENT trace_cidafm -#if 1 - LOCAL_FUNC void CID_Done_AFM( FT_Memory memory, CID_AFM* afm ) @@ -120,7 +118,7 @@ while ( p < limit && !isdigit( *p ) ) { sign = 1; - if (*p == '-') + if ( *p == '-' ) sign = -1; p++; @@ -138,7 +136,7 @@ #undef KERN_INDEX -#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) +#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) /* compare two kerning pairs */ @@ -157,7 +155,7 @@ } - /* parse an AFM file - for now, only read the kerning pairs */ + /* parse an AFM file -- for now, only read the kerning pairs */ LOCAL_FUNC FT_Error CID_Read_AFM( FT_Face cid_face, FT_Stream stream ) @@ -180,8 +178,8 @@ limit = (FT_Byte*)stream->limit; p = start; - /* we are now going to count the occurences of `KP' or `KPX' in */ - /* the AFM file. */ + /* we are now going to count the occurrences of `KP' or `KPX' in */ + /* the AFM file. */ count = 0; for ( p = start; p < limit - 3; p++ ) { @@ -212,7 +210,7 @@ FT_Byte* q; - /* skip keyword (KP or KPX) */ + /* skip keyword (`KP' or `KPX') */ q = p + 2; if ( *q == 'X' ) q++; @@ -281,7 +279,5 @@ kerning->y = 0; } -#endif /* 1 */ - /* END */ diff --git a/src/cid/cidafm.h b/src/cid/cidafm.h index 61c5ad721..93e8b97a2 100644 --- a/src/cid/cidafm.h +++ b/src/cid/cidafm.h @@ -38,8 +38,6 @@ } CID_AFM; -#if 1 - LOCAL_DEF FT_Error CID_Read_AFM( FT_Face cid_face, FT_Stream stream ); @@ -54,8 +52,6 @@ FT_UInt glyph2, FT_Vector* kerning ); -#endif /* 1 */ - #endif /* CIDAFM_H */ diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index 994508234..3a38545e1 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -76,7 +76,8 @@ } CID_Operator; - static const FT_Int t1_args_count[op_max] = + static + const FT_Int t1_args_count[op_max] = { 0, /* none */ 0, /* endchar */ @@ -220,7 +221,7 @@ /* decoder :: A pointer to the glyph builder to initialize. */ /* */ LOCAL_FUNC - void CID_Init_Decoder( CID_Decoder* decoder ) + void CID_Init_Decoder( CID_Decoder* decoder ) { MEM_Set( decoder, 0, sizeof ( *decoder ) ); @@ -229,7 +230,7 @@ } - /* check that there is enough room for `count' more points */ + /* check that there is enough space for `count' more points */ static FT_Error check_points( CID_Builder* builder, FT_Int count ) @@ -238,7 +239,7 @@ } - /* add a new point, do not check space */ + /* add a new point, but do not check space */ static void add_point( CID_Builder* builder, FT_Pos x, @@ -265,7 +266,7 @@ } - /* check room for a new on-curve point, then add it */ + /* check space for a new on-curve point, then add it */ static FT_Error add_point1( CID_Builder* builder, FT_Pos x, @@ -273,6 +274,7 @@ { FT_Error error; + error = check_points( builder, 1 ); if ( !error ) add_point( builder, x, y, 1 ); @@ -307,7 +309,7 @@ } - /* if a path was begun, add its first on-curve point */ + /* if a path has been started, add its first on-curve point */ static FT_Error start_point( CID_Builder* builder, FT_Pos x, @@ -335,8 +337,9 @@ { FT_Outline* outline = builder->current; - /* XXXX: We must not include the last point in the path if it */ - /* is located on the first point. */ + + /* XXX: We must not include the last point in the path if it */ + /* is located on the first point. */ if ( outline->n_points > 1 ) { FT_Int first = 0; @@ -456,7 +459,8 @@ if ( bchar_index < 0 || achar_index < 0 ) { - FT_ERROR(( "t1operator_seac: invalid seac character code arguments\n" )); + FT_ERROR(( "t1operator_seac: )); + FT_ERROR(( " invalid seac character code arguments\n" )); return T1_Err_Syntax_Error; } @@ -542,14 +546,18 @@ FT_Outline_Translate( &dummy, adx - asb, ady ); } } + Exit: return error; } -#define USE_ARGS( n ) top -= n; \ - if ( top < decoder->stack ) \ - goto Stack_Underflow +#define USE_ARGS( n ) do \ + { \ + top -= n; \ + if ( top < decoder->stack ) \ + goto Stack_Underflow; \ + } while ( 0 ) /*************************************************************************/ @@ -561,12 +569,12 @@ /* Parses a given CID charstrings program. */ /* */ /* */ - /* decoder :: The current CID decoder. */ + /* decoder :: The current CID decoder. */ /* */ /* */ - /* charstring_base :: The base of the charstring stream. */ + /* charstring_base :: The base of the charstring stream. */ /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ + /* charstring_len :: The length in bytes of the charstring stream. */ /* */ /* */ /* FreeType error code. 0 means success. */ @@ -738,7 +746,8 @@ { if ( ++ip > limit ) { - FT_ERROR(( "CID_Parse_CharStrings: unexpected EOF in integer\n" )); + FT_ERROR(( "CID_Parse_CharStrings:" )); + FT_ERROR(( " unexpected EOF in integer\n" )); goto Syntax_Error; } @@ -775,6 +784,7 @@ else if ( op == op_callothersubr ) /* callothersubr */ { FT_TRACE4(( " callothersubr" )); + if ( top - decoder->stack < 2 ) goto Stack_Underflow; @@ -819,7 +829,7 @@ if ( decoder->flex_state == 0 || decoder->num_flex_vectors != 7 ) { - FT_ERROR(( "CID)Parse_CharStrings: unexpected flex end\n" )); + FT_ERROR(( "CID_Parse_CharStrings: unexpected flex end\n" )); goto Syntax_Error; } @@ -851,7 +861,8 @@ if ( ip[0] != 12 || ip[1] != 17 ) { - FT_ERROR(( "CID_Parse_CharStrings: `pop' expected, found (%d %d)\n", + FT_ERROR(( "CID_Parse_CharStrings:" )); + FT_ERROR(( " `pop' expected, found (%d %d)\n", ip[0], ip[1] )); goto Syntax_Error; } @@ -877,16 +888,19 @@ FT_Int* delta; FT_Int* values; + if ( !blend ) { - FT_ERROR(( "CID_Parse_CharStrings: unexpected multiple masters operator!\n" )); + FT_ERROR(( "CID_Parse_CharStrings:" )); + FT_ERROR(( " unexpected multiple masters operator!\n" )); goto Syntax_Error; } num_points = top[1] - 13 + ( top[1] == 18 ); if ( top[0] != num_points * blend->num_designs ) { - FT_ERROR(( "CID_Parse_CharStrings: incorrect number of mm arguments\n" )); + FT_ERROR(( "CID_Parse_CharStrings:" )); + FT_ERROR(( " incorrect number of mm arguments\n" )); goto Syntax_Error; } @@ -894,12 +908,12 @@ if ( top < decoder->stack ) goto Stack_Underflow; - /* we want to compute: */ + /* We want to compute: */ /* */ /* a0*w0 + a1*w1 + ... + ak*wk */ /* */ - /* but we only have the a0, a1-a0, a2-a0, .. ak-a0 */ - /* however, given that w0 + w1 + ... + wk == 1, we can */ + /* but we only have the a0, a1-a0, a2-a0, .. ak-a0. */ + /* However, given that w0 + w1 + ... + wk == 1, we can */ /* rewrite it easily as: */ /* */ /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */ @@ -909,7 +923,6 @@ /* I guess that's why it's written in this `compact' */ /* form... */ /* */ - /* */ delta = top + num_points; values = top; for ( nn = 0; nn < num_points; nn++ ) @@ -970,7 +983,7 @@ builder->last.x = x = top[0]; builder->last.y = y = 0; - /* the `metrics_only' indicates that we only want to compute */ + /* The `metrics_only' indicates that we only want to compute */ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it. So exit immediately. */ if ( builder->metrics_only ) @@ -979,7 +992,7 @@ break; case op_seac: - /* return immediately after the processing */ + /* return immediately after processing */ return t1operator_seac( decoder, top[0], top[1], top[2], top[3], top[4] ); @@ -994,7 +1007,7 @@ builder->last.x = x = top[0]; builder->last.y = y = top[1]; - /* the `metrics_only' indicates that we only want to compute */ + /* The `metrics_only' indicates that we only want to compute */ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it. So exit immediately. */ if ( builder->metrics_only ) @@ -1087,6 +1100,7 @@ case op_vhcurveto: FT_TRACE4(( " vhcurveto" )); + if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Memory_Error; @@ -1175,7 +1189,7 @@ case op_pop: FT_TRACE4(( " pop" )); - /* theorically, the arguments are already on the stack */ + /* theoretically, the arguments are already on the stack */ top++; break; @@ -1223,7 +1237,8 @@ case op_setcurrentpoint: FT_TRACE4(( " setcurrentpoint" )); - FT_ERROR(( "CID_Parse_CharStrings: unexpected `setcurrentpoint'\n" )); + FT_ERROR(( "CID_Parse_CharStrings:" )); + FT_ERROR(( " unexpected `setcurrentpoint'\n" )); goto Syntax_Error; default: @@ -1252,6 +1267,9 @@ } +#if 0 + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -1270,9 +1288,6 @@ /*************************************************************************/ -#if 0 - - LOCAL_FUNC FT_Error CID_Compute_Max_Advance( CID_Face face, FT_Int* max_advance ) @@ -1291,14 +1306,14 @@ decoder.builder.metrics_only = 1; decoder.builder.load_points = 0; - /* For each glyph, parse the glyph charstring and extract */ - /* the advance width. */ + /* for each glyph, parse the glyph charstring and extract */ + /* the advance width */ for ( glyph_index = 0; glyph_index < face->root.num_glyphs; glyph_index++ ) { /* now get load the unscaled outline */ error = cid_load_glyph( &decoder, glyph_index ); - /* ignore the error if one occured - skip to next glyph */ + /* ignore the error if one occurred - skip to next glyph */ } *max_advance = decoder.builder.advance.x; @@ -1395,7 +1410,6 @@ } - LOCAL_FUNC FT_Error CID_Load_Glyph( CID_GlyphSlot glyph, CID_Size size, @@ -1442,7 +1456,7 @@ if ( !error ) { /* for composite glyphs, return only the left side bearing and the */ - /* advance width.. */ + /* advance width */ if ( load_flags & FT_LOAD_NO_RECURSE ) { glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; @@ -1455,7 +1469,7 @@ /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.builder.advance.x; + metrics->horiAdvance = decoder.builder.advance.x; /* make up vertical metrics */ metrics->vertBearingX = 0; @@ -1497,10 +1511,10 @@ /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); + metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale ); } /* apply the font matrix */ @@ -1514,8 +1528,8 @@ { cbox.xMin &= -64; cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; + cbox.xMax = ( cbox.xMax + 63 ) & -64; + cbox.yMax = ( cbox.yMax + 63 ) & -64; } metrics->width = cbox.xMax - cbox.xMin; diff --git a/src/cid/cidload.c b/src/cid/cidload.c index 1a0b53880..c66496d3f 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -38,7 +38,7 @@ #define FT_COMPONENT trace_cidload - /* read a single offset */ + /* read a single offset */ LOCAL_FUNC FT_Long cid_get_offset( FT_Byte** start, FT_Byte offsize ) @@ -48,7 +48,10 @@ for ( result = 0; offsize > 0; offsize-- ) - result = ( result << 8 ) | *p++; + { + result <<= 8; + result |= *p++; + } *start = p; return result; @@ -87,10 +90,10 @@ CID_Loader* loader, const CID_Field_Rec* keyword ) { - FT_Error error; - CID_Parser* parser = &loader->parser; - FT_Byte* object; - CID_Info* cid = &face->cid; + FT_Error error; + CID_Parser* parser = &loader->parser; + FT_Byte* object; + CID_Info* cid = &face->cid; /* if the keyword has a dedicated callback, call it */ @@ -309,7 +312,7 @@ len = cur2 - cur; if ( len > 0 && len < 22 ) { - /* now, compare the immediate name to the keyword table */ + /* now compare the immediate name to the keyword table */ const CID_Field_Rec* keyword = t1_field_records; @@ -408,8 +411,8 @@ /* allocate, and read them */ data_len = offsets[num_subrs] - offsets[0]; - if ( ALLOC_ARRAY( subr->code, num_subrs+1, FT_Byte* ) || - ALLOC( subr->code[0], data_len ) ) + if ( ALLOC_ARRAY( subr->code, num_subrs + 1, FT_Byte* ) || + ALLOC( subr->code[0], data_len ) ) goto Fail; if ( FILE_Seek( cid->data_offset + offsets[0] ) || @@ -463,7 +466,7 @@ void t1_init_loader( CID_Loader* loader, CID_Face face ) { - UNUSED(face); + UNUSED( face ); MEM_Set( loader, 0, sizeof ( *loader ) ); } diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index 21490b42a..5b0af145d 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -177,10 +177,10 @@ if ( face->cid.font_info.is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; - /* XXX: TO DO - add kerning with .afm support */ + /* XXX: TODO: add kerning with .afm support */ - /* get style name - be careful, some broken fonts only */ - /* have a /FontName dictionary entry! */ + /* get style name -- be careful, some broken fonts only */ + /* have a /FontName dictionary entry! */ root->family_name = face->cid.font_info.family_name; if ( root->family_name ) { @@ -259,7 +259,7 @@ FT_CharMap charmap = face->charmaprecs; - /* synthesize a Unicode charmap if there is support in the "psnames" */ + /* synthesize a Unicode charmap if there is support in the `psnames' */ /* module */ if ( face->psnames ) { diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h index aec06c864..c28c59be2 100644 --- a/src/cid/cidobjs.h +++ b/src/cid/cidobjs.h @@ -86,20 +86,20 @@ /*************************************************************************/ /* */ - /* HERE BEGINS THE TYPE1 SPECIFIC STUFF */ + /* HERE BEGINS THE TYPE 1 SPECIFIC STUFF */ /* */ /*************************************************************************/ - typedef struct CID_SizeRec_ + typedef struct CID_SizeRec_ { - FT_SizeRec root; - FT_Bool valid; + FT_SizeRec root; + FT_Bool valid; } CID_SizeRec; - typedef struct CID_GlyphSlotRec_ + typedef struct CID_GlyphSlotRec_ { FT_GlyphSlotRec root; @@ -113,11 +113,11 @@ LOCAL_DEF - FT_Error CID_Init_Face( FT_Stream stream, - CID_Face face, - FT_Int face_index, - FT_Int num_params, - FT_Parameter* params ); + FT_Error CID_Init_Face( FT_Stream stream, + CID_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ); LOCAL_DEF void CID_Done_Face( CID_Face face ); diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index d4ec6bcd9..279d4b967 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -354,7 +354,7 @@ } break; - /* **************** otherwise, it's any token **********/ + /* **************** otherwise, it is any token **********/ default: token->start = cur++; token->type = t1_token_any; @@ -504,7 +504,8 @@ for (;;) { d = (FT_Byte)( *cur - '0' ); - if ( d >= 10 ) break; + if ( d >= 10 ) + break; if ( divider < 10000000L ) { @@ -706,7 +707,6 @@ } - /* Loads a simple field (i.e. non-table) into the current */ /* list of objects */ LOCAL_FUNC @@ -761,6 +761,12 @@ *(FT_UShort*)q = (FT_UShort)val; break; +#if SIZEOF_INT == 4 + case 4: + *(FT_Int*)q = (FT_Int)val; + break; +#endif + default: *(FT_Long*)q = val; } @@ -783,7 +789,7 @@ break; default: - /* an error occured */ + /* an error occurred */ goto Fail; } } @@ -958,12 +964,12 @@ buff_len = 256 + 10; - /* look for "StartData" */ + /* look for `StartData' */ for ( p = buffer; p < limit; p++ ) { if ( p[0] == 'S' && strncmp( (char*)p, "StartData", 9 ) == 0 ) { - /* save offset of binary data after "StartData" */ + /* save offset of binary data after `StartData' */ offset = FILE_Pos() - ( limit - p ) + 10; goto Found; } @@ -971,7 +977,7 @@ } Found: - /* all right, we found the start of the binary data. We will now */ + /* we have found the start of the binary data. We will now */ /* rewind and extract the frame of corresponding to the Postscript */ /* section */ diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index d27e8f20c..aa728a55b 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -1783,11 +1783,12 @@ metrics->horiBearingX = FT_MulFix( metrics->horiBearingX, x_scale ); metrics->horiBearingY = FT_MulFix( metrics->horiBearingY, y_scale ); - metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale ); + + metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); + metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); } } } diff --git a/src/type1z/z1gload.c b/src/type1z/z1gload.c index 25c126441..44d7d2ba1 100644 --- a/src/type1z/z1gload.c +++ b/src/type1z/z1gload.c @@ -1368,10 +1368,10 @@ /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); + metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale ); } /* apply the font matrix */