From f6294399056077c92367301623c093db285dadbf Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 6 Jan 2007 07:47:45 +0000 Subject: [PATCH] formatting, copyright years --- ChangeLog | 69 +++++++++++++++++++++++++++++++----------- src/cff/cffgload.c | 22 ++++++++------ src/cff/cffload.c | 47 +++++++++++++++++----------- src/cff/cffload.h | 3 +- src/cff/cfftypes.h | 10 +++--- src/pfr/pfrobjs.c | 9 +++--- src/sfnt/ttcmap.c | 2 +- src/sfnt/ttmtx.c | 17 ++++++----- src/truetype/ttgload.c | 2 +- src/truetype/ttobjs.c | 27 +++++++++-------- src/truetype/ttobjs.h | 2 +- 11 files changed, 131 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6d20cd30..087d5dc9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,26 +1,61 @@ 2007-01-04 David Turner - * src/pfr/pfrobjs.c (pfr_face_init): detect non-scalable fonts - correctly. fixes bug #17876 + * src/pfr/pfrobjs.c (pfr_face_init): Detect non-scalable fonts + correctly. This fixes Savannah bug #17876. - * src/truetype/ttobjs.h, src/truetype/ttobjs.c, - src/truetype/ttgload.c: do not allocate interpreter-specific - tables in memory if we're not going to load glyphs with it - anyway. + + Do not allocate interpreter-specific tables in memory if we are not + going to load glyphs with the bytecode interpreter anyway. + + * src/truetype/ttgload.c (tt_loader_init): Load execution context + only if glyph is hinted. + Updated. + * src/truetype/ttobjs.h (TT_SizeRec): Add members `bytecode_ready' + and `cvs_ready'. + Add `tt_size_ready_bytecode' declaration. + * src/truetype/ttobjs.c (tt_size_done_bytecode, + tt_size_init_bytecode, tt_size_ready_bytecode): New functions. + (tt_size_init): Move most code into `tt_size_init_bytecode'. + (tt_size_done): Move most code into `tt_size_done_bytecode'. + (tt_size_reset): Move some code to `tt_size_ready_bytecode'. - * src/sfnt/ttmtx.c, include/freetype/internal/tttypes.h: - don't extract the metrics table from the SFNT font file. - Instead, reparse it on each glyph load, since the runtime - difference will not be noticeable, and it can save a lot - of heap memory when memory-mapped files are not used. - * src/sfnt/ttcmap.c: slight optimization in the CMAP 4 validator + Don't extract the metrics table from the SFNT font file. Instead, + reparse it on each glyph load. The runtime difference is not + noticeable, and it can save a lot of heap memory when memory-mapped + files are not used. - * src/cff/cffload.c, src/cff/cffload.h, src/cff/cffgload.c, - src/cff/cfftypes.h: formatting + do not load the CFF index - offsets into memory, since this wastes a *lot* of heap memory - with large Asian CFF fonts. There is no significant performance - loss + * include/freetype/internal/tttypes.h (TT_FaceRec): Add members + `horz_metrics_offset' and `vert_metrics_ofset'. + * src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): + Updated. + + + * src/sfnt/ttcmap.c (tt_cmap4_validate): Slight optimization. + + + Do not load the CFF index offsets into memory, since this wastes a + *lot* of heap memory with large Asian CFF fonts. There is no + significant performance loss. + + * src/cff/cffload.h: Add `cff_charset_cid_to_gindex' declaration. + * src/cff/cfftypes.h (CFF_IndexRec): Add fields `start' and + `data_size'. + (CFF_CharsetRec): Add field `num_glyphs'. + + * src/cff/cffload.c (cff_index_read_offset, cff_index_load_offsets, + cff_charset_cid_to_gindex): New functions. + (cff_new_index): Renamed to... + (cff_index_init): This. Update all callers. + Updated -- some code has been moved to `cff_index_load_offsets'. + (cff_done_index): Renamed to... + (cff_index_done): This. Update all callers. + (cff_index_get_pointers, cff_index_access_element): Updated to use + stream offsets. + (cff_charset_compute_cids): Set `num_glyphs' field. + (cff_encoding_load): Updated. + + * src/cff/cffgload.c (cff_slot_load): Updated. 2007-01-04 David Turner diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index c031e033c..5c5ae6159 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -2275,14 +2275,14 @@ FT_UInt glyph_index, FT_Int32 load_flags ) { - FT_Error error; - CFF_Decoder decoder; - TT_Face face = (TT_Face)glyph->root.face; - FT_Bool hinting; - CFF_Font cff = (CFF_Font)face->extra.data; + FT_Error error; + CFF_Decoder decoder; + TT_Face face = (TT_Face)glyph->root.face; + FT_Bool hinting; + CFF_Font cff = (CFF_Font)face->extra.data; - FT_Matrix font_matrix; - FT_Vector font_offset; + FT_Matrix font_matrix; + FT_Vector font_offset; /* in a CID-keyed font, consider `glyph_index' as a CID and map */ @@ -2424,9 +2424,11 @@ { CFF_Index csindex = &cff->charstrings_index; - if (csindex->offsets) + + if ( csindex->offsets ) { - glyph->root.control_data = csindex->bytes + csindex->offsets[glyph_index] - 1; + glyph->root.control_data = csindex->bytes + + csindex->offsets[glyph_index] - 1; glyph->root.control_len = charstring_len; } } diff --git a/src/cff/cffload.c b/src/cff/cffload.c index 988eed09d..cbd4fc331 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -4,7 +4,7 @@ /* */ /* OpenType and CFF data/program tables loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -193,6 +193,7 @@ #undef FT_COMPONENT #define FT_COMPONENT trace_cffload + /* read an offset from the index's stream current position */ static FT_ULong cff_index_read_offset( CFF_Index idx, @@ -203,12 +204,14 @@ FT_Byte tmp[4]; FT_ULong result = 0; + if ( !FT_STREAM_READ( tmp, idx->off_size ) ) { FT_Int nn; + for ( nn = 0; nn < idx->off_size; nn++ ) - result = (result << 8) | tmp[nn]; + result = ( result << 8 ) | tmp[nn]; } *perror = error; @@ -233,8 +236,8 @@ if ( !FT_READ_USHORT( count ) && count > 0 ) { - FT_Byte offsize; - FT_ULong size, last_offset; + FT_Byte offsize; + FT_ULong size, last_offset; /* there is at least one element; read the offset size, */ @@ -258,7 +261,7 @@ goto Exit; size = cff_index_read_offset( idx, &error ); - if (error) + if ( error ) goto Exit; if ( size == 0 ) @@ -316,6 +319,7 @@ FT_Stream stream = idx->stream; FT_Memory memory = stream->memory; + if ( idx->count > 0 && idx->offsets == NULL ) { FT_Byte offsize = idx->off_size; @@ -324,11 +328,12 @@ FT_Byte* p_end; FT_ULong* poff; - data_size = (FT_ULong)( idx->count + 1 ) * offsize; + + data_size = (FT_ULong)( idx->count + 1 ) * offsize; if ( FT_NEW_ARRAY( idx->offsets, idx->count + 1 ) || - FT_STREAM_SEEK( idx->start + 3 ) || - FT_FRAME_ENTER( data_size ) ) + FT_STREAM_SEEK( idx->start + 3 ) || + FT_FRAME_ENTER( data_size ) ) goto Exit; poff = idx->offsets; @@ -361,15 +366,13 @@ } Exit: - if (error) + if ( error ) FT_FREE( idx->offsets ); return error; } - - /* allocate a table containing pointers to an index's elements */ static FT_Error cff_index_get_pointers( CFF_Index idx, @@ -400,7 +403,7 @@ offset = old_offset; /* sanity check for invalid offset tables */ - else if ( offset < old_offset || offset-1 >= idx->data_size ) + else if ( offset < old_offset || offset - 1 >= idx->data_size ) offset = old_offset; t[n] = idx->bytes + offset - 1; @@ -434,13 +437,15 @@ /* load offsets from file or the offset table */ if ( !idx->offsets ) { - FT_ULong pos = element*idx->off_size; + FT_ULong pos = element * idx->off_size; + if ( FT_STREAM_SEEK( idx->start + 3 + pos ) ) goto Exit; off1 = cff_index_read_offset( idx, &error ); - if (error) goto Exit; + if ( error ) + goto Exit; if ( off1 != 0 ) { @@ -760,12 +765,14 @@ { FT_UInt result = 0; + if ( cid < charset->max_cid ) result = charset->cids[cid]; return result; } + static void cff_charset_free_cids( CFF_Charset charset, FT_Memory memory ) @@ -1393,10 +1400,14 @@ goto Exit; /* read the name, top dict, string and global subrs index */ - if ( FT_SET_ERROR( cff_index_init( &font->name_index, stream, 0 )) || - FT_SET_ERROR( cff_index_init( &font->font_dict_index, stream, 0 )) || - FT_SET_ERROR( cff_index_init( &font->string_index, stream, 0 )) || - FT_SET_ERROR( cff_index_init( &font->global_subrs_index, stream, 1 )) ) + if ( FT_SET_ERROR( cff_index_init( &font->name_index, + stream, 0 ) ) || + FT_SET_ERROR( cff_index_init( &font->font_dict_index, + stream, 0 ) ) || + FT_SET_ERROR( cff_index_init( &font->string_index, + stream, 0 ) ) || + FT_SET_ERROR( cff_index_init( &font->global_subrs_index, + stream, 1 ) ) ) goto Exit; /* well, we don't really forget the `disabled' fonts... */ diff --git a/src/cff/cffload.h b/src/cff/cffload.h index 13ee09ddb..068cbb58c 100644 --- a/src/cff/cffload.h +++ b/src/cff/cffload.h @@ -4,7 +4,7 @@ /* */ /* OpenType & CFF data/program tables loader (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2001, 2002, 2003, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -56,6 +56,7 @@ FT_BEGIN_HEADER cff_charset_cid_to_gindex( CFF_Charset charset, FT_UInt cid ); + FT_LOCAL( FT_Error ) cff_font_load( FT_Stream stream, FT_Int face_index, diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h index 07edfbd5a..96301d633 100644 --- a/src/cff/cfftypes.h +++ b/src/cff/cfftypes.h @@ -5,7 +5,7 @@ /* Basic OpenType/CFF type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -40,7 +40,7 @@ FT_BEGIN_HEADER /* stream :: The source input stream. */ /* */ /* start :: The position of the first index byte in the */ - /* input stream */ + /* input stream. */ /* */ /* count :: The number of elements in the index. */ /* */ @@ -49,10 +49,10 @@ FT_BEGIN_HEADER /* data_offset :: The position of first data byte in the index's */ /* bytes. */ /* */ - /* data_size :: size of data table in this index */ + /* data_size :: The size of the data table in this index. */ /* */ - /* offsets :: A table of element offsets in the index. must be */ - /* loaded explicitely */ + /* offsets :: A table of element offsets in the index. Must be */ + /* loaded explicitly. */ /* */ /* bytes :: If the index is loaded in memory, its bytes. */ /* */ diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c index 976ab4af4..180446d73 100644 --- a/src/pfr/pfrobjs.c +++ b/src/pfr/pfrobjs.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -122,7 +122,7 @@ if ( error ) goto Exit; - /* now, set-up all root face fields */ + /* now set up all root face fields */ { PFR_PhyFont phy_font = &face->phy_font; @@ -132,16 +132,17 @@ pfrface->face_flags = FT_FACE_FLAG_SCALABLE; /* if all characters point to the same gps_offset 0, we */ - /* assume the font only contains bitmaps */ + /* assume that the font only contains bitmaps */ { FT_UInt nn; + for ( nn = 0; nn < phy_font->num_chars; nn++ ) if ( phy_font->chars[nn].gps_offset != 0 ) break; if ( nn == phy_font->num_chars ) - pfrface->face_flags = 0; /* not SCALABLE !! */ + pfrface->face_flags = 0; /* not scalable */ } if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 ) diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index 424716bfe..20e8f3a0b 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c index e3eff2965..46e93329a 100644 --- a/src/sfnt/ttmtx.c +++ b/src/sfnt/ttmtx.c @@ -72,6 +72,7 @@ FT_ULong* ptable_offset; FT_ULong* ptable_size; + if ( vertical ) { tag = TTAG_vmtx; @@ -86,7 +87,7 @@ } error = face->goto_table( face, tag, stream, &table_size ); - if (error) + if ( error ) goto Fail; *ptable_size = table_size; @@ -366,27 +367,27 @@ { if ( gindex < (FT_UInt)k ) { - table_pos += 4*gindex; - if ( table_pos+6 > table_end ) + table_pos += 4 * gindex; + if ( table_pos + 6 > table_end ) goto NoData; if ( FT_STREAM_SEEK( table_pos ) || FT_READ_USHORT( *aadvance) || - FT_READ_SHORT( *abearing ) ) + FT_READ_SHORT( *abearing ) ) goto NoData; } else { - table_pos += 4*(k-1); - if ( table_pos+4 > table_end ) + table_pos += 4 * ( k - 1 ); + if ( table_pos + 4 > table_end ) goto NoData; if ( FT_STREAM_SEEK( table_pos ) || FT_READ_USHORT( *aadvance ) ) goto NoData; - table_pos += 4 + 2*(gindex - k); - if ( table_pos+2 > table_end ) + table_pos += 4 + 2 * ( gindex - k ); + if ( table_pos + 2 > table_end ) *abearing = 0; else { diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index a04f914cf..c595487f0 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index 908194e26..dbd2bda2d 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -4,7 +4,7 @@ /* */ /* Objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -524,10 +524,11 @@ static void tt_size_done_bytecode( FT_Size ftsize ) { - TT_Size size = (TT_Size)ftsize; - TT_Face face = (TT_Face)ftsize->face; + TT_Size size = (TT_Size)ftsize; + TT_Face face = (TT_Face)ftsize->face; FT_Memory memory = face->root.memory; + if ( size->debug ) { /* the debug context must be deleted by the debugger itself */ @@ -561,10 +562,8 @@ } - /* initialize bytecode-related fields in the size object, - * should only be needed when bytecode interpretation is - * really needed - */ + /* Initialize bytecode-related fields in the size object. */ + /* We do this only if bytecode interpretation is really needed. */ static FT_Error tt_size_init_bytecode( FT_Size ftsize ) { @@ -646,7 +645,7 @@ error = tt_size_run_fpgm( size ); Exit: - if (error) + if ( error ) tt_size_done_bytecode( ftsize ); return error; @@ -656,7 +655,8 @@ FT_LOCAL_DEF( FT_Error ) tt_size_ready_bytecode( TT_Size size ) { - FT_Error error = 0; + FT_Error error = TT_Err_Ok; + if ( !size->bytecode_ready ) { @@ -677,7 +677,7 @@ for ( i = 0; i < size->cvt_size; i++ ) size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); - /* All twilight points are originally zero */ + /* all twilight points are originally zero */ for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) { size->twilight.org[i].x = 0; @@ -703,13 +703,13 @@ FT_LOCAL_DEF( FT_Error ) tt_size_ready_bytecode( TT_Size size ) { - FT_UNUSED(ftsize); + FT_UNUSED( ftsize ); return 0; } - #endif /* !TT_USE_BYTECODE_INTERPRETER */ + /*************************************************************************/ /* */ /* */ @@ -756,7 +756,8 @@ FT_LOCAL_DEF( void ) tt_size_done( FT_Size ttsize ) /* TT_Size */ { - TT_Size size = (TT_Size)ttsize; + TT_Size size = (TT_Size)ttsize; + #ifdef TT_USE_BYTECODE_INTERPRETER if ( size->bytecode_ready ) diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h index f81328fb2..652ead33e 100644 --- a/src/truetype/ttobjs.h +++ b/src/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */