Zoff
04/17/2024, 12:14 PMKonstantin Tskhovrebov
04/17/2024, 12:16 PMZoff
04/17/2024, 12:40 PMIvan Matkov
04/17/2024, 2:45 PMIvan Matkov
04/17/2024, 2:47 PMcan i change it?I guess you're looking for a way to set in implicitly instead of writing the parameter for each element. It's done in component libraries like material(3) via composition locals. See
LocalTextStyle
Zoff
04/17/2024, 6:09 PMZoff
04/17/2024, 6:11 PMZoff
04/17/2024, 6:12 PMZoff
04/18/2024, 8:54 AMIvan Matkov
04/18/2024, 9:00 AMLocalTextStyle
as I wrote aboveZoff
04/18/2024, 3:19 PMIvan Matkov
04/18/2024, 3:24 PMZoff
04/18/2024, 3:25 PMZoff
04/18/2024, 3:26 PMZoff
04/18/2024, 3:26 PMZoff
04/18/2024, 3:27 PMZoff
04/18/2024, 3:28 PMIvan Matkov
04/18/2024, 3:31 PMbuildAnnotatedString
for applying different style to part of the text, but it will require some rules and knowing in advance what requires displaying with whatZoff
04/18/2024, 3:32 PMIvan Matkov
04/18/2024, 3:32 PMZoff
04/18/2024, 3:33 PMZoff
04/18/2024, 3:33 PMZoff
04/18/2024, 3:33 PMIvan Matkov
04/18/2024, 3:35 PMIvan Matkov
06/07/2024, 5:59 PMTrejkaz
07/26/2024, 1:32 AMimport androidx.compose.ui.text.font.createFontFamilyResolver
import androidx.compose.ui.text.platform.FontLoadResult
@OptIn(ExperimentalStdlibApi::class)
fun main() {
val codePoint = 0x23FE
println("Code point: 0x${codePoint.toHexString(HexFormat.UpperCase)}")
// In @Composable code you would use:
// val fontFamilyResolver = LocalFontFamilyResolver.current
val fontFamilyResolver = createFontFamilyResolver()
println("Font family resolver is: $fontFamilyResolver")
val fontFamiliesToTry = sequenceOf(NotoSans, NotoSansSymbols, NotoSansSymbols2, LastResort)
fontFamiliesToTry.forEach { fontFamily ->
println("Trying font family: $fontFamily")
val something = fontFamilyResolver.resolve(fontFamily).value
if (something is FontLoadResult) {
val skiaTypeface: org.jetbrains.skia.Typeface = checkNotNull(something.typeface)
println(" Resolved to typeface: $skiaTypeface")
val glyph = skiaTypeface.getUTF32Glyph(codePoint)
if (glyph == 0.toShort()) {
println(" Did not find glyph")
} else {
println(" Found glyph: $glyph")
}
}
}
}
Trejkaz
07/26/2024, 1:33 AMsomething
will be FontLoadResult
, but certainly on the current version, if the family is a FontListFontFamily
, you get that type always, so I guess the code works until they change the internal code in the future