From 3a0b08eb07080d00db9d6f414a189f4af9736b94 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Fri, 25 May 2018 12:14:18 +0300 Subject: [PATCH] Fix bullet list item size (depend on text size and not top-bottom arguments) --- .../ru/noties/markwon/spans/BulletListItemSpan.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/ru/noties/markwon/spans/BulletListItemSpan.java b/library/src/main/java/ru/noties/markwon/spans/BulletListItemSpan.java index 7beda477..368f13a9 100644 --- a/library/src/main/java/ru/noties/markwon/spans/BulletListItemSpan.java +++ b/library/src/main/java/ru/noties/markwon/spans/BulletListItemSpan.java @@ -48,12 +48,15 @@ public class BulletListItemSpan implements LeadingMarginSpan { try { final int width = theme.getBlockMargin(); - final int height = bottom - top; - final int side = theme.getBulletWidth(bottom - top); + // @since 1.0.6 we no longer rely on (bottom-top) calculation in order to detect line height + // it lead to bad rendering as first & last lines received different results even + // if text size is the same (first line received greater amount and bottom line -> less) + final int textLineHeight = (int) (paint.descent() - paint.ascent() + .5F); + + final int side = theme.getBulletWidth(textLineHeight); final int marginLeft = (width - side) / 2; - final int marginTop = (height - side) / 2; // in order to support RTL final int l; @@ -64,7 +67,8 @@ public class BulletListItemSpan implements LeadingMarginSpan { l = Math.min(left, right); r = Math.max(left, right); } - final int t = top + marginTop; + + final int t = baseline + (int) ((paint.descent() + paint.ascent()) / 2.F + .5F) - (side / 2); final int b = t + side; if (level == 0