summaryrefslogtreecommitdiffstats
path: root/src/cff/cffload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cff/cffload.c')
-rw-r--r--src/cff/cffload.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index c61222d..470fa82 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-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -382,13 +382,15 @@
static FT_Error
cff_index_get_pointers( CFF_Index idx,
FT_Byte*** table,
- FT_Byte** pool )
+ FT_Byte** pool,
+ FT_ULong* pool_size )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = idx->stream->memory;
FT_Byte** t = NULL;
FT_Byte* new_bytes = NULL;
+ FT_ULong new_size;
*table = NULL;
@@ -400,10 +402,11 @@
goto Exit;
}
- if ( idx->count > 0 &&
- !FT_NEW_ARRAY( t, idx->count + 1 ) &&
- ( !pool || !FT_ALLOC( new_bytes,
- idx->data_size + idx->count ) ) )
+ new_size = idx->data_size + idx->count;
+
+ if ( idx->count > 0 &&
+ !FT_NEW_ARRAY( t, idx->count + 1 ) &&
+ ( !pool || !FT_ALLOC( new_bytes, new_size ) ) )
{
FT_ULong n, cur_offset;
FT_ULong extra = 0;
@@ -459,6 +462,8 @@
if ( pool )
*pool = new_bytes;
+ if ( pool_size )
+ *pool_size = new_size;
}
Exit:
@@ -501,8 +506,8 @@
{
element++;
off2 = cff_index_read_offset( idx, &error );
- }
- while ( off2 == 0 && element < idx->count );
+
+ } while ( off2 == 0 && element < idx->count );
}
}
else /* use offsets table */
@@ -597,7 +602,8 @@
if ( !FT_ALLOC( name, byte_len + 1 ) )
{
- FT_MEM_COPY( name, bytes, byte_len );
+ if ( byte_len )
+ FT_MEM_COPY( name, bytes, byte_len );
name[byte_len] = 0;
}
cff_index_forget_element( idx, &bytes );
@@ -809,7 +815,7 @@
/* When multiple GIDs map to the same CID, we choose the lowest */
/* GID. This is not described in any spec, but it matches the */
/* behaviour of recent Acroread versions. */
- for ( j = (FT_Long)num_glyphs - 1; j >= 0 ; j-- )
+ for ( j = (FT_Long)num_glyphs - 1; j >= 0; j-- )
charset->cids[charset->sids[j]] = (FT_UShort)j;
charset->max_cid = max_cid;
@@ -871,8 +877,8 @@
FT_UShort glyph_sid;
- /* If the the offset is greater than 2, we have to parse the */
- /* charset table. */
+ /* If the offset is greater than 2, we have to parse the charset */
+ /* table. */
if ( offset > 2 )
{
FT_UInt j;
@@ -1316,7 +1322,12 @@
CFF_Private priv = &font->private_dict;
- cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict, library );
+ cff_parser_init( &parser,
+ CFF_CODE_TOPDICT,
+ &font->font_dict,
+ library,
+ 0,
+ 0 );
/* set defaults */
FT_MEM_ZERO( top, sizeof ( *top ) );
@@ -1370,7 +1381,12 @@
priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
- cff_parser_init( &parser, CFF_CODE_PRIVATE, priv, library );
+ cff_parser_init( &parser,
+ CFF_CODE_PRIVATE,
+ priv,
+ library,
+ top->num_designs,
+ top->num_axes );
if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
FT_FRAME_ENTER( font->font_dict.private_size ) )
@@ -1400,7 +1416,7 @@
goto Exit;
error = cff_index_get_pointers( &font->local_subrs_index,
- &font->local_subrs, NULL );
+ &font->local_subrs, NULL, NULL );
if ( error )
goto Exit;
}
@@ -1478,16 +1494,17 @@
/* read the name, top dict, string and global subrs index */
if ( FT_SET_ERROR( cff_index_init( &font->name_index,
- stream, 0 ) ) ||
+ stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &font->font_dict_index,
- stream, 0 ) ) ||
+ stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &string_index,
- stream, 1 ) ) ||
+ stream, 1 ) ) ||
FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
- stream, 1 ) ) ||
+ stream, 1 ) ) ||
FT_SET_ERROR( cff_index_get_pointers( &string_index,
&font->strings,
- &font->string_pool ) ) )
+ &font->string_pool,
+ &font->string_pool_size ) ) )
goto Exit;
font->num_strings = string_index.count;
@@ -1614,7 +1631,7 @@
font->num_glyphs = font->charstrings_index.count;
error = cff_index_get_pointers( &font->global_subrs_index,
- &font->global_subrs, NULL );
+ &font->global_subrs, NULL, NULL );
if ( error )
goto Exit;