Skip to content

Commit

Permalink
fix: set variable tables on build
Browse files Browse the repository at this point in the history
  • Loading branch information
mishamyrt committed May 11, 2024
1 parent cf15723 commit 63eeec8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
## Fixed

* Combs alignment. (`ỐỔỖǪǫ`, `Ḩḩ`, `ẲẴẤẨẢ`, `ỂỄ`)
* Variable "Thin" variant.
* Variable tables.

## [2.510] — May 10, 2024

Expand Down
19 changes: 13 additions & 6 deletions scripts/builder/make.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Make helpers"""
import subprocess as sp
from os import listdir, unlink
from shutil import move, which
from os import listdir
from shutil import which

STAT_CONFIG = 'STAT.yaml'
VARIABLE_SUFFIX = '[wght]'

def _run(*args: str) -> bool:
with sp.Popen(" ".join(args), shell=True, stdout=sp.PIPE) as child:
Expand All @@ -27,11 +28,18 @@ def _gftools(subcommand: str, *args: str) -> bool:

def _fix_variable(font_dir, family_name) -> bool:
"""Generate STAT table for variable ttf"""
file_path = f'{font_dir}/{family_name}{VARIABLE_SUFFIX}.ttf'
return _gftools(
"fix-font",
"--include-source-fixes",
f'--out "{file_path}"',
f'"{file_path}"'
) and _gftools(
"gen-stat",
"--inplace",
f'--src "{STAT_CONFIG}"',
f'"{font_dir}/{family_name}.ttf"')
f'"{file_path}"'
)

def _fix_ttf(font_dir, _) -> bool:
"""Fix bold fsSelection and macStyle"""
Expand All @@ -42,12 +50,11 @@ def _fix_ttf(font_dir, _) -> bool:
success = _gftools(
"fix-font",
"--include-source-fixes",
f'--out "{file_path}"',
file_path
)
if not success:
return False
unlink(file_path)
move(f'{file_path}.fix', file_path)
return True

POST_FIXES = {
Expand All @@ -66,7 +73,7 @@ def make(family_name: str, ds_path: str, fmt: str, out_dir: str) -> bool:
"--filter DecomposeTransformedComponentsFilter"
]
if fmt == "variable":
cmd.append(f'--output-path "{out_dir}/{family_name}.ttf"')
cmd.append(f'--output-path "{out_dir}/{family_name}{VARIABLE_SUFFIX}.ttf"')
else:
cmd.append("--interpolate")
cmd.append(f'--output-dir "{out_dir}"')
Expand Down

0 comments on commit 63eeec8

Please sign in to comment.