freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] ewaldhew-wip f7f461c 32/52: [callsubr] type 1 mode


From: Hew Yih Shiuan Ewald
Subject: [freetype2] ewaldhew-wip f7f461c 32/52: [callsubr] type 1 mode
Date: Mon, 10 Jul 2017 05:10:18 -0400 (EDT)

branch: ewaldhew-wip
commit f7f461ceaa0a038144519ca405c937706911dfb8
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>

    [callsubr] type 1 mode
---
 src/psaux/psft.c    | 35 +++++++++++++++++++++++++++++++----
 src/psaux/psintrp.c |  3 ++-
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/src/psaux/psft.c b/src/psaux/psft.c
index 34ac0b6..5f66255 100644
--- a/src/psaux/psft.c
+++ b/src/psaux/psft.c
@@ -710,15 +710,42 @@
     FT_ZERO( buf );
 
     idx = (CF2_UInt)( subrNum + decoder->locals_bias );
-    if ( idx >= decoder->num_locals )
+    if ( idx < 0 || idx >= decoder->num_locals )
       return TRUE;     /* error */
 
     FT_ASSERT( decoder->locals );
 
-    buf->start =
-    buf->ptr   = decoder->locals[idx];
-    buf->end   = decoder->locals[idx + 1];
+    if ( decoder->font->isT1 /* TODO(ewaldhew): actually have this */)
+    {
+      /* The Type 1 driver stores subroutines without the seed bytes. */
+      /* The CID driver stores subroutines with seed bytes.  This     */
+      /* case is taken care of when decoder->subrs_len == 0.          */
+      buf->start = decoder->subrs[idx];
+
+      if ( decoder->subrs_len )
+        buf->end     = buf->start + decoder->subrs_len[idx];
+      else
+      {
+        /* We are using subroutines from a CID font.  We must adjust */
+        /* for the seed bytes.                                       */
+        buf->start  += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
+        buf->end     = decoder->subrs[idx + 1];
+      }
+
+      buf->ptr = buf->start;
 
+      if ( !buf->start )
+      {
+        FT_ERROR(( "t1_decoder_parse_charstrings:"
+                   " invoking empty subrs\n" ));
+      }
+    }
+    else
+    {
+      buf->start =
+      buf->ptr   = decoder->locals[idx];
+      buf->end   = decoder->locals[idx + 1];
+    }
     return FALSE;      /* success */
   }
 
diff --git a/src/psaux/psintrp.c b/src/psaux/psintrp.c
index 01c5c81..b5733bc 100644
--- a/src/psaux/psintrp.c
+++ b/src/psaux/psintrp.c
@@ -979,7 +979,8 @@
           FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr"
                                               : " callsubr" ));
 
-          if ( charstringIndex > CF2_MAX_SUBR )
+          if ( ( !font->isT1 && charstringIndex > CF2_MAX_SUBR ) ||
+               (  font->isT1 && charstringIndex > T1_MAX_SUBRS_CALLS ) )
           {
             /* max subr plus one for charstring */
             lastError = FT_THROW( Invalid_Glyph_Format );



reply via email to

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