formatting, copyright years

This commit is contained in:
Werner Lemberg 2007-01-06 07:47:45 +00:00
parent d88a0c9e64
commit f629439905
11 changed files with 131 additions and 79 deletions

View File

@ -1,26 +1,61 @@
2007-01-04 David Turner <david@freetype.org> 2007-01-04 David Turner <david@freetype.org>
* src/pfr/pfrobjs.c (pfr_face_init): detect non-scalable fonts * src/pfr/pfrobjs.c (pfr_face_init): Detect non-scalable fonts
correctly. fixes bug #17876 correctly. This fixes Savannah bug #17876.
* src/truetype/ttobjs.h, src/truetype/ttobjs.c,
src/truetype/ttgload.c: do not allocate interpreter-specific Do not allocate interpreter-specific tables in memory if we are not
tables in memory if we're not going to load glyphs with it going to load glyphs with the bytecode interpreter anyway.
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, * include/freetype/internal/tttypes.h (TT_FaceRec): Add members
src/cff/cfftypes.h: formatting + do not load the CFF index `horz_metrics_offset' and `vert_metrics_ofset'.
offsets into memory, since this wastes a *lot* of heap memory * src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics):
with large Asian CFF fonts. There is no significant performance Updated.
loss
* 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 <david@freetype.org> 2007-01-04 David Turner <david@freetype.org>

View File

@ -4,7 +4,7 @@
/* */ /* */
/* OpenType Glyph Loader (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -2275,14 +2275,14 @@
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int32 load_flags ) FT_Int32 load_flags )
{ {
FT_Error error; FT_Error error;
CFF_Decoder decoder; CFF_Decoder decoder;
TT_Face face = (TT_Face)glyph->root.face; TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting; FT_Bool hinting;
CFF_Font cff = (CFF_Font)face->extra.data; CFF_Font cff = (CFF_Font)face->extra.data;
FT_Matrix font_matrix; FT_Matrix font_matrix;
FT_Vector font_offset; FT_Vector font_offset;
/* in a CID-keyed font, consider `glyph_index' as a CID and map */ /* in a CID-keyed font, consider `glyph_index' as a CID and map */
@ -2424,9 +2424,11 @@
{ {
CFF_Index csindex = &cff->charstrings_index; 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; glyph->root.control_len = charstring_len;
} }
} }

View File

@ -4,7 +4,7 @@
/* */ /* */
/* OpenType and CFF data/program tables loader (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -193,6 +193,7 @@
#undef FT_COMPONENT #undef FT_COMPONENT
#define FT_COMPONENT trace_cffload #define FT_COMPONENT trace_cffload
/* read an offset from the index's stream current position */ /* read an offset from the index's stream current position */
static FT_ULong static FT_ULong
cff_index_read_offset( CFF_Index idx, cff_index_read_offset( CFF_Index idx,
@ -203,12 +204,14 @@
FT_Byte tmp[4]; FT_Byte tmp[4];
FT_ULong result = 0; FT_ULong result = 0;
if ( !FT_STREAM_READ( tmp, idx->off_size ) ) if ( !FT_STREAM_READ( tmp, idx->off_size ) )
{ {
FT_Int nn; FT_Int nn;
for ( nn = 0; nn < idx->off_size; nn++ ) for ( nn = 0; nn < idx->off_size; nn++ )
result = (result << 8) | tmp[nn]; result = ( result << 8 ) | tmp[nn];
} }
*perror = error; *perror = error;
@ -233,8 +236,8 @@
if ( !FT_READ_USHORT( count ) && if ( !FT_READ_USHORT( count ) &&
count > 0 ) count > 0 )
{ {
FT_Byte offsize; FT_Byte offsize;
FT_ULong size, last_offset; FT_ULong size, last_offset;
/* there is at least one element; read the offset size, */ /* there is at least one element; read the offset size, */
@ -258,7 +261,7 @@
goto Exit; goto Exit;
size = cff_index_read_offset( idx, &error ); size = cff_index_read_offset( idx, &error );
if (error) if ( error )
goto Exit; goto Exit;
if ( size == 0 ) if ( size == 0 )
@ -316,6 +319,7 @@
FT_Stream stream = idx->stream; FT_Stream stream = idx->stream;
FT_Memory memory = stream->memory; FT_Memory memory = stream->memory;
if ( idx->count > 0 && idx->offsets == NULL ) if ( idx->count > 0 && idx->offsets == NULL )
{ {
FT_Byte offsize = idx->off_size; FT_Byte offsize = idx->off_size;
@ -324,11 +328,12 @@
FT_Byte* p_end; FT_Byte* p_end;
FT_ULong* poff; 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 ) || if ( FT_NEW_ARRAY( idx->offsets, idx->count + 1 ) ||
FT_STREAM_SEEK( idx->start + 3 ) || FT_STREAM_SEEK( idx->start + 3 ) ||
FT_FRAME_ENTER( data_size ) ) FT_FRAME_ENTER( data_size ) )
goto Exit; goto Exit;
poff = idx->offsets; poff = idx->offsets;
@ -361,15 +366,13 @@
} }
Exit: Exit:
if (error) if ( error )
FT_FREE( idx->offsets ); FT_FREE( idx->offsets );
return error; return error;
} }
/* allocate a table containing pointers to an index's elements */ /* allocate a table containing pointers to an index's elements */
static FT_Error static FT_Error
cff_index_get_pointers( CFF_Index idx, cff_index_get_pointers( CFF_Index idx,
@ -400,7 +403,7 @@
offset = old_offset; offset = old_offset;
/* sanity check for invalid offset tables */ /* 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; offset = old_offset;
t[n] = idx->bytes + offset - 1; t[n] = idx->bytes + offset - 1;
@ -434,13 +437,15 @@
/* load offsets from file or the offset table */ /* load offsets from file or the offset table */
if ( !idx->offsets ) 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 ) ) if ( FT_STREAM_SEEK( idx->start + 3 + pos ) )
goto Exit; goto Exit;
off1 = cff_index_read_offset( idx, &error ); off1 = cff_index_read_offset( idx, &error );
if (error) goto Exit; if ( error )
goto Exit;
if ( off1 != 0 ) if ( off1 != 0 )
{ {
@ -760,12 +765,14 @@
{ {
FT_UInt result = 0; FT_UInt result = 0;
if ( cid < charset->max_cid ) if ( cid < charset->max_cid )
result = charset->cids[cid]; result = charset->cids[cid];
return result; return result;
} }
static void static void
cff_charset_free_cids( CFF_Charset charset, cff_charset_free_cids( CFF_Charset charset,
FT_Memory memory ) FT_Memory memory )
@ -1393,10 +1400,14 @@
goto Exit; goto Exit;
/* read the name, top dict, string and global subrs index */ /* read the name, top dict, string and global subrs index */
if ( FT_SET_ERROR( cff_index_init( &font->name_index, stream, 0 )) || if ( FT_SET_ERROR( cff_index_init( &font->name_index,
FT_SET_ERROR( cff_index_init( &font->font_dict_index, stream, 0 )) || stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &font->string_index, stream, 0 )) || FT_SET_ERROR( cff_index_init( &font->font_dict_index,
FT_SET_ERROR( cff_index_init( &font->global_subrs_index, stream, 1 )) ) 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; goto Exit;
/* well, we don't really forget the `disabled' fonts... */ /* well, we don't really forget the `disabled' fonts... */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* OpenType & CFF data/program tables loader (specification). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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, cff_charset_cid_to_gindex( CFF_Charset charset,
FT_UInt cid ); FT_UInt cid );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
cff_font_load( FT_Stream stream, cff_font_load( FT_Stream stream,
FT_Int face_index, FT_Int face_index,

View File

@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */ /* Basic OpenType/CFF type definitions and interface (specification */
/* only). */ /* only). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2006 by */ /* Copyright 1996-2001, 2002, 2003, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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. */ /* stream :: The source input stream. */
/* */ /* */
/* start :: The position of the first index byte in the */ /* start :: The position of the first index byte in the */
/* input stream */ /* input stream. */
/* */ /* */
/* count :: The number of elements in the index. */ /* 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 */ /* data_offset :: The position of first data byte in the index's */
/* bytes. */ /* 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 */ /* offsets :: A table of element offsets in the index. Must be */
/* loaded explicitely */ /* loaded explicitly. */
/* */ /* */
/* bytes :: If the index is loaded in memory, its bytes. */ /* bytes :: If the index is loaded in memory, its bytes. */
/* */ /* */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType PFR object methods (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -122,7 +122,7 @@
if ( error ) if ( error )
goto Exit; goto Exit;
/* now, set-up all root face fields */ /* now set up all root face fields */
{ {
PFR_PhyFont phy_font = &face->phy_font; PFR_PhyFont phy_font = &face->phy_font;
@ -132,16 +132,17 @@
pfrface->face_flags = FT_FACE_FLAG_SCALABLE; pfrface->face_flags = FT_FACE_FLAG_SCALABLE;
/* if all characters point to the same gps_offset 0, we */ /* 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; FT_UInt nn;
for ( nn = 0; nn < phy_font->num_chars; nn++ ) for ( nn = 0; nn < phy_font->num_chars; nn++ )
if ( phy_font->chars[nn].gps_offset != 0 ) if ( phy_font->chars[nn].gps_offset != 0 )
break; break;
if ( nn == phy_font->num_chars ) 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 ) if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )

View File

@ -4,7 +4,7 @@
/* */ /* */
/* TrueType character mapping table (cmap) support (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */

View File

@ -72,6 +72,7 @@
FT_ULong* ptable_offset; FT_ULong* ptable_offset;
FT_ULong* ptable_size; FT_ULong* ptable_size;
if ( vertical ) if ( vertical )
{ {
tag = TTAG_vmtx; tag = TTAG_vmtx;
@ -86,7 +87,7 @@
} }
error = face->goto_table( face, tag, stream, &table_size ); error = face->goto_table( face, tag, stream, &table_size );
if (error) if ( error )
goto Fail; goto Fail;
*ptable_size = table_size; *ptable_size = table_size;
@ -366,27 +367,27 @@
{ {
if ( gindex < (FT_UInt)k ) if ( gindex < (FT_UInt)k )
{ {
table_pos += 4*gindex; table_pos += 4 * gindex;
if ( table_pos+6 > table_end ) if ( table_pos + 6 > table_end )
goto NoData; goto NoData;
if ( FT_STREAM_SEEK( table_pos ) || if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance) || FT_READ_USHORT( *aadvance) ||
FT_READ_SHORT( *abearing ) ) FT_READ_SHORT( *abearing ) )
goto NoData; goto NoData;
} }
else else
{ {
table_pos += 4*(k-1); table_pos += 4 * ( k - 1 );
if ( table_pos+4 > table_end ) if ( table_pos + 4 > table_end )
goto NoData; goto NoData;
if ( FT_STREAM_SEEK( table_pos ) || if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance ) ) FT_READ_USHORT( *aadvance ) )
goto NoData; goto NoData;
table_pos += 4 + 2*(gindex - k); table_pos += 4 + 2 * ( gindex - k );
if ( table_pos+2 > table_end ) if ( table_pos + 2 > table_end )
*abearing = 0; *abearing = 0;
else else
{ {

View File

@ -4,7 +4,7 @@
/* */ /* */
/* TrueType Glyph Loader (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Objects manager (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -524,10 +524,11 @@
static void static void
tt_size_done_bytecode( FT_Size ftsize ) tt_size_done_bytecode( FT_Size ftsize )
{ {
TT_Size size = (TT_Size)ftsize; TT_Size size = (TT_Size)ftsize;
TT_Face face = (TT_Face)ftsize->face; TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory; FT_Memory memory = face->root.memory;
if ( size->debug ) if ( size->debug )
{ {
/* the debug context must be deleted by the debugger itself */ /* the debug context must be deleted by the debugger itself */
@ -561,10 +562,8 @@
} }
/* initialize bytecode-related fields in the size object, /* Initialize bytecode-related fields in the size object. */
* should only be needed when bytecode interpretation is /* We do this only if bytecode interpretation is really needed. */
* really needed
*/
static FT_Error static FT_Error
tt_size_init_bytecode( FT_Size ftsize ) tt_size_init_bytecode( FT_Size ftsize )
{ {
@ -646,7 +645,7 @@
error = tt_size_run_fpgm( size ); error = tt_size_run_fpgm( size );
Exit: Exit:
if (error) if ( error )
tt_size_done_bytecode( ftsize ); tt_size_done_bytecode( ftsize );
return error; return error;
@ -656,7 +655,8 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
tt_size_ready_bytecode( TT_Size size ) tt_size_ready_bytecode( TT_Size size )
{ {
FT_Error error = 0; FT_Error error = TT_Err_Ok;
if ( !size->bytecode_ready ) if ( !size->bytecode_ready )
{ {
@ -677,7 +677,7 @@
for ( i = 0; i < size->cvt_size; i++ ) for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); 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++ ) for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
{ {
size->twilight.org[i].x = 0; size->twilight.org[i].x = 0;
@ -703,13 +703,13 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
tt_size_ready_bytecode( TT_Size size ) tt_size_ready_bytecode( TT_Size size )
{ {
FT_UNUSED(ftsize); FT_UNUSED( ftsize );
return 0; return 0;
} }
#endif /* !TT_USE_BYTECODE_INTERPRETER */ #endif /* !TT_USE_BYTECODE_INTERPRETER */
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
@ -756,7 +756,8 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
tt_size_done( FT_Size ttsize ) /* TT_Size */ 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 #ifdef TT_USE_BYTECODE_INTERPRETER
if ( size->bytecode_ready ) if ( size->bytecode_ready )

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Objects manager (specification). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */