Creating an Apple color font (sbix)

Tutorial
by Rainer Erich Scheichelbauer

20 July 2022 Published on 30 October 2014

Ever wondered how those Emoji fonts work on the Mac and the iPhone? The pictures are nothing but colored bitmap images embedded in the font.

In ‘Apple-style’ color fonts, bitmap images are embedded in a so-called sbix table inside the font file. Multiple images at various sizes can be assigned to each glyph. Thus, the device displaying it can pick the most appropriate resolution.

Prepare size variations

Usually, sbix fonts make use of Portable Network Graphic (PNG) format. JPEG and TIFF also work fine. Apple’s original specification even allowed for PDFs, but they are not supported by iOS or macOS, and PDF has officially been dropped from the OpenType specification. Whichever format we choose, we need to prepare those images outside of Glyphs.

Let’s say I want to take the Glyphs icon and put it into the uppercase G of a font. It is a good idea to prepare image files at several resolutions in an image editing application like Pixelmator or Preview. If you already have the pictures, then all you need to do is produce the size variations. Note that simple downscaling can even be done with an Automator workflow, which can be triggered via the contextual menu in Finder, when installed as an OS X service.

In any event, we strongly recommend to keep your images in a subfolder next to the .glyphs file. That is because Glyphs only stores their relative path in the file, not the binary itself.

Of course, whenever you move your .glyphs file, move the subfolder along with it. Otherwise, you risk Glyphs complaining about missing image files. Should that happen to you, you may find the Set New Path for Images script useful. Find it in the Images submenu in the mekkablue scripts.

Set the width

Now, let’s start Glyphs and create a new font. I bring up my uppercase G and change its width. The master layer is only for determining the metrics of the glyph, and will stay empty. The width should reflect the ratio of the image in relationship to the Units Per Em (UPM). You can check on your UPM value in File > Font Info > Font.

In my case, I set its width to 1000, because my icon is square and my UPM is 1000, the recommended value for CFF OpenType Fonts and the app default in Glyphs. If your graphic is only half as wide as it is high, set it to half its UPM, i.e. 500. If it is twice as wide, set it to 2000. You get the idea.

Create ‘iColor’ layers

Now, with the G still open, open the Palette (Window > Palette, Cmd-Opt-P), and go to the Layers section. Select your Regular master, and create a new layer by clicking the plus button. A backup layer will appear, named after the current date and time. Now right click the layer and turn it into an iColor layer:

The layer is renamed to iColor 128 and displayed in bold type, indicating that it is recgnized as a special layer. Then double click the layer name to set the intended resolution:

The rest is easy. Simply drag the PNG files from the Finder into the respective iColor layers. If you have done everything right, your setup could look similar to this:

The width of the iColor sublayers, as well as any image manipulations (scaling or placement), will be ignored. So, you do not need to bother to readjust the PNGs in the glyph metrics.

Controlling width, scale and position

Both the width and the vertical position if the image are controlled through the master layer, i.e., the Regular layer in the examples above.

The position of the image is set to the origin of the bounds of the master layer, and defaults to the layer origin (coordinates 0, 0). So, for example, if you want to move the image 100 units below the baseline, you add a tiny, tiny path at y=−100, approximately like this:

It can be a closed two-node path without any expansion, so it stays invisible. Its only function is to provide an origin point for the image, and such a mini path serves the function already. This works for horizontal displacement as well: just move the path away from x=0.

The advance width of the glyph is inherited from the master layer as well, and can only be controlled by setting the width of the master layer.

The scale of the image is controlled by the number written in the layer name, after iColor. Technically, that number is the number of image pixels which correspond to the em, or in other words, to the font size.

So, if your image is 500 pixels high and placed on a layer called iColor 500, but appears too small for your liking, try using a smaller number in the layer name, e.g., iColor 450. That way, 450 pixels make up the em (the font size), and a 500-pixel image will be larger than the font size by a ninth.

Vertical metrics

One piece of advice about vertical metrics: to prevent clipping of your sbix pictures on Apple devices, make sure your hhea values encompass the images completely. Usually, the only problematic value in this respect is the hheaAscender, make sure it lies above the top edge of your images. Read more about how to set vertical metrics.

Export

Now when you go to File > Export, pick OTF, TTF or any Webfont format as export format. Glyphs will create a font containing the sbix table. Have fun! You can test, e.g., with the free TextPreview:

Equivalent SVG table

You can increase the reach of (and support for) your bitmap font by adding an SBIX to SVG parameter in an instance in File > Font Info > Exports. As value, you use the preferred pixel size:

Then the corresponding iColor layers will be duplicated into an SVG table. (Read more about SVG fonts.) In other words, the same bitmap images will be in two OpenType tables, SVG and sbix. What’s more, you can control export or non-export of sbix and SVG tables with Export SVG Table and Export sbix Table. That way, you can produce an sbix-only, an SVG-only and a hybrid sbix/SVG font.

sbix in Photoshop

The latest versions of Photoshop CC can display sbix fonts as well. But for sbix to work in Photoshop, these three criteria must be fulfilled:

  1. The sbix glyphs must contain outlines as well, even if it is only two tiny paths. They define the cropping bounding box in Photoshop. If there are no outlines, everything is cropped, and you do not see your pixel image.
  2. The font must be installed in the system (e.g., in FontBook). The Adobe Fonts folder will not do. We recommend to use different names every time you export in order to avoid font cache problems.
  3. After each font installation, you must restart Photoshop for the sbix fonts to be recognized.

Support for sbix

Besides Apple devices, sbix fonts are supported and displayed on Windows versions 10 and later, as well as Linux and Android devices. The latest Chrome versions support sbix on every platform (do pay attention to the clipping issue though, see above), and Firefox displays it too, but only on Android and Linux.

Useful scripts

The mekkablue scripts contain two scripts that facilitate handling of sbix layers:

  • Color > Add sbix Images to Font: Will get all PNG, GIF, JPG files in a folder and create iColor layers with them in the current font and master. The scripts expects the following file name convention: glyphname pixelsize.suffix, for example: Adieresis 128.png.
  • Color > sbix Spacer allows you to batch-set sbix positions and glyph widths. It even has an option to insert the tiny paths for avoiding clipping:

Besides those, the mekkablue scripts in the Images submenu may come in handy, especially the aforementioned Set New Path for Images and the scripts for removing images if you want to start over.


Update 2017-08-08: added ‘sbix in Photoshop’ section, title-cased headers.
Update 2018-04-14: added the Support for sbix section, thx Behdad! Updated tutorial title.
Update 2018-11-18: added note about vertical metrics.
Update 2018-11-19: added section ‘Controlling Width, Scale and Position’, removed an outdated sentence about sbix support.
Update 2018-11-29: added warning about clipping in Chrome, updated tiny path image. added custom parameters.
Update 2018-11-30: clarified sbix to SVG. Fixed wrong screenshot.
Update 2019-01-28: correction of title ‘Support for sbix’.
Update 2021-06-20: added Useful Scripts and updated for Glyphs 3, renamed ‘Apple-style’ to ‘sbix’ wherever applicable.
Update 2022-07-20: updated title, related articles, minor formatting.