freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 99be2b315: [cff, truetype] Rearrange variation range


From: Werner Lemberg
Subject: [freetype2] master 99be2b315: [cff, truetype] Rearrange variation range checks.
Date: Tue, 21 May 2024 14:26:24 -0400 (EDT)

branch: master
commit 99be2b315425f51184f23fde2a3c12b528c6a612
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [cff, truetype] Rearrange variation range checks.
    
    This should achieve quicker results for common cases.
    
    * src/cff/cffload.c (cff_blend_build_vector): Rearrange conditionals.
    * src/truetype/ttgxvar.c (tt_var_get_item_delta): Ditto.
---
 src/cff/cffload.c      | 22 ++++++++++------------
 src/truetype/ttgxvar.c | 21 ++++++++++-----------
 2 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index d4f1ef5ff..01d78770b 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1497,24 +1497,23 @@
         CFF_AxisCoords*  axis = &varRegion->axisList[j];
 
 
-        /* compute the scalar contribution of this axis; */
-        /* ignore invalid ranges                         */
-        if ( axis->startCoord > axis->peakCoord ||
-             axis->peakCoord > axis->endCoord   )
+        /* compute the scalar contribution of this axis */
+        /* while running mandatory range checks         */
+        if ( axis->peakCoord == NDV[j] ||
+             axis->peakCoord == 0      )
           continue;
 
         else if ( axis->startCoord < 0 &&
-                  axis->endCoord > 0   &&
-                  axis->peakCoord != 0 )
+                  axis->endCoord   > 0 )
           continue;
 
-        /* peak of 0 means ignore this axis */
-        else if ( axis->peakCoord == 0 )
+        else if ( axis->startCoord > axis->peakCoord ||
+                  axis->peakCoord  > axis->endCoord  )
           continue;
 
         /* ignore this region if coords are out of range */
-        else if ( NDV[j] < axis->startCoord ||
-                  NDV[j] > axis->endCoord   )
+        else if ( NDV[j] <= axis->startCoord ||
+                  NDV[j] >= axis->endCoord   )
         {
           blend->BV[master] = 0;
           break;
@@ -1525,8 +1524,7 @@
           blend->BV[master] = FT_MulDiv( blend->BV[master],
                                          NDV[j] - axis->startCoord,
                                          axis->peakCoord - axis->startCoord );
-
-        else if ( NDV[j] > axis->peakCoord )
+        else   /* NDV[j] > axis->peakCoord ) */
           blend->BV[master] = FT_MulDiv( blend->BV[master],
                                          axis->endCoord - NDV[j],
                                          axis->endCoord - axis->peakCoord );
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 886a90546..2e0cc7539 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -1077,24 +1077,23 @@
         FT_Fixed  ncv = ttface->blend->normalizedcoords[j];
 
 
-        /* compute the scalar contribution of this axis; */
-        /* ignore invalid ranges                         */
-        if ( axis->startCoord > axis->peakCoord ||
-             axis->peakCoord > axis->endCoord   )
+        /* compute the scalar contribution of this axis */
+        /* while running mandatory range checks         */
+        if ( axis->peakCoord == ncv ||
+             axis->peakCoord == 0   )
           continue;
 
         else if ( axis->startCoord < 0 &&
-                  axis->endCoord > 0   &&
-                  axis->peakCoord != 0 )
+                  axis->endCoord   > 0 )
           continue;
 
-        /* peak of 0 means ignore this axis */
-        else if ( axis->peakCoord == 0 )
+        else if ( axis->startCoord > axis->peakCoord ||
+                  axis->peakCoord  > axis->endCoord  )
           continue;
 
         /* ignore this region if coords are out of range */
-        else if ( ncv < axis->startCoord ||
-                  ncv > axis->endCoord   )
+        else if ( ncv <= axis->startCoord ||
+                  ncv >= axis->endCoord   )
         {
           scalar = 0;
           break;
@@ -1105,7 +1104,7 @@
           scalar = FT_MulDiv( scalar,
                               ncv - axis->startCoord,
                               axis->peakCoord - axis->startCoord );
-        else if ( ncv > axis->peakCoord )
+        else   /* ncv > axis->peakCoord */
           scalar = FT_MulDiv( scalar,
                               axis->endCoord - ncv,
                               axis->endCoord - axis->peakCoord );



reply via email to

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