#!/usr/bin/python3

import os
import subprocess

import fontforge

os.makedirs("css", exist_ok=True)
subprocess.run(
    ["sass", "scss/font-awesome.scss", "css/font-awesome.css"],
    check=True
)
subprocess.run(
    ["sass", "-t", "compressed", "scss/font-awesome.scss", "css/font-awesome.min.css"],
    check=True
)

SVG = "fonts/fontawesome-webfont.svg"
EOT = "fonts/fontawesome-webfont.eot"
TTF = "fonts/fontawesome-webfont.ttf"
WOFF = "fonts/fontawesome-webfont.woff"
WOFF2 = "fonts/fontawesome-webfont.woff2"
OTF = "fonts/FontAwesome.otf"

fa = fontforge.open(SVG)
fa.fontname = "FontAwesome"
fa.fullname = "FontAwesome"
fa.copyright = "Copyright Dave Gandy 2016. All rights reserved."
fa.version = "4.7.0"
fa.sfntRevision = 4.007
fa.os2_fstype = 0
fa.ascent = 1536
fa.descent = 256
    
for font in [TTF, WOFF, WOFF2, OTF]:
    fa.generate(font)

with open(EOT, "wb") as eot:
    subprocess.run(
        ["mkeot", TTF], stdout=eot, check=True
    )
