Skip to content

Commit

Permalink
test: Set previousFontMetrics to null + logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Siobhan committed Dec 1, 2023
1 parent d93ce9f commit ccc306c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.text.TextPaint
import android.text.style.LineHeightSpan
import android.text.style.MetricAffectingSpan
import android.text.style.UpdateLayout
import android.util.Log
import org.wordpress.aztec.AlignmentRendering
import org.wordpress.aztec.AztecAttributes
import org.wordpress.aztec.AztecTextFormat
Expand Down Expand Up @@ -124,8 +125,10 @@ open class AztecHeadingSpan(
val spanStart = spanned.getSpanStart(this)
val spanEnd = spanned.getSpanEnd(this)

Log.d("TESTING 101", "chooseHeight is called")
// save original font metrics
if (previousFontMetrics == null) {
Log.d("TESTING 101", "chooseHeight is called, inside previousFontMetrics null check")
previousFontMetrics = Paint.FontMetricsInt()
previousFontMetrics!!.top = fm.top
previousFontMetrics!!.ascent = fm.ascent
Expand Down Expand Up @@ -153,11 +156,13 @@ open class AztecHeadingSpan(
if (!addedTopPadding) {
fm.ascent = previousFontMetrics!!.ascent
fm.top = previousFontMetrics!!.top
Log.d("TESTING 101", "chooseHeight is called, addedTopPadding")
}

if (!addedBottomPadding) {
fm.descent = previousFontMetrics!!.descent
fm.bottom = previousFontMetrics!!.bottom
Log.d("TESTING 101", "chooseHeight is called, addedBottomPadding")
}
}

Expand All @@ -184,9 +189,12 @@ open class AztecHeadingSpan(
override fun updateMeasureState(paint: TextPaint) {
val headingSize = getHeadingSize()
// when font size changes - reset cached font metrics to reapply vertical padding
if (headingSize != previousHeadingSize || previousSpacing != paint.fontSpacing) {
/* if (headingSize != previousHeadingSize || previousSpacing != paint.fontSpacing) {
previousFontMetrics = null
}
*/
previousFontMetrics = null
Log.d("TESTING 101", "updateMeasureState is called and previousFontMetrics set to null")
previousHeadingSize = headingSize
previousSpacing = paint.fontSpacing
when (headingSize) {
Expand Down

0 comments on commit ccc306c

Please sign in to comment.