-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The current implementation of MarkdownLineHeightSpan
is a bit tricky:
Lines 6 to 18 in b753c7a
public class MarkdownLineHeightSpan implements MarkdownSpan, LineHeightSpan { | |
private final float mLineHeight; | |
public MarkdownLineHeightSpan(float lineHeight) { | |
mLineHeight = lineHeight; | |
} | |
@Override | |
public void chooseHeight(CharSequence text, int start, int end, int spanstartv, int lineHeight, Paint.FontMetricsInt fm) { | |
fm.top -= mLineHeight / 4; | |
fm.ascent -= mLineHeight / 4; | |
} | |
} |
Also, we need to obtain information about existing spans before applying MarkdownLineHeightSpan
:
react-native-live-markdown/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java
Lines 149 to 157 in b753c7a
case "h1": | |
setSpan(ssb, new MarkdownBoldSpan(), start, end); | |
CustomLineHeightSpan[] spans = ssb.getSpans(0, ssb.length(), CustomLineHeightSpan.class); | |
if (spans.length >= 1) { | |
int lineHeight = spans[0].getLineHeight(); | |
setSpan(ssb, new MarkdownLineHeightSpan(lineHeight * 1.5f), start, end); | |
} | |
// NOTE: size span must be set after line height span to avoid height jumps | |
setSpan(ssb, new MarkdownFontSizeSpan(mMarkdownStyle.getH1FontSize()), start, end); |
The objective of this task is to eliminate division by 4 as well as calling .getSpans()
method if needed.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request