https://kotlinlang.org logo
Title
c

Cody Mikol

12/09/2021, 6:13 PM
How can I have both a
Monospace
and
SansSerif
font family set at the same time?
c

Casey Brooks

12/10/2021, 3:47 PM
As in, the two different font families used for different portions of the same
Text()
composable? You can use
AnnotatedString
with the builder DSL, or Thistle markup to abstract away that relatively-verbose API.
c

Cody Mikol

12/10/2021, 3:49 PM
Not exactly, I want a font that is both Sans Serif and Monospace
I’m rewriting a tool for authoring git commits and the diff viewer I’m writing needs to be in Monospace, but also needs to not have serifs so it is easier on the eyes
c

Casey Brooks

12/10/2021, 3:53 PM
That really doesn't make sense, as far as Font Families go. You can't just compose two fonts into one, fonts are much more complicated than that. You probably want to just find and use a custom font, Google Fonts is great resource for finding free fonts
c

Cody Mikol

12/10/2021, 3:58 PM
Thanks Casey 🙂
This will be my plan for tonight
👍 1
c

Chris Sinco [G]

12/10/2021, 9:42 PM
Yes, I’d advise using monospace fonts for the code, and then sans-serif for the UI font. They can co-exist in a UI, but will be really jarring if used in the same string token (alternating character fonts).
c

Cody Mikol

12/10/2021, 9:46 PM
See my image Chris, I want a monospaced font without serifs in my diff viewer, not alternating font styles
👍 1
c

Chris Sinco [G]

12/10/2021, 10:15 PM
Gotcha. I would maybe start here to find a monospace, sans serif font: https://www.programmingfonts.org/ Then once you find one you like, see if the font files are available for use, e.g. on Google Fonts.
Though browsing through that site, it’s hard to find a monospace font that is devoid of any serifs 🤷