UFO

There are two main ways to convert between UFO and VFB formats:

  1. using Tal Leming’s UFO Central script
  2. using FontLab’s vfb2ufo command-line tool

Using UFO Central

UFO Central is a tool with many years of service to RoboFab+FontLab users in pre-RoboFont days. It can export VFBs to UFOs and import UFOs into VFBs.

Installation

  • download the UFOCentral.py script from GitHub
  • save it inside your Library/Application Support/FontLab/Studio 5/Macros folder
  • restart FontLab
  • UFO Central will appear in the list of scripts in the Macro toolbar
FontLab’s Macro toolbar

Usage

Select UFO Central from the drop-down list in the Macro toolbar, and press the Run button. A window with several options will appear:

UFO Central dialog

The interface is simple and self-explaining. Use the Help button to get more information about each option.

Advantages / disadvantages

advantages disadvantages
  • works consistently and predictably
  • has a user-friendly interface
  • does not support hinting data (PS or TT)
  • does not export FL kerning classes
  • does not support some UFO2 features

Using vfb2ufo

vfb2ufo is a command-line conversion utility provided by FontLab. It is able to convert both ways (from VFB to UFO, and from UFO to VFB), and is available for macOS and Windows users.

Installation

The tool can be downloaded for free here.

Usage

After you have installed vfb2ufo, you can run it in Terminal:

vfb2ufo myFolder/myFont.vfb anotherFolder/myOuputFont.ufo

The destination path is optional – if it is omitted, the output files will be saved with the same name and in the same folder as the source files.

For the complete list of options, see the included documentation:

vfb2ufo -h

Calling vfb2ufo with Python

Even though vfb2ufo is a C program, you can call it with Python using the subprocess module:

from subprocess import Popen

# path to vfb2ufo on your machine
ufo2vfbLocation = "/usr/local/bin/vfb2ufo"

# path to input VFB file
vfbPath = u"/myFolder/myFont.vfb"

# path to output UFO file
ufoPath = u"/anotherFolder/myFont.ufo"

# call the vfb2ufo program
p = Popen([ufo2vfbLocation, vfbPath, ufoPath]) # "-64", etc
p.wait()

# add a note to the converted UFO
f = OpenFont(ufoPath, showInterface=False)
f.info.note = 'converted from vfb with vfb2ufo'
f.close(save=True)

Here is another example, showing how to convert a whole folder of VFBs into UFOs:

import os
from subprocess import Popen

# path to vfb2ufo on your machine
ufo2vfbLocation = "/usr/local/bin/vfb2ufo"

# path to folder with input VFBs
vfbsFolder = u"/myVFBsFolder"

# path to folder for output UFOs
ufosFolder = u"/myUFOsFolder"

# collect all VFBs in VFBs folder
vfbs = [f for f in os.listdir(vfbsFolder) if os.path.splitext(f)[-1] == '.vfb']

# batch convert VFBs to UFO
for vfb in vfbs:

    # make file paths
    vfbPath = os.path.join(vfbsFolder, vfb)
    ufoPath = os.path.join(ufosFolder, vfb.replace('.vfb', '.ufo'))

    # call the vfb2ufo program
    p = Popen([ufo2vfbLocation, vfbPath, ufoPath]) # "-64", etc
    p.wait()

    # add a note to the converted UFO
    f = OpenFont(ufoPath, showInterface=False)
    f.info.note = 'converted from vfb with vfb2ufo'
    f.close(save=True)

Advantages / disadvantages

advantages disadvantages
  • very fast
  • does not require FontLab Studio
  • supports hinting data (PS and TT)
  • supports Multiple Master VFBs
  • contains a few known bugs*
  • relatively recent project

* Some known bugs in vfb2ufo:

  • glyphs with overlapping components are decomposed
  • unnamed guidelines get corrupted
  • ghost hints are reversed
  • OT classes are not written into features (remain as groups)
Last edited on 01/09/2021