mirror of
https://github.com/rsms/inter.git
synced 2024-11-15 19:47:47 +01:00
tools/bake-vf.py: exit with error if fvar table has unexpected values
This commit is contained in:
parent
c0c503302a
commit
f054332d55
1 changed files with 10 additions and 5 deletions
|
@ -331,14 +331,16 @@ def gen_stat(ttfont):
|
||||||
|
|
||||||
def check_fvar(ttfont):
|
def check_fvar(ttfont):
|
||||||
fvar = ttfont['fvar']
|
fvar = ttfont['fvar']
|
||||||
error = False
|
ok = True
|
||||||
for i in fvar.instances:
|
for i in fvar.instances:
|
||||||
actual_wght = i.coordinates['wght']
|
actual_wght = i.coordinates['wght']
|
||||||
expected_wght = round(actual_wght / 100) * 100
|
expected_wght = round(actual_wght / 100) * 100
|
||||||
if expected_wght != actual_wght:
|
if expected_wght != actual_wght:
|
||||||
print(f"unexpected wght {actual_wght} (expected {expected_wght})",
|
print(f"BAD wght {actual_wght} (expected {expected_wght})", i.coordinates)
|
||||||
ttfont, i.coordinates)
|
ok = False
|
||||||
error = True
|
# else:
|
||||||
|
# print(f"OK wght {actual_wght}", i.coordinates)
|
||||||
|
return ok
|
||||||
|
|
||||||
|
|
||||||
# def fixup_fvar(ttfont):
|
# def fixup_fvar(ttfont):
|
||||||
|
@ -372,6 +374,8 @@ def main():
|
||||||
|
|
||||||
# load font
|
# load font
|
||||||
ttfont = TTFont(args.input, recalcBBoxes=False, recalcTimestamp=False)
|
ttfont = TTFont(args.input, recalcBBoxes=False, recalcTimestamp=False)
|
||||||
|
if not check_fvar(ttfont):
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# infer axis extremes
|
# infer axis extremes
|
||||||
global OPSZ_MIN
|
global OPSZ_MIN
|
||||||
|
@ -397,7 +401,8 @@ def main():
|
||||||
gen_stat(ttfont)
|
gen_stat(ttfont)
|
||||||
|
|
||||||
# check fvar table
|
# check fvar table
|
||||||
check_fvar(ttfont)
|
if not check_fvar(ttfont):
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# # fixup OS/2 table (set usWeightClass)
|
# # fixup OS/2 table (set usWeightClass)
|
||||||
# fixup_os2(ttfont)
|
# fixup_os2(ttfont)
|
||||||
|
|
Loading…
Reference in a new issue