Skip to content
Snippets Groups Projects
Commit b82c54b7 authored by Sally's avatar Sally
Browse files

[Bold text] Use a default bold font for null typefaces

When a TextView's typeface is null and bold is enabled, Typeface.DEFAULT
is used. Instead, this should be Typeface.DEFAULT_BOLD

Flag:
adb shell device_config put text com.android.text.flags.fix_null_typeface_bolding true

Bug: 314811487
Test: manual, CTS
Change-Id: I1be9d6c17b6736caa28e280872bf4b1dac4c7855
parent 43b19a4a
No related branches found
No related tags found
No related merge requests found
......@@ -201,3 +201,13 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
flag {
name: "fix_null_typeface_bolding"
namespace: "text"
description: "Use a bold typeface when bolding is enabled and the original typeface is null"
bug: "314811487"
metadata {
purpose: PURPOSE_BUGFIX
}
}
......@@ -4817,7 +4817,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mFontWeightAdjustment != 0
&& mFontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED) {
if (tf == null) {
tf = Typeface.DEFAULT;
if (Flags.fixNullTypefaceBolding()) {
tf = Typeface.DEFAULT_BOLD;
} else {
tf = Typeface.DEFAULT;
}
} else {
int newWeight = Math.min(
Math.max(tf.getWeight() + mFontWeightAdjustment, FontStyle.FONT_WEIGHT_MIN),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment