Skip to content

Commit

Permalink
Heading Span - Reset previous font metrics if the font spacing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo committed Jan 25, 2022
1 parent a58cd77 commit 52a7e6b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ open class AztecHeadingSpan(

var previousFontMetrics: Paint.FontMetricsInt? = null
var previousTextScale: Float = 1.0f
var previousSpacing: Float? = null

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

override fun updateMeasureState(textPaint: TextPaint) {
// when font size changes - reset cached font metrics to reapply vertical padding
if (previousTextScale != heading.scale) {
if (previousTextScale != heading.scale || previousSpacing != textPaint.fontSpacing) {
previousFontMetrics = null
}
previousTextScale = heading.scale
previousSpacing = textPaint.fontSpacing

textPaint.textSize *= heading.scale
}
Expand Down

0 comments on commit 52a7e6b

Please sign in to comment.