[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] ewaldhew-wip 29196f0 20/47: [callsubr] type 1 mode
From: |
Hew Yih Shiuan Ewald |
Subject: |
[freetype2] ewaldhew-wip 29196f0 20/47: [callsubr] type 1 mode |
Date: |
Thu, 6 Jul 2017 04:49:35 -0400 (EDT) |
branch: ewaldhew-wip
commit 29196f0114f4f099175b4dde3ca2a1f39f004d6f
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 2107100..42f0cf2 100644
--- a/src/psaux/psft.c
+++ b/src/psaux/psft.c
@@ -704,15 +704,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 e05b686..3d99204 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 );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] ewaldhew-wip 29196f0 20/47: [callsubr] type 1 mode,
Hew Yih Shiuan Ewald <=