Skip to content

Instantly share code, notes, and snippets.

@luismanson
Forked from jdbdnz/fontforge-limit-glyphs.py
Created October 24, 2019 00:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save luismanson/4086aab6177dc597459af19d59a30407 to your computer and use it in GitHub Desktop.
Limit FontAwesome to just those Glyphs I want to use
# Open font in [fontforge](https://fontforge.github.io/en-US/) (FontAwesome's [fa-solid-900.woff](https://github.com/FortAwesome/Font-Awesome/blob/master/webfonts/fa-solid-900.woff) in my case)
# So you can see what you're doing: Menu > Encoding > Compact
# ctrl+a to select all glyphs
# ctrl+. should open Execute Script
# Ensure desiredGlyphNames includes all glyphs used in app
desiredGlyphNames = ["caret-down", "caret-up", "chart-bar", "check", "chevron-down", "clipboard-list", "comments", "expand", "filter", "flask", "images", "info-circle", "layer-group", "redo", "ruler", "ruler-horizontal", "ruler-vertical", "sort-amount-down", "star", "table", "tag", "users", "video"]
font = fontforge.activeFont()
for glyph in list(font.selection.byGlyphs):
glyphNotUsed = glyph.glyphname not in desiredGlyphNames
if glyphNotUsed:
glyph.clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment