I'm having an issue with a font that is offset dow...
# compose-desktop
s
I'm having an issue with a font that is offset downward for no apparent reason. I'm trying to get it vertically centered and it is shifted down outside of the
Text
composable. The same font on Android is fine and all other fonts work as expected on desktop.
Screenshot from 2024-03-27 09-55-29.png
Copy code
Box(Modifier.fillMaxWidth()) {
    Text(
        text = value,
        color = textColor,
        fontFamily = remember { getFont(MR.fonts.digitalmono_regular) },
        style = MaterialTheme.typography.displaySmall,
        maxLines = 1,
        overflow = TextOverflow.Ellipsis,
        modifier = Modifier
            .padding(8.dp)
            .align(Alignment.CenterEnd)
            .background(Color.Red)
    )
}
g
can you try setting lineHeight to the same as the text size?
s
Yes, I tried that. I don't think it's necessary when using the theme typography though.
g
I've had some really weird behavior on desktop specifically before that matching the two solved, not sure if it'd fix it for you too.
s
No, setting the line height actually made it worse.
g
Hm. Out of curiosity what happens if you set the lineheight to textsize*2? I wonder if something's not calculating correctly.
s
that was a good idea. it's off the bottom of the box. setting the lineheight to 0 puts it where it should be.
g
Yeah sounds like some math isn't mathing properly. At least you've got a workaround for now.
s
My workaround is just to ditch this font.
z
Out of curiosity, which font was it? Which font works for you? Trying to figure out if my issue is the same, it does sound like it but all the font Ive tried fail in the exact same way 🤷🏽‍♂️
s
It was this font: https://www.dafont.com/digital-7.font The default monospace font works fine.
🙏🏽 1