Making a color font


A color font lets glyphs carry their own colors—emoji are the most familiar example. OpenType has four color formats: COLR/CPAL, which describes glyphs with layers and palettes; OpenType-SVG, which embeds vector images; and sbix and CBDT/CBLC, which embed bitmaps.

W3C’s CSS Fonts Module Level 4 describes color fonts like this:

Color fonts allow for font files to describe, not just the contours describing the edges of glyphs, but also the colors present inside the glyphs.

——W3C, CSS Fonts Module Level 4 › Color Font Support

In other words, besides contours, the font file records the colors inside each glyph. In the OpenType spec, the COLR table defines how glyphs are rendered in color, and the CPAL table stores one or more palettes. On the web, the CSS font-palette property switches between palettes.

This tutorial uses the grinning face emoji (U+1F600) to walk through building a color font in fontion, from palette to export. For the history of each format and how they differ, see the TwinType blog post A Rainbow of Type: Color Fonts (in Chinese).

  1. Add a glyph
  2. Create a palette and choose which color tables to export
  3. Create color layers
  4. Draw on each layer
  5. Preview
  6. Export

Key concepts

Term Description
Palette A list of colors shared by the whole font. Each color has an index (0, 1, 2…)
Color layer A layer in a glyph mapped to one palette color. Named COLR_NN, where NN is the color index
Draft layer A layer with no color assigned yet. Not exported
Master layer The monochrome contours. On export, the monochrome contours are automatically the union of all color layers

Layers are listed top to bottom; the higher a layer is in the list, the further back it is drawn.

Add a glyph

In the add-glyph field on the Glyphs overview, enter U+1F600 and click + Add glyph. For creating a new font, see Making a variable font.

Glyphs overview

Create a palette

  1. Open Font Info and scroll down to Color font.

Color font settings

  1. Click Add palette. A default set of six colors is created.

Default palette

  1. Edit colors: click a swatch to open the color picker, or type a hex code. Click ✕ to the right of a color to delete it, or + at the top right of the palette to add one.

This example uses three colors:

Index Hex Use
0 #FFCC33 Face
1 #FF8A80 Cheeks
2 #4A2F1B Eyes and mouth

Finished palette

Choose color tables

Check the color tables to write into the font. You can check more than one.

Color table Type Supported in
COLR / CPAL Vector Windows, Chromium
SVG table Vector Firefox, Adobe
sbix Bitmap Apple
CBDT / CBLC Bitmap Android

This example checks COLR / CPAL and SVG table.

Selecting color tables

Create color layers

  1. Open the smiley’s glyph editor.

Empty glyph

  1. Under Layers on the left, click Add layer. A draft layer appears.

Draft layer

  1. Click the color dot on the right of the layer row and pick a color from the palette that pops up.

Assigning a color

  1. The layer is renamed COLR_00 and becomes a color layer.

Color layer

Layer row button Function
Color dot Assign or change the color
Eye Show or hide the layer’s underlay
✕ Delete the layer

Double-click a layer name to rename it. Renaming it to anything other than COLR_NN turns it back into a draft.

Draw the face

  1. Select the COLR_00 layer.
  2. Right-click the Rectangle tool and switch to the Ellipse tool.

Switching to the Ellipse tool

  1. Hold Shift and drag to draw a perfect circle. The contour is shown in the layer’s color.

Face

Draw the cheeks

  1. Click Add layer and choose #FF8A80 from the color dot. The layer becomes COLR_01.
  2. Select COLR_01 and draw an ellipse on each side with the Ellipse tool.

Cheeks

Draw the eyes and mouth

  1. Click Add layer and choose #4A2F1B from the color dot. The layer becomes COLR_02.
  2. Select COLR_02 and draw two eyes with the Ellipse tool.

Eyes

  1. Press P to switch to the Pen tool and draw the mouth:
    • Click at the left corner of the mouth.
    • At the lowest point of the mouth, click and drag to the right to pull out a horizontal handle.
    • Click at the right corner of the mouth.
    • Press Ctrl + E to close the path.

Drawing the mouth with the pen

You now have three color layers.

Finished smiley

Hold Space to see the result.

Fill preview

Preview

Glyph cells on the Glyphs overview show the colors directly.

Color in the Glyphs overview

Open the Preview page and paste 😀. The Color button at the bottom toggles between color and monochrome; the dots next to it are the current palette.

Text preview

Export

  1. Go back to the Glyphs overview and click Export font.
  2. Choose TTF as the format.

Export settings

  1. Click Start export. When it’s done, click the download icon in the Versions list.

Export complete

The exported file name comes from the Family Name in Font Info, so set it before exporting.

Keyboard shortcuts

Action Function
Right-click the Rectangle tool Switch between Rectangle and Ellipse
Shift + drag (Ellipse tool) Perfect circle
P Pen tool
Ctrl + E Close path
Hold Space Fill preview

For the full list, see Features & keyboard shortcuts.

Further reading