From e84a7ae48ce6697a2762a27199b3401cbfa86d6a Mon Sep 17 00:00:00 2001 From: nopdan Date: Fri, 10 May 2024 13:26:24 +0800 Subject: [PATCH] fix: the last candidate font size is abnormal --- .../java/com/osfans/trime/ime/composition/Composition.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/osfans/trime/ime/composition/Composition.kt b/app/src/main/java/com/osfans/trime/ime/composition/Composition.kt index 356af365e8..5c9bd0583a 100644 --- a/app/src/main/java/com/osfans/trime/ime/composition/Composition.kt +++ b/app/src/main/java/com/osfans/trime/ime/composition/Composition.kt @@ -142,12 +142,14 @@ class Composition(context: Context, attrs: AttributeSet?) : TextView(context, at private val highlightTextColor: Int?, private val highlightBackColor: Int?, private val textColor: Int?, + private val textSize: Int, ) : ClickableSpan() { override fun onClick(tv: View) { textInputManager?.onCandidatePressed(index) } override fun updateDrawState(ds: TextPaint) { + ds.textSize = sp(textSize).toFloat() ds.isUnderlineText = false ds.typeface = typeface if (index == highlightIndex) { @@ -319,6 +321,7 @@ class Composition(context: Context, attrs: AttributeSet?) : TextView(context, at highlightLabelColor, highlightCandidateBackColor, labelColor, + labelTextSize, ) inSpans(alignmentSpan, labelSpan, labelTextSizeSpan) { append(label) } @@ -329,6 +332,7 @@ class Composition(context: Context, attrs: AttributeSet?) : TextView(context, at highlightCandidateTextColor, highlightCandidateBackColor, candidateTextColor, + candidateTextSize, ) inSpans(alignmentSpan, candidateSpan, candidateTextSizeSpan) { append(text) } currentLineLength += text.length @@ -341,6 +345,7 @@ class Composition(context: Context, attrs: AttributeSet?) : TextView(context, at highlightCommentTextColor, highlightCandidateBackColor, commentTextColor, + commentTextSize, ) inSpans(alignmentSpan, commentSpan, commentTextSizeSpan) { append(comment) } currentLineLength += comment.length