[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] ewaldhew-wip f3f6fbd 11/47: [255, div] large number handling
From: |
Hew Yih Shiuan Ewald |
Subject: |
[freetype2] ewaldhew-wip f3f6fbd 11/47: [255, div] large number handling |
Date: |
Thu, 6 Jul 2017 04:49:33 -0400 (EDT) |
branch: ewaldhew-wip
commit f3f6fbd31ad20a6cc70681311e57113fa98f9ea3
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>
[255, div] large number handling
---
src/psaux/psintrp.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 54 insertions(+), 7 deletions(-)
diff --git a/src/psaux/psintrp.c b/src/psaux/psintrp.c
index 5bf1886..8392a2d 100644
--- a/src/psaux/psintrp.c
+++ b/src/psaux/psintrp.c
@@ -1354,14 +1354,22 @@
FT_TRACE4(( " div\n" ));
- divisor = cf2_stack_popFixed( opStack );
- dividend = cf2_stack_popFixed( opStack );
-
+ if ( font->isT1 && large_int )
+ {
+ divisor = (CF2_F16Dot16)cf2_stack_popInt( opStack );
+ dividend = (CF2_F16Dot16)cf2_stack_popInt( opStack );
+
+ large_int = FALSE;
+ }
+ else
+ {
+ divisor = cf2_stack_popFixed( opStack );
+ dividend = cf2_stack_popFixed( opStack );
+ }
+
cf2_stack_pushFixed( opStack,
FT_DivFix( dividend, divisor ) );
- if ( font->isT1 )
- large_int = FALSE;
}
continue; /* do not clear the stack */
@@ -2198,9 +2206,48 @@
( byte3 << 8 ) |
byte4 );
- FT_TRACE4(( " %.5f", v / 65536.0 ));
+ /* For Type 1:
*/
+ /* According to the specification, values > 32000 or < -32000 must
*/
+ /* be followed by a `div' operator to make the result be in the
*/
+ /* range [-32000;32000]. We expect that the second argument of
*/
+ /* `div' is not a large number. Additionally, we don't handle
*/
+ /* stuff like `<large1> <large2> <num> div <num> div' or
*/
+ /* <large1> <large2> <num> div div'. This is probably not allowed
*/
+ /* anyway.
*/
+ /* <large> <num> <num>+ div is not checked but should not be
*/
+ /* allowed as the large value remains untouched.
*/
+ if ( font->isT1 )
+ {
+ if ( v > 32000 || v < -32000 )
+ {
+ if ( large_int )
+ {
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " no `div' after large integer\n" ));
+ }
+ else
+ large_int = TRUE;
+ }
+ else
+ {
+ if ( !large_int )
+ v = (CF2_Fixed)( (FT_UInt32)v << 16 );
+ }
+ }
+
+ if ( large_int )
+ {
+ FT_TRACE4(( " %.5f", v ));
+
+ cf2_stack_pushInt( opStack, (CF2_Int)v );
+ }
+ else
+ {
+ FT_TRACE4(( " %.5f", v / 65536.0 ));
- cf2_stack_pushFixed( opStack, v );
+ cf2_stack_pushFixed( opStack, v );
+ }
+
}
}
continue; /* don't clear stack */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] ewaldhew-wip f3f6fbd 11/47: [255, div] large number handling,
Hew Yih Shiuan Ewald <=