Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ca12281 authored by Eric Fischer's avatar Eric Fischer Committed by Android (Google) Code Review
Browse files

Merge "Fix rounding of extra spacing when it is negative."

parents c1ba7431 1065758a
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1012,12 +1012,12 @@ extends Layout
        int extra;

        if (needMultiply) {
            // XXX: this looks like it is using the +0.5 and the cast to int
            // to do rounding, but this I expect this isn't doing the intended
            // thing when spacingmult < 1.  An intended extra of, say, -1.2
            // will get 'rounded' to -.7 and then truncated to 0.
            extra = (int) ((below - above) * (spacingmult - 1)
                           + spacingadd + 0.5);
            double ex = (below - above) * (spacingmult - 1) + spacingadd;
            if (ex >= 0) {
                extra = (int)(ex + 0.5);
            } else {
                extra = -(int)(-ex + 0.5);
            }
        } else {
            extra = 0;
        }
+2 −2
Original line number Diff line number Diff line
@@ -213,13 +213,13 @@ public class StaticLayoutTest extends TestCase {
        }

        public int scale(float height) {
            int altVal = (int)(height * sMult + sAdd + 0.5); // existing impl
            int altVal = (int)(height * sMult + sAdd + 0.5);
            int rndVal = Math.round(height * sMult + sAdd);
            if (altVal != rndVal) {
                Log.i("Scale", "expected scale: " + rndVal +
                        " != returned scale: " + altVal);
            }
            return altVal; // existing implementation
            return rndVal;
        }
    }