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 Apple device displaying it can pick the most appropriate resolution.
Prepare Size Variations
Usually, Apple-style color fonts make use of Portable Network Graphic (PNG) format. JPEG and TIFF also work fine. The specification even allows for PDFs, but they are not (yet) supported by iOS or OS X. 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.
Hint: Create at least one small variation below 100 pixels, because it can significantly boost display performance at low resolutions, especially on older devices.
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 folder in my Glyphs-Scripts repository on GitHub.
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.
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 sublayers by clicking the Copy button as often as necessary. You need as many sublayers as you have PNG files.
Rename the layers to
iColor, followed by a wordspace and a number indicating the image resolution. For instance,
iColor 128, and
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:
Important note: Some implementations (most prominently, the one in Chrome) will clip (!) the image depending on the bounding box of the master layer. So you also want to put such a tiny path at the top right of your image.
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.
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.
Equivalent SVG Table
You can increase the reach of (and support for) your bitmap font by adding an SBIX to SVG parameter in File > Font Info > Instances. 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 Apple-style color fonts as well. But for sbix to work in Photoshop, these three criteria must be fulfilled:
- 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.
- 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.
- After each font installation, you must restart Photoshop for the sbix fonts to be recognized.
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.
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.