Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Android] update Font with new resource value #4864

Merged

Conversation

PhilipDukhov
Copy link
Contributor

@PhilipDukhov PhilipDukhov commented May 24, 2024

Fixes #4863

Before this update, when a new resource value was passed to org.jetbrains.compose.resources.Font composable, it kept the original value.

Test sample code. Res.font here is autogenerated from commonMain/composeResources/font/ folder content.

var flag by remember {
    mutableStateOf(false)
}
Column {
    Text(
        "hey",
        fontFamily = FontFamily(Font(if (flag) Res.font.HelveticaNeueMedium else Res.font.COMICSANS, FontWeight.Normal))
    )
    Switch(checked = flag, onCheckedChange = { flag = it })
}

Release Notes

Fixes - Resources

  • Fix a cached font if the resource acessor was changed

@terrakok terrakok self-requested a review May 27, 2024 11:46
@terrakok terrakok merged commit 0485f03 into JetBrains:master May 27, 2024
@PhilipDukhov PhilipDukhov deleted the android-fix-font-recomposition branch May 27, 2024 12:34
terrakok pushed a commit that referenced this pull request May 28, 2024
Fixes #4863

Before this update, when a new `resource` value was passed to
`org.jetbrains.compose.resources.Font` composable, it kept the original
value.

Test sample code. `Res.font` here is autogenerated from
`commonMain/composeResources/font/` folder content.
```kt
var flag by remember {
    mutableStateOf(false)
}
Column {
    Text(
        "hey",
        fontFamily = FontFamily(Font(if (flag) Res.font.HelveticaNeueMedium else Res.font.COMICSANS, FontWeight.Normal))
    )
    Switch(checked = flag, onCheckedChange = { flag = it })
}
```

## Release Notes
### Fixes - Resources
- Fix a cached font if the resource acessor was changed

(cherry picked from commit 0485f03)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Font is not updated to the new font resource
2 participants