File: __main__.py

package info (click to toggle)
python-notobuilder 0%2B20250929-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 192 kB
  • sloc: python: 682; makefile: 9; sh: 1
file content (60 lines) | stat: -rw-r--r-- 1,598 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from glob import glob
import os
import sys
import subprocess

exit_status = 0

os.makedirs("out/fontspector", exist_ok=True)
families = [os.path.basename(x) for x in glob("fonts/*")]


def do_one_run(profile, output, inputs):
    if not inputs:
        return 0
    config = []
    if os.path.exists("fontspector.yml"):
        config = ["--config", "fontspector.yml"]
    args = [
        "fontspector",
        "--profile", "googlefonts",
        *config,
        "--full-lists",
        "-l",
        "warn",
        "--succinct",
        "--badges",
        "out/badges",
        "--html",
        f"out/fontspector/notofonts-{output}-report.html",
        "--ghmarkdown",
        f"out/fontspector/notofonts-{output}-report.md",
        *inputs,
    ]
    args = " ".join(args)
    return subprocess.run(
        args,
        shell=True,
    ).returncode


def run_fontspector(family):
    local_exit_status = 0
    #unhinted_outputs = glob(f"fonts/{family}/unhinted/ttf/*.ttf")
    #hinted_outputs = glob(f"fonts/{family}/hinted/ttf/*.ttf")

    gf_outputs = glob(f"fonts/{family}/googlefonts/variable-ttf/*.ttf")
    if not gf_outputs:
        gf_outputs = glob(f"fonts/{family}/googlefonts/ttf/*.ttf")

    #local_exit_status |= do_one_run("notofonts", f"{family}-unhinted", unhinted_outputs)
    #local_exit_status |= do_one_run("notofonts", f"{family}-hinted", hinted_outputs)

    local_exit_status |= do_one_run("googlefonts", f"{family}-googlefonts", gf_outputs)
    return local_exit_status


for family in families:
    exit_status |= run_fontspector(family)

sys.exit(exit_status)