jeziellago / compose-markdown

Markdown Text for Android Jetpack Compose 📋.
MIT License
568 stars 48 forks source link

Respect line height in typography style that is passed in. Also use correct SP unit for text size. #51

Closed aphexcx closed 1 year ago

aphexcx commented 1 year ago

Closes #17 and closes #41 respectively.

Only supports line height specified in SP, not EM. I wasn't sure of the correct calculation to apply for EMs -- I read https://stackoverflow.com/questions/69311233/android-compose-has-textsize-unit-em but that may be out of scope for this PR. Regardless, I tested this and it works great:

val appTypography = Typography(
...
    bodyMedium = TextStyle(
        fontFamily = appFontFamily,
        fontWeight = FontWeight.W400,
        fontSize = 16.sp,
        lineHeight = 24.sp,
    ),
...
)

MarkdownText(
        markdown = message.content,
        fontResource = R.font.soehne_buch,
        style = typography.bodyMedium // line height of 24sp is now respected
    )    
jeziellago commented 1 year ago

Hi, @aphexcx! Thank you for contributing! Can you add it to the sample project? I mean, add a style with bodyMedium to show how it works.

MarkdownText(
        markdown = message.content,
        fontResource = R.font.soehne_buch,
        style = typography.bodyMedium // line height of 24sp is now respected
    )