[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master 41533b9 1/3: [cff] Code shuffling.
From: |
Werner LEMBERG |
Subject: |
[freetype2] master 41533b9 1/3: [cff] Code shuffling. |
Date: |
Thu, 15 Dec 2016 11:35:29 +0000 (UTC) |
branch: master
commit 41533b958cca73ed8f0e12ec4b38f1369e4e9ee3
Author: Dave Arnold <address@hidden>
Commit: Werner Lemberg <address@hidden>
[cff] Code shuffling.
* src/cff/cfftypes.h (CFF_Font): Add `library' and `base_offset'
fields.
* src/cff/cffload.c (cff_subfont_load): Change last argument to
`CFF_Font'
Split off parsing of private dictionary into...
(cff_load_private_dict): ...this new function.
(cff_font_load): Updated.
---
ChangeLog | 14 ++++++
src/cff/cffload.c | 127 ++++++++++++++++++++++++++++++++--------------------
src/cff/cfftypes.h | 2 +
3 files changed, 94 insertions(+), 49 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a20fd9b..dd862dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2016-12-15 Dave Arnold <address@hidden>
+ Werner Lemberg <address@hidden>
+
+ [cff] Code shuffling.
+
+ * src/cff/cfftypes.h (CFF_Font): Add `library' and `base_offset'
+ fields.
+
+ * src/cff/cffload.c (cff_subfont_load): Change last argument to
+ `CFF_Font'
+ Split off parsing of private dictionary into...
+ (cff_load_private_dict): ...this new function.
+ (cff_font_load): Updated.
+
2016-12-14 Werner Lemberg <address@hidden>
[sfnt, truetype] Add framework for Metrics Variations service.
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index c74a0bb..072474f 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1333,25 +1333,77 @@
static FT_Error
- cff_subfont_load( CFF_SubFont font,
+ cff_load_private_dict( CFF_Font font,
+ CFF_SubFont subfont )
+ {
+ FT_Error error = FT_Err_Ok;
+ CFF_ParserRec parser;
+ CFF_FontRecDict top = &subfont->font_dict;
+ CFF_Private priv = &subfont->private_dict;
+ FT_Stream stream = font->stream;
+
+
+ /* parse the private dictionary, if any */
+ if ( !top->private_offset || !top->private_size )
+ goto Exit;
+
+ /* set defaults */
+ FT_ZERO( priv );
+
+ priv->blue_shift = 7;
+ priv->blue_fuzz = 1;
+ priv->lenIV = -1;
+ 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,
+ font->library,
+ top->num_designs,
+ top->num_axes );
+
+ if ( FT_STREAM_SEEK( font->base_offset + top->private_offset ) ||
+ FT_FRAME_ENTER( top->private_size ) )
+ goto Exit;
+
+ FT_TRACE4(( " private dictionary:\n" ));
+ error = cff_parser_run( &parser,
+ (FT_Byte*)stream->cursor,
+ (FT_Byte*)stream->limit );
+ FT_FRAME_EXIT();
+
+ if ( error )
+ goto Exit;
+
+ /* ensure that `num_blue_values' is even */
+ priv->num_blue_values &= ~1;
+
+ Exit:
+ return error;
+ }
+
+
+ static FT_Error
+ cff_subfont_load( CFF_SubFont subfont,
CFF_Index idx,
FT_UInt font_index,
FT_Stream stream,
FT_ULong base_offset,
- FT_Library library )
+ CFF_Font font )
{
FT_Error error;
CFF_ParserRec parser;
FT_Byte* dict = NULL;
FT_ULong dict_len;
- CFF_FontRecDict top = &font->font_dict;
- CFF_Private priv = &font->private_dict;
+ CFF_FontRecDict top = &subfont->font_dict;
+ CFF_Private priv = &subfont->private_dict;
cff_parser_init( &parser,
CFF_CODE_TOPDICT,
- &font->font_dict,
- library,
+ &subfont->font_dict,
+ font->library,
0,
0 );
@@ -1396,39 +1448,9 @@
goto Exit;
/* parse the private dictionary, if any */
- if ( top->private_offset && top->private_size )
- {
- /* set defaults */
- FT_ZERO( priv );
-
- priv->blue_shift = 7;
- priv->blue_fuzz = 1;
- priv->lenIV = -1;
- 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,
- 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 ) )
- goto Exit;
-
- FT_TRACE4(( " private dictionary:\n" ));
- error = cff_parser_run( &parser,
- (FT_Byte*)stream->cursor,
- (FT_Byte*)stream->limit );
- FT_FRAME_EXIT();
- if ( error )
- goto Exit;
-
- /* ensure that `num_blue_values' is even */
- priv->num_blue_values &= ~1;
- }
+ error = cff_load_private_dict( font, subfont );
+ if ( error )
+ goto Exit;
/* read the local subrs, if any */
if ( priv->local_subrs_offset )
@@ -1437,12 +1459,12 @@
priv->local_subrs_offset ) )
goto Exit;
- error = cff_index_init( &font->local_subrs_index, stream, 1 );
+ error = cff_index_init( &subfont->local_subrs_index, stream, 1 );
if ( error )
goto Exit;
- error = cff_index_get_pointers( &font->local_subrs_index,
- &font->local_subrs, NULL, NULL );
+ error = cff_index_get_pointers( &subfont->local_subrs_index,
+ &subfont->local_subrs, NULL, NULL );
if ( error )
goto Exit;
}
@@ -1495,10 +1517,13 @@
FT_ZERO( font );
FT_ZERO( &string_index );
- font->stream = stream;
- font->memory = memory;
- dict = &font->top_font.font_dict;
- base_offset = FT_STREAM_POS();
+ dict = &font->top_font.font_dict;
+ base_offset = FT_STREAM_POS();
+
+ font->library = library;
+ font->stream = stream;
+ font->memory = memory;
+ font->base_offset = base_offset;
/* read CFF font header */
if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )
@@ -1577,7 +1602,7 @@
subfont_index,
stream,
base_offset,
- library );
+ font );
if ( error )
goto Exit;
@@ -1625,8 +1650,12 @@
{
sub = font->subfonts[idx];
FT_TRACE4(( "parsing subfont %u\n", idx ));
- error = cff_subfont_load( sub, &fd_index, idx,
- stream, base_offset, library );
+ error = cff_subfont_load( sub,
+ &fd_index,
+ idx,
+ stream,
+ base_offset,
+ font );
if ( error )
goto Fail_CID;
}
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index 4426c7e..a679c6a 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -224,8 +224,10 @@ FT_BEGIN_HEADER
typedef struct CFF_FontRec_
{
+ FT_Library library;
FT_Stream stream;
FT_Memory memory;
+ FT_ULong base_offset; /* offset to start of CFF */
FT_UInt num_faces;
FT_UInt num_glyphs;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master 41533b9 1/3: [cff] Code shuffling.,
Werner LEMBERG <=