Skip to content

Instantly share code, notes, and snippets.

@hugmanrique
Last active April 4, 2020 14:06
Embed
What would you like to do?
Font optimization
#!/bin/bash
# Required:
# fonttools, zopfli, installable via pip install.
set -e
ORIGINAL=original.otf
UNICODES_FILE=unicodes.txt
FORMATS=(woff woff2)
FEATURES=kern,rlig,calt,cv05
for format in "${FORMATS[@]}"; do
pyftsubset $ORIGINAL --unicodes-file=$UNICODES_FILE --no-ignore-missing-unicodes \
--output-file="output.$format" --flavor=$format --with-zopfli \
--layout-features=$FEATURES \
--recalc-average-width --recalc-max-context
done
# See https://www.unicode.org/ucd/ for the latest version of the Unicode Character Database.
# https://www.fileformat.info/info/unicode/block/index.htm contains a table of characters.
#
# Spanish alphabet (with accents), punctuation and Math symbols.
# Obtained from https://www.fontsquirrel.com/tools/webfont-generator (requires inspecting the `POST unicode` request)
2260,221E,00B1,2264,2265,00B5,2202,2211,220F,03C0,222B,00AA,00BA,03A9,00AC,221A,2248,2206,00F7,2044,2030,0020,0041,0042,0043,0044,0045,0046,0047,0048,0049,004A,004B,004C,004D,004E,004F,0050,0051,0052,0053,0054,0055,0056,0057,0058,0059,005A,00E1,00E9,0061,0062,0063,0064,0065,0066,0067,0068,0069,006A,006B,006C,006D,006E,006F,0070,0071,0072,0073,0074,0075,0076,0077,0078,0079,007A,00A1,00BF,00C1,00C9,00CD,00D1,00D3,00DA,00DC,00ED,00F1,00F3,00FA,00FC,0021,0022,0023,0024,0025,0026,0027,0028,0029,002A,002B,002C,002D,002E,002F,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,003A,003B,003C,003D,003E,003F,0040,005B,005C,005D,005E,005F,0060,007B,007C,007D,007E,00A2,00A3,00A5,00A8,00A9,00AB,00AE,00B4,00B8,00BB,02C6,02DA,02DC,2013,2014,2018,2019,201A,201C,201D,201E,2026,2039,203A,20AC,2122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment