Skip to content
Merged
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 @@ -5,15 +5,19 @@ import android.graphics.Paint
import android.graphics.RectF
import android.graphics.Typeface
import android.text.TextPaint
import android.text.style.CharacterStyle
import android.text.style.LineBackgroundSpan
import android.text.style.MetricAffectingSpan
import com.swmansion.enriched.spans.interfaces.EnrichedBlockSpan
import com.swmansion.enriched.styles.HtmlStyle

class EnrichedCodeBlockSpan(private val htmlStyle: HtmlStyle) : CharacterStyle(), LineBackgroundSpan, EnrichedBlockSpan {
override fun updateDrawState(paint: TextPaint?) {
paint?.typeface = Typeface.MONOSPACE
paint?.color = htmlStyle.codeBlockColor
class EnrichedCodeBlockSpan(private val htmlStyle: HtmlStyle) : MetricAffectingSpan(), LineBackgroundSpan, EnrichedBlockSpan {
override fun updateDrawState(paint: TextPaint) {
paint.typeface = Typeface.MONOSPACE
paint.color = htmlStyle.codeBlockColor
}

override fun updateMeasureState(paint: TextPaint) {
paint.typeface = Typeface.MONOSPACE
}

override fun drawBackground(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ package com.swmansion.enriched.spans

import android.graphics.Typeface
import android.text.TextPaint
import android.text.style.BackgroundColorSpan
import android.text.style.MetricAffectingSpan
import com.swmansion.enriched.spans.interfaces.EnrichedInlineSpan
import com.swmansion.enriched.styles.HtmlStyle

class EnrichedInlineCodeSpan(private val htmlStyle: HtmlStyle) : BackgroundColorSpan(htmlStyle.inlineCodeBackgroundColor), EnrichedInlineSpan {
class EnrichedInlineCodeSpan(private val htmlStyle: HtmlStyle) : MetricAffectingSpan(), EnrichedInlineSpan {
override fun updateDrawState(textPaint: TextPaint) {
super.updateDrawState(textPaint)

val typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
textPaint.typeface = typeface
textPaint.color = htmlStyle.inlineCodeColor
textPaint.typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)
textPaint.bgColor = htmlStyle.inlineCodeBackgroundColor
}

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