jeziellago / compose-markdown

Markdown Text for Android Jetpack Compose 📋.
MIT License
507 stars 40 forks source link

[feat] Taking fontfamily from style if fontResource it's null #77

Closed adrifernandev closed 6 months ago

adrifernandev commented 6 months ago

If fontfamily is defined on the style that is passed by arguments, it takes it from this style, instead of having to pass the fontResource.

adrifernandev commented 6 months ago

@jeziellago

jeziellago commented 6 months ago

Hi, @adrifernandev Thank you for contributing.

Considering that compose has multiple strategies of font loading and the MarkdownText under the hood uses a TextView, my suggestion for you is to try to implement this wrapper function to translate the compose strategies into a typeface for a native TextView. https://github.com/jeziellago/compose-markdown/blob/c990cebefd72c93f1902c8941cc216bd7bb2081c/markdowntext/src/main/java/dev/jeziellago/compose/markdowntext/TextAppearanceExt.kt#L50

fun TextView.applyFontFamily(fontFamily: FontFamily) {
    when(fontFamily) {
        is SystemFontFamily -> {}
        is FontListFontFamily -> {}
        is LoadedFontFamily -> {}
    }
}