top of page
Writer's pictureUdit Khandelwal

Lining and Oldstyle Numbers for Webfonts

Updated: Oct 4, 2023

Oldstyle Numbers – The Necessary Evil

Numbers (or figures) in most of the typefaces are sized, positioned and treated equal to the uppercase letters. Because of this, they stand-out and look ugly when used in paragraphs, as paragraphs are mostly in a mixed case. Look at how 4,23,498 stands out from rest of the characters here dues to it’s height.


The problem becomes more evident when your font-size increases and you use numbers like 4,23,498 in such paragraphs even when you don’t want your numbers to stand out.

So, a lot of typefaces, take special care to provide an alternate set of numbers, that blend in nicely in paragraphs. These are called oldstyle figures, and they have varying heights and alignments, as opposed to lining figures, which are of uniform height and alignment. They blend in with lowercase, as they have the same x-height, and also have ascenders and descenders. Example below shows the stark difference between lining and oldstyle figures of the typeface ‘Playfair Display’.

Oldstyle-01

The Design Problem: Oldstyle Doesn’t Work Everywhere

So now, you’ve got a great typeface that gives you amazing oldstyle numbers. But the problem is, oldstyle isn’t appropriate at all places. Places where numbers stand alone or where you needs them to be aligned, oldstyle looks jarring and ugly. Take a look at the examples below. In version A, I’m using oldstyle only (which is default). While that works for the title, it looks a bit too distracting for the price and sizes. Hence, in version B, while I retained the oldstyle for title, I switched to lining for price and sizes, getting  perfect alignment.



A. Oldstyle Only

Mob-Oldstyle-01

B. Oldstyle + Lining

Mob-Oldstyle-02

The Wrong Implementation: CSS

Now in typefaces like Playfair Display, oldstyle figures are default, which would mean you’d need an overriding CSS to be able to use lining numbers. That should be easy, right? Right. And it would work on all the browsers, right? Wrong! Let’s take a look at the CSS which is supposed to solve this:

.lnum {
font-variant-numeric: lining-nums;
-moz-font-feature-settings: "lnum" 1;
-moz-font-feature-settings: "lnum=1";
-ms-font-feature-settings: "lnum" 1;
-o-font-feature-settings: "lnum" 1;
-webkit-font-feature-settings: "lnum" 1;
font-feature-settings: "lnum" 1;
}

Apply this class to elements you wish to show lining numbers for. And this is what you’d expect to see on all the browsers (at  least I did, while I was looking for a solution):

css-lining

But, to break your heart, it doesn’t work on a lot of platforms. Here is a list of supported browsers for lining numbers. It’s a shame, I know. So what do you do? Modify the font file, provided you have the license to do so.

The Right Solution: Modify The Font File

Fontsquirrel provides this amazing tool called Webfont Generator that allows you to modify licensed webfonts and create your own font files from them. So what I’m suggesting here is, use this tool to strip off the oldstyle numbers and keep lining numbers as default. Then download the font and use it as a webfont hosted on a CDN or on your own server. Here is a step by step process to do this:

  1. Open Webfont Generator

  2. Select expert mode

  3. Upload your Webfonts

  4. Override the following attributes to set them as follows

  5. Truetype Hinting: TTFAutoHint

  6. Opentype Flattening: Check Lining Numerals

  7. Provide desired font name suffix (eg. oldstyle or lining)

  8. Download the fonts

  9. Upload the downloaded webfonts to your server

  10. Use them as demonstrated in downloaded demo files

I know, that’s a lot of work just to get aligned numbers, but trust me, it pays back well!

Resources

320 views

Related Posts

See All

Comments


This Post Features

Explore more Insights

Explore more insightful posts and stay updated with the latest trends and tips.

bottom of page