Status Update
Comments
sp...@google.com <sp...@google.com>
sp...@google.com <sp...@google.com> #2
Able to repro on API 34, Compose ToT. I shortened the repro,
Sean, could you take a peek at this? It seems like there may be a disconnect between the font changing and then not picking up the correct weight. That or something is off with the way the font is created here, but I'm not certain.
va...@gmail.com <va...@gmail.com> #3
Forgot one part of the repro, you will need the
[Deleted User] <[Deleted User]> #4
Clearly caching bug, minimal repro:
sp...@google.com <sp...@google.com> #5
private val fontWeights = listOf(100, 200, 300, 400)
private val fonts = listOf(
"Azeret" to R.font.azeret_mono,
"Roboto Mono" to R.font.roboto_mono,
)
@OptIn(ExperimentalTextApi::class)
private val fontFamilies = fonts.map { (_, resId) ->
FontFamily(
fontWeights.map { weight ->
Font(
resId = resId,
weight = FontWeight(weight),
variationSettings = FontVariation.Settings(FontVariation.weight(weight))
)
}
)
}
@Composable
fun Demo() {
Column {
FullListRepro()
// FullListOK()
}
}
@Composable
fun FullListRepro() {
Column {
fontWeights.forEach { weight ->
fonts.forEachIndexed { i, (familyName, _) ->
val fontFamily = fontFamilies[i]
val style = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight(weight),
fontSize = 40.sp
)
BasicText("$weight $familyName", style=style)
}
}
}
}
@Composable
fun FullListOK() {
Column {
fonts.forEachIndexed { i, (familyName, _) ->
fontWeights.forEach { weight ->
val fontFamily = fontFamilies[i]
val style = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight(weight),
fontSize = 40.sp
)
BasicText("$weight $familyName", style=style)
}
}
}
}
OK composable is fine, but if you switch the order you see the incorrect behavior coming from resource font loading.
va...@gmail.com <va...@gmail.com> #6
When setting the fontWeight, either in the TextStyle, or in the TextField, ... 100-300 shows same weight, 400-600 shows same weight etc ...
When setting it as FontVariation.Setting it is working correctly ...
Is this need to explicitly mention for variable fonts ?
sp...@google.com <sp...@google.com> #7
That issue is a little bit different
We don't do any draw time istantiation of font axes.
You can get the behavior you expect by defining multiple instances of the font. One for each font weight that you want to support. You can put them in a FontFamily, and then matching is done by (FontWeight, Style)
va...@gmail.com <va...@gmail.com> #8
Project: platform/frameworks/support
Branch: androidx-main
Author: Sean McQuillan <
Link:
Don't allow Paint to cache variation settings of resource fonts
Expand for full commit details
Don't allow Paint to cache variation settings of resource fonts
Prev: Loading two resource fonts with the same variation settings would cause the variation settings to not be applied to the second font.
New: Paint cache is invalidated during font load path.
Fixes: b/372044241
Test: manual of variable font demo
Relnote: "Resource fonts with the same variation settings will now avoid over-caching causing the incorrect variation settings to be applied."
Change-Id: If3dff4ea44e33b1ed80bc7fb5057923a088f1678
Files:
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/font/PlatformTypefaces.android.kt
Hash: 8ad5f10469c5a044be4fd8a90fc19c5614f61734
Date: Tue Oct 15 16:25:26 2024
sp...@google.com <sp...@google.com> #9
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.ui:ui-text:1.8.0-alpha08
androidx.compose.ui:ui-text-android:1.8.0-alpha08
androidx.compose.ui:ui-text-jvmstubs:1.8.0-alpha08
androidx.compose.ui:ui-text-linuxx64stubs:1.8.0-alpha08
Description
After running Lint I saw the following complains from Lint:
```
Incorrect icon size for `mipmap-hdpi/ic_launcher_foreground.png`: expected 72x72, but was 162x162 for /home/niklas/dev/GitHub/vanniktech/app-yatzy/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Incorrect icon size for `mipmap-mdpi/ic_launcher_foreground.png`: expected 48x48, but was 108x108 for /home/niklas/dev/GitHub/vanniktech/app-yatzy/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Incorrect icon size for `mipmap-xhdpi/ic_launcher_foreground.png`: expected 96x96, but was 216x216 for /home/niklas/dev/GitHub/vanniktech/app-yatzy/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Incorrect icon size for `mipmap-xxhdpi/ic_launcher_foreground.png`: expected 144x144, but was 324x324 for /home/niklas/dev/GitHub/vanniktech/app-yatzy/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Incorrect icon size for `mipmap-xxxhdpi/ic_launcher_foreground.png`: expected 192x192, but was 432x432 for /home/niklas/dev/GitHub/vanniktech/app-yatzy/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
```
Either the wizard is generating the images with incorrect sizes or the Lint check is using the wrong dimensions. In either case an app icon that was generated using the wizard should not be flagged by Lint.