
Simplifies loading variable TTF fonts with different weights from a single file, enhancing text rendering flexibility. Utilizes JetBrains Skia API on JVM and handles font variations on Android.
Make loading differently weighted fonts from one .ttf file easier. Hopefully this will be supported in Compose Multiplatform natively sometime in the future.
composeResources/font.val fontFamily by loadFont(Res.font.your_font, FontWeight(500))Text("The quick brown fox jumps over the lazy dog", fontFamily = fontFamily)val commonMain by getting {
dependencies {
implementation("com.dshatz.compose-mpp:compose-font:<version>")
}
}On JVM, jetbrains skia api is used.
On Android, the font will be written to app filesDir once and then loaded into memory and copied with variationSettings whenever the fontWeight changes.
Unfortunately there is no way to directly load a font on android from composeResources/ folder while also applying variationSettings.
Merge requests welcome, especially for adding iOS support.
Make loading differently weighted fonts from one .ttf file easier. Hopefully this will be supported in Compose Multiplatform natively sometime in the future.
composeResources/font.val fontFamily by loadFont(Res.font.your_font, FontWeight(500))Text("The quick brown fox jumps over the lazy dog", fontFamily = fontFamily)val commonMain by getting {
dependencies {
implementation("com.dshatz.compose-mpp:compose-font:<version>")
}
}On JVM, jetbrains skia api is used.
On Android, the font will be written to app filesDir once and then loaded into memory and copied with variationSettings whenever the fontWeight changes.
Unfortunately there is no way to directly load a font on android from composeResources/ folder while also applying variationSettings.
Merge requests welcome, especially for adding iOS support.