In this post I would like to focus on the subset command.
As the name suggests, when you subset a font file a.otf
according to a character set S,
you want to get a font file b.otf containing only the glyphs
present both in a.otf and S.
For example, a.otf might be a universal font,
containing glyphs for all Unicode codepoints,
and S might be the union of Basic Latin and CyrillicUnicode Blocks.
You want the new font b.otf to contain the glyphs of these two blocks only.
You might want to subset a given font to reduce its size
(e.g., for embedding it into an eBook or to reduce the bandwidth of your Web site)
or because you are required by the font license
(many font foundries require you to do so,
before embedding their font files into apps or documents,
so that a user cannot extract the whole font and use it later).
In the following examples I will use an OTF font,
but glyphIgo also works on TTF and WOFF fonts,
as the heavy lifting is done by the FontForge library,
which supports those formats as well.
Subsetting using EPUB files (-e switch)
If you have an EPUB eBook ebook.epub, and you want to embed
a big font file font.otf, but you only used, say, Latin characters,
you might want to subset the font in order to avoid embedding
also the Cyrillic, Greek, Math, Mahjong Tiles (yes, it exists!), etc. glyphs.
With glyphIgo you do not even need to know exactly what characters
you used: the script will compute the character set of your eBook
and use it to subset your font:
Note that, in this case, if we had used an online tool like FontSquirrel
and selected only the Latin subset, we might have failed
to remember to include the 0x20?? characters.
(Please read the Technical Notes to know the details of
how glyphIgo computes the eBook character set.)
Subsetting using Unicode ranges (-p switch)
OK, but what if you need to subset a font and
you know exactly what characters you want to keep?
In other words, you want to specify a font and one or more Unicode ranges,
and get the corresponding subset into a new font.
With glyphIgo the process is simple:
just create a UTF-8, plain text file,
containing all the characters you need,
and use the -p switch instead of -e.
For example, if you just want the union of 0-9 and A-F ranges,
you will write a file 09AF.set containing:
Then, you will specify it using the -p parameter:
Using the list command, we can check that the new font minimized.otf contains indeed:
Clearly, if you need to subset several fonts,
or several/complex character sets,
you can generate (and store) your own range files:
In this example:
the Basic Latin Unicode block includes the codepoints 0x0000..0x007F,
the Cyrillic block 0x0400..0x04FF,
and the Runic block 0x16A0..0x16FF.
If you need the hexadecimal range of a particular Unicode block,
you can find them in this file;
font.otf does not contain Runic glyphs, and hence also minimized.otf does not
(glyphIgo cannot create glyphs that are not present in the original font!);
you can also add single characters, like the horizontal ellipsis (0x2026).