Fixed
Status Update
Comments
ki...@google.com <ki...@google.com>
no...@google.com <no...@google.com> #3
Amended the behavior slightly to find the best match from the requested style.
si...@google.com <si...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 6e7a1ffacde6ead3acbff09514503e896d3c8bf3
Author: Sean McQuillan <seanmcq@google.com>
Date: Tue Mar 29 11:04:25 2022
TypefaceCompatApi29 finds best from requested style
This causes fonts closer to the desired style to be chosen on
resolution.
Test: ./gradlew :core:core:cAT
Bug: b/194553426
Relnote: "TypefaceCompat will now respect both requested and loaded
style information on API 29+. This is a behavior change when the loaded
fonts are not FontWeight.Normal or FontWeight.Bold, as the actual loaded
weight and style will be used. For more information see b/194553426 "
Change-Id: I1f90279afa68afa450bb98eb7c5237464c5f57d8
M core/core/src/androidTest/java/androidx/core/graphics/TypefaceCompatTest.java
M core/core/src/androidTest/java/androidx/core/content/res/ResourcesCompatTest.java
A core/core/src/androidTest/res/font/samplexmlfont_medium.xml
M core/core/src/main/java/androidx/core/graphics/TypefaceCompatApi29Impl.java
https://android-review.googlesource.com/2047984
Branch: androidx-main
commit 6e7a1ffacde6ead3acbff09514503e896d3c8bf3
Author: Sean McQuillan <seanmcq@google.com>
Date: Tue Mar 29 11:04:25 2022
TypefaceCompatApi29 finds best from requested style
This causes fonts closer to the desired style to be chosen on
resolution.
Test: ./gradlew :core:core:cAT
Bug:
Relnote: "TypefaceCompat will now respect both requested and loaded
style information on API 29+. This is a behavior change when the loaded
fonts are not FontWeight.Normal or FontWeight.Bold, as the actual loaded
weight and style will be used. For more information see
Change-Id: I1f90279afa68afa450bb98eb7c5237464c5f57d8
M core/core/src/androidTest/java/androidx/core/graphics/TypefaceCompatTest.java
M core/core/src/androidTest/java/androidx/core/content/res/ResourcesCompatTest.java
A core/core/src/androidTest/res/font/samplexmlfont_medium.xml
M core/core/src/main/java/androidx/core/graphics/TypefaceCompatApi29Impl.java
si...@google.com <si...@google.com>
an...@google.com <an...@google.com> #6
Since it's not listed here, repeating:
This was solved by github contribution
dr...@gmail.com <dr...@gmail.com> #7
Any way I can tell what version this will land in?
dr...@gmail.com <dr...@gmail.com> #9
Great—works as expected, thanks!
Description
When using
ResourcesCompat.getFont
to resolve a .ttf file in res/font, the returnedTypeface
instance always has a weight of 400 and a style ofNORMAL
.On all APIs < 29, style correctly resolves to
ITALIC
. On API 28, weight correctly resolves to 300.The font actually looks correct when displayed on an API 29 device, it just has the wrong values according to the
Typeface
instance.The issue is reproducible in this test class . Several tests fail on API 29 only due to this issue. I've also added a temporary
typefaceBug
test case that uses an ActivityScenario to demonstrate that the text actually appears correctly on API 29.