Skip to content
Source Chapter Two. Gradients

Chapter Three. Fonts

Historically, Roboto was hardcoded everywhere in our project. Now, instead of it, two new typefaces appeared: one for headings, another for everything else. It would seem not much has changed. You just put the typeface file in resources and change the typefaces in Typography from the Compose theme. Well, that's what I thought, at least.

I downloaded variable font files from Google Fonts, added them, specified them in the theme. And I see that everything has stuck together, letter spacing is less than needed, line height is wrong, letter weight is also off. Started debugging, made Compose previews for all weights from 100 to 1000 on top of the Figma layout and realized that the variable font just doesn't work. I mean, how doesn't it work - it works, but only as Regular (up to 500) and as Bold (above 500). Along the way, all other typeface parameters are applied incorrectly.

After that, I found a warning in the documentation that "Variable fonts are only supported on Android O and above", my fears began to be confirmed, but, by the way, even on the latest Android 15 on a Pixel, nothing works for me.

Didn't dig further. Decided to just put ready-made typefaces as separate files like in the good old days. It worked fine, a miracle. In general, the standard conclusion: the dumber, the better. Maybe there's something wrong with these specific TTF files, but if I were betting money, I'd bet on Android and tool quirks.

This is all, as you understand, about Compose. And who's going to fix XML screens? We go create XML resources with font-family, specify them in the XML theme. And naturally, the realization comes that now you need to go through all layouts and styles, remove the hardcoded link to Roboto at least in favor of sans-serif, sans-serif-medium, etc. Nobody assumed this could happen when they were laying things out.

In the end, everything works in XML too. But with one typeface. The one that was intended for all basic fonts. We gave up on the second one (for headings) with design approval in favor of deadlines. Because it won't get worse, XML screens already look much worse than Compose ones, since there's actually no design system there. And I'm scared to even imagine the amount of work to set the right fonts for all headings in all legacy layouts. Nobody has touched these XMLs for years and everyone hopes they'll be thrown out or rewritten. But they're more alive than all the living.

The simplest task, it would seem...