Roman Shamin Profile picture
Jul 12, 2022 24 tweets 6 min read Read on X
Hey, designers and developers, does anyone use fractional font sizes in your designs?

No? Read further to know how one simple trick can make your text look sharper, help with paddings, and perhaps even become an essential part of your design system.

#ui #ux #uiux #typography Image
First of all, why do we even use whole numbers, like 14 or 16px, for font sizes?

Because it’s comfy! We’re humans, and our brains tend to stick with simple round numbers.
However, the problem is that, in terms of real pixels, the actual visible size of the character doesn’t match the given font size value, and in most cases, this visible size doesn’t match the pixel grid.

So we end up with a text which is blurry at the top. Image
(There are reasons why these things are quite complex in fonts. We can talk about them some other time. Like this tweet if you’re interested.)
To check it in your design, first, turn on the pixel grid display. `View → Pixel Grid` in Figma, `View → Canvas → Show Pixel Grid on Zoom` in Sketch.

Then, turn on pixel preview. `View → Pixel Preview` in Figma, `View → Canvas → Show Pixels on Zoom` in Sketch. Image
And then zoom in on the text enough to see the pixels.
Don’t count on retina displays hiding this effect. The difference is noticeable even with high pixel density.

Don’t you want to provide razor-sharp text for your readers?
So, let’s get out of our comfort zone and slightly reverse the priorities!

Let’s make the height of our capital letters a round number of pixels rather than specifying a round number for the font size.
For this example I took the great Inter font by @rsms.

The text labels on the top are set for the most popular font sizes: 12, 16, and 18px. The ones on the bottom have been slightly tweaked to achieve the closest pixel-perfect height.

Just like that. Isn’t it simple? Image
Besides text sharpness, this approach brings us a few benefits.

👇
1. Since the cap height takes the whole amount of pixels, the space above the text (on a button, for example) takes the whole amount of pixels too. This makes it easier to adjust the text label’s vertical position of UI elements. Image
2. Also, if you use something like a 4px baseline grid in your design system, you can set visible font sizes according to it.

I have some more tips and tricks on that. Follow me and don’t miss anything: @romanshamin_en.
3. And, if one day you have to swap the font family for another, this new font will look the same size as the previous one.

Of course, that is, if you set its cap heights to the same size in pixels. Image
Okay, how to calculate the font size to achieve that pixel perfect cap height?

There’s a formula. If you want maximum precision and you’re ready to extract a few parameters from the font `hhea` table, just ping in DM or in replies.

But… I recommend finding it manually!
Just zoom in to see the top of the text label very closely. It must be about 6400% of the zoom option or higher.

Increase or decrease the value by 0.1 or 0.2 points in the font size text field. Then repeat with 0.01 to make the shape fit the pixel grid perfectly.

That’s it!
* * *

I know it can take time to wrap your brain around using fractional sizes. Sometimes numbers can turn out long and ugly. Don’t worry about it, browsers don’t care. And, to be honest, it’s their primary job to count numbers quickly.
Frontend developers also don’t have to constantly deal with them. They can put these values to CSS custom properties.
This little trick is just one essential part of the design system we made in @evilmartians.

Want to read more about it? Take a look at the thread of my teammate @antiflasher explaining why it’s worth having system versus not:
I mostly write about all the aspects of building design systems. Also, I’m working on creating a font family and sharing the process on my Twitter.

If you’re interested, follow me: @romanshamin_en.
Well, this is it. Try this on your next project and let me know what you think!

TL;DR

Using fractional values for your UI typography gives:
— extra text sharpness
— predictable vertical space
— advanced typography for design systems
— simpler font family swapping

🙌
P. S. Okay, since this got viral, here are some of my articles you may find interesting.

1/4

Accessible design from the get-go | evilmartians.com/chronicles/acc…
2/4

Variable fonts in real life: how to use and love them | evilmartians.com/chronicles/var…
3/4

The joy of Variable Fonts: getting started on the Frontend | evilmartians.com/chronicles/the…
4/4

Figma DIY: Building a color system plugin | evilmartians.com/chronicles/fig…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Roman Shamin

Roman Shamin Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @romanshamin_en

Sep 29, 2023
Introducing #Harmony, a new UI color palette for product designers.

Harmony combines cutting-edge color technology, providing precise UI element contrast control, extremely consistent color shades, and P3 gamut support.

It’s free and available in Figma Community.
Begin here:

You’ll discover the palette neatly organized in the “Harmony Primitives” collection. Utilize it to craft aliases for your semantic tokens and set up UI theming modes.

P. S. Keep mirrored contrast pairs in mind (we’ll delve into these later).figma.com/community/file…
So, what makes it so special?

Harmony’s primary focus is accessibility, specifically visual contrast. It’s designed to enhance control over the contrast between UI elements, which is especially useful for designing both light and dark themes.

Let’s dive into features! This image spoofs how Apple represents the features of their products using a bento layout
Read 27 tweets
Aug 25, 2022
The vertical metrics of the Martian Grotesk and Mono typeface family are one reason they work great in UIs.

In this thread, I explain how “equal” metrics—metrics that lead to equal space above and below the text—can make digital design and development easier.

#uiux #typography Text “Vertical metrics in U...
In a line of text, every letter has its own visible shape and size. However, when we implement a line of text with HTML/CSS in the browser, or by using text labels in XCode, we’re actually working with the invisible rectangular area around it.

This area is called a bounding box. Two texts “Halg”, the one o...
Even if you’re not a designer or a developer, you might notice this box when making slides in Apple Keynote, MS Powerpoint, or Google Slides. When selecting text objects we see the transform box around them; in most cases, this box corresponds to the bounding box. The images displays how tex...
Read 34 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(