Behind the scenes, Coldtype uses the Skia library to rasterize two-dimensional vectors. But what if we want to rasterize three-dimensional graphics? One very fun option is to use Blender.

Because Blender has an incredible Python API, it’s not too difficult to use it programmatically — i.e. to write a normal Coldtype script, mark a few things (with metadata specific to Blender), and then let Blender & Coldtype take care of the translation to three dimensions. Here’s an example:

from coldtype import *
from coldtype.blender import *

fnt = Font.Find("SwearCilatiVariable")

def varfont(f):
    return (Glyphwise("Vari", lambda g:
        Style(fnt, 325,
            opsz=f.adj(-g.i*5).e("seio", 1, rng=(0.98, 0)),
            wght=f.adj(-g.i*15).e("seio", 1, rng=(0.98, 0))
        .pmap(lambda i, p: p
            .ch(b3d(lambda bp: bp
                    .e("ceio", 1, rng=(0.015, 3)))))))

But before you can begin, you’ll need to install Coldtype using the python bundled with Blender.


Installing packages in Blender requires locating the bundled python binary included with Blender itself. The path to this binary varies based on the version of Blender you have installed, but should look something like this on Mac:


And this on Windows (if you’re using a forward-slash prompt like git bash, which I would recommend for futzing with Python command line stuff):

/c/Program Files/Blender Foundation/Blender/2.93/python/bin/python.exe

The 2.93 and the 3.9 might be different depending on your installation.

On my computer, I’ve aliased that path to something I call b3d_python, so there’s a line like this in my ~/.bash_profile:

alias b3d_python='/Applications/'

I also have a line to address the Blender executable itself:

alias b3d='/Applications/'

This is useful because when you’re running Python scripts in Blender on Mac, you need to start Blender from the command-line, in order to see errors and logs generated by the Python. If you start Python from the GUI Application in your Applications folder, you’ll be unable to see anything printed or thrown from your script.

Once you have all that out of the way, you can pip install things using that executable, like so:

b3d_python -m pip install "coldtype[viewer]"

Or if you’d like to skip the b3d_python aliasing part on Windows:

/c/Program Files/Blender Foundation/Blender/2.93/python/bin/python.exe -m pip install "coldtype[viewer]"

Running Code in Blender

To get a Blender window to show up, all you need to do is use the @b3d_animation decorator in place of the standard @animation decorator, and add -bw 1 to the command-line invocation. Or, if you want a set of sensible CLI defaults, try -p b3d instead, which stands for --profile=b3d and sets -bw 1 as part of some other settings in the b3d profile.

So, to use an example from the Coldtype repo, you could run:

coldtype examples/blender/ -p b3d

This should launch both a standard Coldtype window (with a 2D Skia render) and a Blender GUI window, which should automatically render the same thing as the 2D window, except in 3D. Put another way: you do not need to open Blender yourself, since Coldtype launches it as a background process (necessary to connect the live-code-reloading part of Coldtype to Blender). To quit both Coldtype and Blender, just hit ctrl-c in the terminal.

What’s different in Blender is that the contents of the scene aren’t re-created from scratch every time you render; instead, you annotate specific elements in your returned result, then those annotated results are displayed in Blender, as persistent objects. This means you can use Blender in a hybrid fashion, creating objects using the GUI, saving the file, and then re-saving your Coldtype source file for automatic updates in Blender itself. (It also means you might need to periodically delete some things that Coldtype creates in Blender, if you no longer want those things to exist and the Coldtype program no longer references them.)

Here’s a short video demonstrating what’s being described above (all of which is now part of the released public Coldtype (despite what the tweet says)):


If you’ve attempted to install Coldtype into Blender but are seeing an error about Python.h, you’ll need to download the Python 3.9.2 source tarball, unzip it, then manually copy the files in the python Include folder into the blender embedded python /Applications/ folder. (This requires Blender 2.93 or 2.93.2)