当我想使用具有可变字体粗细(wght
标签)的字体时 - 特别是Public Sans - 并且字体在 XML 文件中注册,如下所示(使用fontVariationSettings
):
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="100"
android:font="@font/public_sans_variable_font_wght"
android:fontVariationSettings="'wght' 100" />
<!-- ... all weights up to 900 -->
</font-family>
对于旧类型的 XML 布局,甚至对于字体 XML ,权重似乎没有正确反映在 Android Studio设计窗格中。但是,在应用程序运行时,文本会正确呈现。
(设计左,运行时右)
使用Jetpack Compose,它是一致的——在设计(使用@Preview
)和运行时都是正确的。
使用静态字体(单独bold
的、regular
文件等,这不是问题。)
这是 Android Studio 的已知问题(我在最新的稳定 AS 上运行:)Android Studio Bumblebee | 2021.1.1
,还是在该 XML 中设置不正确?
谢谢你的帮助。