Connect with us

Code

VFont – iOS Variable Font Integration

VFont is a brilliant library which simplifies working with variable fonts in iOS projects.

If you’ve never heard about variable fonts, I’d recommend reading this article Variable fonts in real life: how to use and love them by @romashamin

What does the VFont make easier?

First of all, I wondered if variable fonts are supported in iOS. Nowadays, developers use the top-level UIFont class to work individually with Light, Regular, Medium, Bold, and other font styles. I discovered that VF support had already been added in iOS 3.2. However, it was implemented using low level code in the CTFont class in the CoreText library. This leads to extra work in order to get to variable fonts using CoreText and UIFont.

VFont usage

First, you need to add the custom variable font to your project. If you’ve never done this, I recommend reading this tutorial.

exclamation Be aware that the font file name can be different from the actual font name! To get the correct full font name, upload the font file to fontgauntlet.com.

Native instruments

// First, you have to get information about the variable font (axes names, IDs, and allowed values). But the current axis value isn't there 

Advertisement

Trending