freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master e27b8a5: [truetype] Speed up `TT_Load_Glyph'.


From: Werner LEMBERG
Subject: [freetype2] master e27b8a5: [truetype] Speed up `TT_Load_Glyph'.
Date: Tue, 27 Sep 2016 19:21:38 +0000 (UTC)

branch: master
commit e27b8a5598d851c98ec04f23316587e94d5bb086
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [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.
---
 ChangeLog                           |   14 ++++++++++++++
 include/freetype/internal/tttypes.h |    3 +--
 src/truetype/ttgload.c              |   32 +++-----------------------------
 src/truetype/ttpload.c              |   15 ++++++++++++++-
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a1d3e37..d2b89e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2016-09-27  Werner Lemberg  <address@hidden>
 
+       [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  <address@hidden>
+
        [truetype] Introduce dynamic limits for some bytecode opcodes.
 
        This speeds up FreeType's handling of malformed fonts.
diff --git a/include/freetype/internal/tttypes.h 
b/include/freetype/internal/tttypes.h
index 1767132..f00e572 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1344,6 +1344,7 @@ FT_BEGIN_HEADER
     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;
@@ -1492,8 +1493,6 @@ FT_BEGIN_HEADER
     FT_Vector        pp1;
     FT_Vector        pp2;
 
-    FT_ULong         glyf_offset;
-
     /* the zone where we load our glyphs */
     TT_GlyphZoneRec  base;
     TT_GlyphZoneRec  zone;
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 2d0b29f..28a5419 100644
--- 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;
@@ -2497,32 +2497,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 )
     {
diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c
index 328f3a3..c84c18e 100644
--- 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 );



reply via email to

[Prev in Thread] Current Thread [Next in Thread]