freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] ewaldhew-wip 4873988 17/29: [[stem]] lsb correction


From: Hew Yih Shiuan Ewald
Subject: [freetype2] ewaldhew-wip 4873988 17/29: [[stem]] lsb correction
Date: Mon, 26 Jun 2017 01:55:04 -0400 (EDT)

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

    [[stem]] lsb correction
---
 src/psaux/psintrp.c | 88 ++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 57 insertions(+), 31 deletions(-)

diff --git a/src/psaux/psintrp.c b/src/psaux/psintrp.c
index f73dc2d..f57aa6a 100644
--- a/src/psaux/psintrp.c
+++ b/src/psaux/psintrp.c
@@ -756,13 +756,28 @@
       case cf2_cmdHSTEM:
         FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" ));
 
-        /* never add hints after the mask is computed */
-        /* except if in Type 1 mode (no hintmask op)  */
-        if ( !font->isT1 && cf2_hintmask_isValid( &hintMask ) )
+        if ( !font->isT1 )
         {
-          FT_TRACE4(( "cf2_interpT2CharString:"
-                      " invalid horizontal hint mask\n" ));
-          break;
+          /* never add hints after the mask is computed */
+          /* except if in Type 1 mode (no hintmask op)  */
+          if ( cf2_hintmask_isValid( &hintMask ) )
+          {
+            FT_TRACE4(( "cf2_interpT2CharString:"
+                        " invalid horizontal hint mask\n" ));
+            break;
+          }
+        }
+        else
+        {
+          /* Do lsb correction */
+          CF2_F16Dot16  hint_pos;
+
+          FT_ASSERT( ( cf2_stack_count( opStack ) == 2 ) );
+
+          hint_pos = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+                              font->decoder->builder->left_bearing.y );
+
+          cf2_stack_setReal( opStack, 0, hint_pos );
         }
 
         cf2_doStems( font,
@@ -781,13 +796,28 @@
       case cf2_cmdVSTEM:
         FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" ));
 
-        /* never add hints after the mask is computed */
-        /* except if in Type 1 mode (no hintmask op)  */
-        if ( !font->isT1 && cf2_hintmask_isValid( &hintMask ) )
+        if ( !font->isT1 )
         {
-          FT_TRACE4(( "cf2_interpT2CharString:"
-                      " invalid vertical hint mask\n" ));
-          break;
+          /* never add hints after the mask is computed */
+          /* except if in Type 1 mode (no hintmask op)  */
+          if ( cf2_hintmask_isValid( &hintMask ) )
+          {
+            FT_TRACE4(( "cf2_interpT2CharString:"
+                        " invalid vertical hint mask\n" ));
+            break;
+          }
+        }
+        else
+        {
+          /* Do lsb correction */
+          CF2_F16Dot16  hint_pos;
+
+          FT_ASSERT( ( cf2_stack_count( opStack ) == 2 ) );
+
+          hint_pos = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+                              font->decoder->builder->left_bearing.x );
+
+          cf2_stack_setReal( opStack, 0, hint_pos );
         }
 
         cf2_doStems( font,
@@ -1170,35 +1200,31 @@
                       FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
                     else
                     {
-                      CF2_F16Dot16  v0, dv0, v1, dv1, v2, dv2;
+                      CF2_F16Dot16  v0, v1, v2;
                       CF2_F16Dot16  lsb;
-                      
+
                       FT_TRACE4(( op2 == cf2_escVSTEM3 ? " vstem3\n"
                                                        : " hstem3\n" ));
 
-                      v0  = cf2_stack_popFixed( opStack );
-                      dv0 = cf2_stack_popFixed( opStack );
-                      v1  = cf2_stack_popFixed( opStack );
-                      dv1 = cf2_stack_popFixed( opStack );
-                      v2  = cf2_stack_popFixed( opStack );
-                      dv2 = cf2_stack_popFixed( opStack );
+                      FT_ASSERT( ( cf2_stack_count( opStack ) == 6 ) );
 
                       lsb = ( op2 == cf2_escVSTEM3 ? 
font->decoder->builder->left_bearing.x
                                                    : 
font->decoder->builder->left_bearing.y );
 
-                      cf2_stack_pushFixed( opStack, ADD_INT32( v0, lsb ) );
-                      cf2_stack_pushFixed( opStack, dv0 );
+                      v0 = cf2_stack_getReal( opStack, 0 );
+                      v1 = cf2_stack_getReal( opStack, 2 );
+                      v2 = cf2_stack_getReal( opStack, 4 );
 
-                      cf2_stack_pushFixed( opStack, SUB_INT32( SUB_INT32 ( v1,
-                                                                           v0 
),
-                                                                          dv0 
) );
-                      cf2_stack_pushFixed( opStack, dv1 );
+                      cf2_stack_setReal( opStack, 0,
+                                         ADD_INT32( v0,
+                                                    lsb ) );
+                      cf2_stack_setReal( opStack, 2,
+                                         SUB_INT32( SUB_INT32( v1, v0 ),
+                                                    cf2_stack_getReal( 
opStack, 1 ) ) );
+                      cf2_stack_setReal( opStack, 4,
+                                         SUB_INT32( SUB_INT32( v2, v1 ),
+                                                    cf2_stack_getReal( 
opStack, 3 ) ) );
 
-                      cf2_stack_pushFixed( opStack, SUB_INT32( SUB_INT32 ( v2,
-                                                                           v1 
),
-                                                                          dv1 
) );
-                      cf2_stack_pushFixed( opStack, dv2 );
-                      
                       cf2_doStems( font,
                                    opStack,
                                    op2 == cf2_escVSTEM3 ? &vStemHintArray : 
&hStemHintArray,



reply via email to

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