Skip to content

Instantly share code, notes, and snippets.

@CarsonSlovoka
Last active June 21, 2021 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarsonSlovoka/c91df3517a4023e3cb5c6c093e27663e to your computer and use it in GitHub Desktop.
Save CarsonSlovoka/c91df3517a4023e3cb5c6c093e27663e to your computer and use it in GitHub Desktop.
convert TTF to Woff, Woff2,...

Install

  • pip install fontTools
  • pip install brotlicffi (woff need use it)
from fontTools.ttLib import TTFont, woff2
from pathlib import Path
sourceTTF = Path('my.ttf')
targetFormat = 'woff'
f = TTFont(sourceTTF)
f.flavor = targetFormat
f.save(Path("temp") / Path(sourceTTF.stem + '.' + targetFormat))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment