Skip to content

Commit 3f004c8

Browse files
author
Gerardo Pacheco
authored
Merge pull request #952 from wordpress-mobile/feature/heading-span-restore-metrics-for-spacing-updates
Heading Span - Reset previous font metrics if the font spacing changes
2 parents b3d5ca6 + 52a7e6b commit 3f004c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecHeadingSpan.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ open class AztecHeadingSpan(
8181

8282
var previousFontMetrics: Paint.FontMetricsInt? = null
8383
var previousTextScale: Float = 1.0f
84+
var previousSpacing: Float? = null
8485

8586
enum class Heading constructor(internal val scale: Float, internal val tag: String) {
8687
H1(SCALE_H1, "h1"),
@@ -163,10 +164,11 @@ open class AztecHeadingSpan(
163164

164165
override fun updateMeasureState(textPaint: TextPaint) {
165166
// when font size changes - reset cached font metrics to reapply vertical padding
166-
if (previousTextScale != heading.scale) {
167+
if (previousTextScale != heading.scale || previousSpacing != textPaint.fontSpacing) {
167168
previousFontMetrics = null
168169
}
169170
previousTextScale = heading.scale
171+
previousSpacing = textPaint.fontSpacing
170172

171173
textPaint.textSize *= heading.scale
172174
}

0 commit comments

Comments
 (0)