Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ open class EnrichedInlineCodeSpan(
) : MetricAffectingSpan(),
EnrichedInlineSpan {
override fun updateDrawState(textPaint: TextPaint) {
val typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
textPaint.typeface = typeface
applyMonospace(textPaint)
textPaint.color = enrichedStyle.inlineCodeColor
textPaint.bgColor = enrichedStyle.inlineCodeBackgroundColor
}

override fun updateMeasureState(textPaint: TextPaint) {
val typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
applyMonospace(textPaint)
}

// When switching to a monospace font, we need to remember
// and apply other current styles, such as bold or italic.
private fun applyMonospace(textPaint: TextPaint) {
val currentStyle = textPaint.typeface?.style ?: Typeface.NORMAL
val typeface = Typeface.create(Typeface.MONOSPACE, currentStyle)

textPaint.typeface = typeface
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class InlineStyles(
) {
val previousSpanStart = (start - 1).coerceAtLeast(0)
val previousSpanEnd = previousSpanStart + 1
val nextSpanStart = (end + 1).coerceAtMost(spannable.length)
val nextSpanStart = end.coerceAtMost(spannable.length)
val nextSpanEnd = (nextSpanStart + 1).coerceAtMost(spannable.length)
val previousSpans = spannable.getSpans(previousSpanStart, previousSpanEnd, type)
val nextSpans = spannable.getSpans(nextSpanStart, nextSpanEnd, type)
Expand Down
Loading