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

Commit 337d92e0 authored by Siyamed Sinir's avatar Siyamed Sinir
Browse files

Fix bullet span vertical positioning

Test: bit CtsTextTestCases:android.text.style.cts.BulletSpanTest
Bug: 33138492
Change-Id: I2fd787190d7125591fb0fc823f6ead532c859829
parent c94801f8
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -110,19 +110,16 @@ public class BulletSpan implements LeadingMarginSpan, ParcelableSpan {

            p.setStyle(Paint.Style.FILL);

            if (l != null) {
                // "bottom" position might include extra space as a result of line spacing
                // configuration. Subtract extra space in order to show bullet in the vertical
                // center of characters.
                final int line = l.getLineForOffset(start);
            final float y;
            if (line == l.getLineCount() - 1) {
                // line spacing values are not added to last line, vertical center is top+bottom/2
                y = (top + bottom) / 2f;
            } else {
                // line spacing values are added to the lines other than last line, remove added
                // empty line spacing to calculate vertical center
                final float lineHeight =
                        (top - bottom - l.getSpacingAdd()) / l.getSpacingMultiplier();
                y = top - lineHeight / 2f;
                bottom = bottom - l.getLineExtra(line);
            }

            final float y = (top + bottom) / 2f;

            if (c.isHardwareAccelerated()) {
                if (sBulletPath == null) {
                    sBulletPath = new Path();