| 1 |
from glob import glob |
| 2 |
import os |
| 3 |
import sys |
| 4 |
import subprocess |
| 5 |
|
| 6 |
exit_status = 0 |
| 7 |
|
| 8 |
os.makedirs("out/fontspector", exist_ok=True) |
| 9 |
families = [os.path.basename(x) for x in glob("fonts/*")] |
| 10 |
|
| 11 |
|
| 12 |
def do_one_run(profile, output, inputs): |
| 13 |
if not inputs: |
| 14 |
return 0 |
| 15 |
config = [] |
| 16 |
if os.path.exists("fontspector.yml"): |
| 17 |
config = ["--config", "fontspector.yml"] |
| 18 |
args = [ |
| 19 |
"fontspector", |
| 20 |
"--profile", "googlefonts", |
| 21 |
*config, |
| 22 |
"--full-lists", |
| 23 |
"-l", |
| 24 |
"warn", |
| 25 |
"--succinct", |
| 26 |
"--badges", |
| 27 |
"out/badges", |
| 28 |
"--html", |
| 29 |
f"out/fontspector/notofonts-{output}-report.html", |
| 30 |
"--ghmarkdown", |
| 31 |
f"out/fontspector/notofonts-{output}-report.md", |
| 32 |
*inputs, |
| 33 |
] |
| 34 |
args = " ".join(args) |
| 35 |
return subprocess.run( |
| 36 |
args, |
| 37 |
shell=True, |
| 38 |
).returncode |
| 39 |
|
| 40 |
|
| 41 |
def run_fontspector(family): |
| 42 |
local_exit_status = 0 |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
gf_outputs = glob(f"fonts/{family}/googlefonts/variable-ttf/*.ttf") |
| 47 |
if not gf_outputs: |
| 48 |
gf_outputs = glob(f"fonts/{family}/googlefonts/ttf/*.ttf") |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
local_exit_status |= do_one_run("googlefonts", f"{family}-googlefonts", gf_outputs) |
| 54 |
return local_exit_status |
| 55 |
|
| 56 |
|
| 57 |
for family in families: |
| 58 |
exit_status |= run_fontspector(family) |
| 59 |
|
| 60 |
sys.exit(exit_status) |