What are Variable Fonts? How do I work with them in CSS?

Asked

Viewed 243 times

15

I’ve heard enough of the term Variable Fonts, and that this would be a new standard that the Web should adopt as a whole soon... I do not know if this really proceeds, but it seems that this new "format" of fonts, together with their new properties offer very interesting possibilities.

With the Variable Fonts we might have something like this:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui


But my doubts are:

  • As Variable Fonts already have a good browser support? All modern browsers accept Variable Fonts?
  • What are the new CSS properties, such as wght and wdth, that we can use to work with these fonts?
  • They offer a better performance by having multiple styles, condensed, bold, italic, all within a single file without importing multiple files, like .otf for example?
  • They offer features and typographical treatments to improve accessibility and user experience?
  • What’s the difference between a Fonte Normal and a Variable Fonts at the time of animation?

2 answers

13


Before starting it is important to know that the variable fonts are a new font format that offers a lot of flexibility in font style.

You know when you download a source from the internet there is always a font package (usually), for example, so Arial could have, Arial, Arial Black, Arial Regular and thousands of other files that you would need to import into CSS if you wanted to use. As variable fonts came to "end" this, they allow to contain multiple variations to a source in a single file, that’s right, in a single file. This allows the use of a web file that can access different font styles. Also variable fonts allow animating and transitions in font styles, which is not possible with static sources.

But anyway, now that we’ve got an idea of what it is and what the questions are for.

As Variable Fonts already have a good browser support? All modern browsers accept the Variable Fonts?

Actually the support is not yet universal, but according to the Can I Use about 76% of browsers already support variable fonts, which is very good, but remember that this value is from the date of this reply and may be outdated, so refer to this link to see if the support increased.

What are the new CSS properties like wght and wdth that we can use to work with these fonts?

  • wght: Controls the intensity of the source. The value is set with font-weight.

  • wdth: Controls the width of the font. For this we use the property font-stretch.

  • ital: Controls the intensity of italics. The value can be set with font-style.

  • opsz: Controls the optical font size. The property used is font-optical-sizing.

  • slnt: Controls the inclination of the source. The value can be set with font-style.

They offer a better performance by having several styles, Condensed, Bold, Italic, all within one file without need import multiple files type . otf for example?

Most web users want pages loaded quickly, and so does Google, who said that web pages should load in up to 2 seconds (see this article to learn more). Knowing this we are aware that the user experience is on with the loading time of a website. Soon sites that take time to allow interaction tend to have less access.

As variable fonts act in this sense, as you need a file are less data to load on the page and fewer requests, which leads to more loading speed.

But you may be wondering: but how can she upload everything together in a file?

What happens is that the variable fonts have one or more axes, each providing a variation between the different ends of a letter (bold, italic, ...). So we only need one file and not several.

They offer features and typographical treatments to improve accessibility and user experience?

For the best user experience your source should be readable, enjoyable and accessible.

The readability of a text refers to how easy the characters are to distinguish one from the other, while the pleasantness refers to how easy it is to analyze and understand the text. Finally, accessible typography involves things like ensuring that a source has sufficient contrast to the background, which benefits visually impaired users.

And the variable fonts allow a control over all these pointed elements. What provides a greater accessibility and a pleasant user experience.

What’s the difference between a Normal Font and a Variable Fonts on the fly of animation?

There is a big difference when performing an animation with a normal source and with a variable font. The "variable fonts" (literal translation) have, as already mentioned, a high flexibility, you can change the size, tilt and perform several changes in a practical way. I’ll put some links in the tips section with animation examples.

Tips:

References:

  • Why is it more performatic? If you are more flexible and "everything comes together", that is, you can not only load the styles of the font you want, the trend is something less performatic. What a miracle Variable Fonts do?

  • So, you have a single file that contains all these variations (bold, italic, regular, among others). If you have worked with direct development of websites you know that we often need to import several files, for example, Roboto Light, Roboto Bold, Roboto Italic, among others to be able to apply the different types of specifications to the sources. Knowing this, at the time of loading the page would have to make several requests to the server, and this could cost time and data, as there are 3 files with different sizes. By using variable fonts you find this data.

  • This I think you understood, but what happens is that the variable fonts have one or more axes, where each one provides a variation between the different extremes of a letter (bold, italic, inclinations, everything...). You have a greater control over variations. That is the miracle of variable fonts. That’s why it only needs one file, which is usually lighter than loading multiple files to apply different styles to the same font.

  • 1

    It would be nice to comment on custom properties. In addition to the predefined axes, the author can place other arbitrary variations. All are defined by a 4-character identifier.

  • @Bacco that part of FONT FEATURES is very interesting! It has some types that give a very cool effect https://www.harbortype.com/rocher-color/ and other types to Dunbar that has some 20 font Features

  • I am waiting for FF 63 (and a little free time) to test better :D

Show 1 more comment

1

Variable Fonts - As the name implies, they are variable fonts.

There are numerous benefits to this technology, I think the main one is that it was developed by these small companies : Microsoft, Google, Apple and Adobe. A single file, more speed on delivery, faster loading...

Answering questions

Do Variable Fonts already have good browser support? All modern browsers accepted as Variable Fonts?

Speaking of desktop browser, yes! All current browsers already accept.

One remark to be made here is that IE does not accept in any version.

inserir a descrição da imagem aqui

Another problem you would have with "mobile"

What are the new CSS properties like wght and wdth that we can use to work with these fonts?

Estates:

  • Susi - we can call it "Super Size"
  • temp - we can call it "Temperature"
  • yest - hm... makes the source thicker...
  • grvt - Let’s bincar with gravity, that’s right! haha
  • DIST - we can call it "Distortion"
  • wght - we can say that this guy increases or decreases the font thickness
  • wdth - widens or tightens ... haha
  • BVEL - Depth ?
  • SHDW - Shading
  • slnt - Here you do it : TEST hahah
  • opsz - Zoom ? we also have.
  • cntr - Font contrast
  • Ital - Brother of the guy up there "slnt"
  • STLE - We modified the style

There are others but these would be the most used, you can see them working here :

I WANT TO SEE IT IN PRACTICE!

They offer better performance by having multiple styles, Condensed, Bold, Italic, all within a single file without importing multiple uncle files. otf for example?

Simple question, even simpler answer, yes! You have a performance gain by being just a binary, you can expect more speed and understanding faster.

They offer features and typographical treatments to improve accessibility and user experience?

So this part is up to you! exactly, you will control and draw the font your way, you who will dictate whether the user will have a good experience or not!

What is the difference between a Normal Font and a Variable Fonts at animation time?

Due to its large number of axes the gain is extremely remarkable compared to a normal font, and speaking of performance we will compare to a normal font ?

So here’s a brief comparison:

Roboto: twelve source files, twelve variants. Variable sources: one font file, unlimited variants. As you can already imagine, our typographical options grow incredibly with variable fonts.

References:

medium

google dev

v-font

Browser other questions tagged

You are not signed in. Login or sign up in order to post.