Skip to content

Commit

Permalink
Explicity reset typeface in updateTextPaint (#47097)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #47097

Calling Paint.reset() doesn't reset the active type face (https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/libs/hwui/hwui/PaintImpl.cpp;l=86), which causes measurements bugs for Text which don't specify a font to be incorrect.

Changelog: [Android][Fixed] Text without explicit font styles was potentially cut-off.

Reviewed By: NickGerleman

Differential Revision: D64535719

fbshipit-source-id: d300c26bf828a0e2e4b170254f9be5f409aff2dc
  • Loading branch information
javache authored and facebook-github-bot committed Oct 18, 2024
1 parent 0a2dec1 commit 95a5d1c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,11 @@ private static Layout createLayout(
private static void updateTextPaint(
TextPaint paint, TextAttributeProps baseTextAttributes, Context context) {
// TextPaint attributes will be used for content outside the Spannable, like for the
// hypothetical height of a new line after a trailing newline charater (considered part of the
// hypothetical height of a new line after a trailing newline character (considered part of the
// previous line).
paint.reset();
paint.setAntiAlias(true);

if (baseTextAttributes.getEffectiveFontSize() != ReactConstants.UNSET) {
paint.setTextSize(baseTextAttributes.getEffectiveFontSize());
}
Expand All @@ -459,6 +460,8 @@ private static void updateTextPaint(
paint.setFakeBoldText((missingStyle & Typeface.BOLD) != 0);
paint.setTextSkewX((missingStyle & Typeface.ITALIC) != 0 ? -0.25f : 0);
}
} else {
paint.setTypeface(null);
}
}

Expand Down

0 comments on commit 95a5d1c

Please sign in to comment.