ref: e27b8a5598d851c98ec04f23316587e94d5bb086
parent: 0d9459294238c4fa5a45ccf8077c8b258bd487ac
author: Werner Lemberg <[email protected]>
date: Tue Sep 27 17:21:01 EDT 2016
[truetype] Speed up `TT_Load_Glyph'. This avoids additional calls to `tt_face_lookup_table' for the `glyf' table, which can be expensive. * include/freetype/internal/tttypes.h (TT_LoaderRec): Move `glyf_offset' field to ... (TT_FaceRec): ... this structure. * src/truetype/ttgload.c (load_truetype_glyph): Updated. (tt_loader_init): Move initialization of `glyf_offset' to ... * src/truetype/ttpload.c (tt_face_load_loca): .. this function.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2016-09-27 Werner Lemberg <[email protected]>
+ [truetype] Speed up `TT_Load_Glyph'.
+
+ This avoids additional calls to `tt_face_lookup_table' for the
+ `glyf' table, which can be expensive.
+
+ * include/freetype/internal/tttypes.h (TT_LoaderRec): Move
+ `glyf_offset' field to ...
+ (TT_FaceRec): ... this structure.
+ * src/truetype/ttgload.c (load_truetype_glyph): Updated.
+ (tt_loader_init): Move initialization of `glyf_offset' to ...
+ * src/truetype/ttpload.c (tt_face_load_loca): .. this function.
+
+2016-09-27 Werner Lemberg <[email protected]>
+
[truetype] Introduce dynamic limits for some bytecode opcodes.
This speeds up FreeType's handling of malformed fonts.
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1344,6 +1344,7 @@
const char* postscript_name;
FT_ULong glyf_len;
+ FT_ULong glyf_offset; /* since 2.7.1 */
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Bool doblend;
@@ -1491,8 +1492,6 @@
FT_Bool linear_def;
FT_Vector pp1;
FT_Vector pp2;
-
- FT_ULong glyf_offset;
/* the zone where we load our glyphs */
TT_GlyphZoneRec base;
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1505,10 +1505,10 @@
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* for the incremental interface, `glyf_offset' is always zero */
- if ( !loader->glyf_offset &&
+ if ( !face->glyf_offset &&
!face->root.internal->incremental_interface )
#else
- if ( !loader->glyf_offset )
+ if ( !face->glyf_offset )
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
@@ -1517,7 +1517,7 @@
}
error = face->access_glyph_frame( loader, glyph_index,
- loader->glyf_offset + offset,
+ face->glyf_offset + offset,
(FT_UInt)loader->byte_len );
if ( error )
goto Exit;
@@ -2496,32 +2496,6 @@
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
-
- /* seek to the beginning of the glyph table -- for Type 42 fonts */
- /* the table might be accessed from a Postscript stream or something */
- /* else... */
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
-
- if ( face->root.internal->incremental_interface )
- loader->glyf_offset = 0;
- else
-
-#endif
-
- {
- error = face->goto_table( face, TTAG_glyf, stream, 0 );
-
- if ( FT_ERR_EQ( error, Table_Missing ) )
- loader->glyf_offset = 0;
- else if ( error )
- {
- FT_ERROR(( "tt_loader_init: could not access glyph table\n" ));
- return error;
- }
- else
- loader->glyf_offset = FT_STREAM_POS();
- }
/* get face's glyph loader */
if ( !glyf_table_only )
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -73,9 +73,22 @@
/* it is possible that a font doesn't have a glyf table at all */
/* or its size is zero */
if ( FT_ERR_EQ( error, Table_Missing ) )
- face->glyf_len = 0;
+ {
+ face->glyf_len = 0;
+ face->glyf_offset = 0;
+ }
else if ( error )
goto Exit;
+ else
+ {
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( face->root.internal->incremental_interface )
+ face->glyf_offset = 0;
+ else
+#endif
+ face->glyf_offset = FT_STREAM_POS();
+ }
+
FT_TRACE2(( "Locations " ));
error = face->goto_table( face, TTAG_loca, stream, &table_len );