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

Commit 0bb00093 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Fix in vertical measurement in text lines with different text sizes

The last span of the TextLine was defining the FontMetrics, instead of
min/maxing the different values.

Bug 3220698

Change-Id: I7394b1699a15aeee4cc38462d561faf329d3e1f6
parent dcafdb2e
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -662,6 +662,25 @@ class TextLine {
        }
    }

    /**
     * @param wp
     */
    private static void expandMetricsFromPaint(FontMetricsInt fmi, TextPaint wp) {
        final int previousTop     = fmi.top;
        final int previousAscent  = fmi.ascent;
        final int previousDescent = fmi.descent;
        final int previousBottom  = fmi.bottom;
        final int previousLeading = fmi.leading;

        wp.getFontMetricsInt(fmi);

        fmi.top     = Math.min(fmi.top,     previousTop);
        fmi.ascent  = Math.min(fmi.ascent,  previousAscent);
        fmi.descent = Math.max(fmi.descent, previousDescent);
        fmi.bottom  = Math.max(fmi.bottom,  previousBottom);
        fmi.leading = Math.max(fmi.leading, previousLeading);
    }

    /**
     * Utility function for measuring and rendering text.  The text must
     * not include a tab or emoji.
@@ -703,7 +722,7 @@ class TextLine {
        }

        if (fmi != null) {
            wp.getFontMetricsInt(fmi);
            expandMetricsFromPaint(fmi, wp);
        }

        if (c != null) {
+1 −0
Original line number Diff line number Diff line
@@ -1818,6 +1818,7 @@ public class Paint {
        nativeGetCharArrayBounds(mNativePaint, text, index, count, bounds);
    }
    
    @Override
    protected void finalize() throws Throwable {
        finalizer(mNativePaint);
    }