Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unable to display Chinese #15

Open
Joehzd opened this issue Jun 4, 2023 · 1 comment
Open

Unable to display Chinese #15

Joehzd opened this issue Jun 4, 2023 · 1 comment

Comments

@Joehzd
Copy link

Joehzd commented Jun 4, 2023

I am using the text component to display text, but it cannot display Chinese

20230604-103301

@naser09
Copy link

naser09 commented Aug 6, 2023

    onWasmReady {
        val fontFamily = mutableStateOf<FontFamily?>(null)
        MainScope().launch {
            val data = resource("font/NotoSansJP-Regular.ttf").readBytes()
            val font = Font("notoSansJP", data)
            val fm = FontFamily(listOf(font))
            fontFamily.value = fm
        }
        CanvasBasedWindow("Show Japanese or Chinese", canvasElementId = "ComposeTarget") {
            MaterialTheme(colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()) {
                Scaffold(
                    modifier = Modifier.fillMaxSize()
                ) {
                    DefaultFontComposable(font = fontFamily.value ?: FontFamily.Default) {
                        UIShow()
                    }
                }
            }
        }
    }
}``` 

and ```@Composable
public fun DefaultFontComposable(
    font: FontFamily,
    content: @Composable () -> Unit
) {
    CompositionLocalProvider(LocalTextStyle provides  TextStyle(fontFamily = font)){
        content()
    }
}``` this is just a workaround .. and this font in resource/font directory . i am using google font -> download then paste in font directory ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants