mirror of
https://github.com/rsms/inter.git
synced 2024-08-15 22:00:25 +03:00
change wght mappings, making it so that values exposed to the user are the expected ones, ie 700 for bold
This commit is contained in:
parent
0f3e57eaf1
commit
70faa70bf2
@ -8,47 +8,50 @@ This script performs the following:
|
||||
|
||||
How to debug/develop this script:
|
||||
|
||||
1. create a working dir and build the initial fonts:
|
||||
1. build the initial fonts:
|
||||
|
||||
mkdir -p build/bake
|
||||
make -j var
|
||||
|
||||
2. after making changes, run script and inspect with ttx:
|
||||
|
||||
( for a in build/fonts/var/.Inter-*.var.ttf; do
|
||||
python misc/tools/bake-vf.py "$a" -o build/bake/"$(basename "${a/.Inter/Inter}")"
|
||||
done && ttx -t STAT -i -f -s build/bake/Inter-*.ttf )
|
||||
(. build/venv/bin/activate && mkdir -p build/bake &&
|
||||
for f in build/fonts/var/.Inter-*.var.ttf; do
|
||||
python misc/tools/bake-vf.py "$f" -o build/bake/"$(basename "${f/.Inter/Inter}")"
|
||||
done)
|
||||
(. build/venv/bin/activate && ttx -t STAT -i -f -s build/bake/Inter-*.var.ttf)
|
||||
|
||||
"""
|
||||
import sys, os, os.path, re, argparse
|
||||
from fontTools.ttLib import TTFont
|
||||
from fontTools.otlLib.builder import buildStatTable
|
||||
|
||||
FLAG_DEFAULT = 0x2 # elidable value, effectively marks a location as default
|
||||
|
||||
|
||||
# stat_axes_format_2 is used for making a STAT table with format 1 & 2 records
|
||||
def stat_axes_format_2(is_italic):
|
||||
return [
|
||||
dict(name="Optical Size", tag="opsz", ordering=0, values=[
|
||||
dict(nominalValue=14, rangeMinValue=14, rangeMaxValue=21, name="Text",
|
||||
flags=0x2, linkedValue=28),
|
||||
flags=FLAG_DEFAULT, linkedValue=28),
|
||||
dict(nominalValue=28, rangeMinValue=21, rangeMaxValue=28, name="Display"),
|
||||
]),
|
||||
{ "name": "Weight", "tag": "wght", "ordering": 1, "values": [
|
||||
dict(name="Weight", tag="wght", ordering=1, values=[
|
||||
dict(nominalValue=100, rangeMinValue=100, rangeMaxValue=150, name="Thin"),
|
||||
dict(nominalValue=200, rangeMinValue=150, rangeMaxValue=250, name="ExtraLight"),
|
||||
dict(nominalValue=300, rangeMinValue=250, rangeMaxValue=350, name="Light"),
|
||||
dict(nominalValue=400, rangeMinValue=350, rangeMaxValue=450, name="Regular",
|
||||
flags=0x2, linkedValue=660),
|
||||
dict(nominalValue=500, rangeMinValue=450, rangeMaxValue=540, name="Medium"),
|
||||
dict(nominalValue=580, rangeMinValue=540, rangeMaxValue=620, name="SemiBold"),
|
||||
dict(nominalValue=660, rangeMinValue=620, rangeMaxValue=720, name="Bold"),
|
||||
dict(nominalValue=780, rangeMinValue=720, rangeMaxValue=840, name="ExtraBold"),
|
||||
dict(nominalValue=900, rangeMinValue=840, rangeMaxValue=900, name="Black"),
|
||||
] },
|
||||
{ "name": "Italic", "tag": "ital", "ordering": 2, "values": [
|
||||
dict(value=1, name="Italic") if is_italic else \
|
||||
dict(value=0, name="Roman", flags=0x2, linkedValue=1),
|
||||
] },
|
||||
flags=FLAG_DEFAULT, linkedValue=700),
|
||||
dict(nominalValue=500, rangeMinValue=450, rangeMaxValue=550, name="Medium"),
|
||||
dict(nominalValue=600, rangeMinValue=550, rangeMaxValue=650, name="SemiBold"),
|
||||
dict(nominalValue=700, rangeMinValue=650, rangeMaxValue=750, name="Bold"),
|
||||
dict(nominalValue=800, rangeMinValue=750, rangeMaxValue=850, name="ExtraBold"),
|
||||
dict(nominalValue=900, rangeMinValue=850, rangeMaxValue=900, name="Black"),
|
||||
]),
|
||||
dict(name="Italic", tag="ital", ordering=2, values=[
|
||||
dict(value=1, name="Italic") if is_italic else \
|
||||
dict(value=0, name="Roman", flags=FLAG_DEFAULT, linkedValue=1),
|
||||
]),
|
||||
]
|
||||
|
||||
|
||||
@ -62,12 +65,13 @@ def stat_axes_format_3(is_italic):
|
||||
{ "name": "Weight", "tag": "wght", "values": [
|
||||
{ "name": "Thin"+suffix, "value": 100, "linkedValue": 400 },
|
||||
{ "name": "ExtraLight"+suffix, "value": 200, "linkedValue": 500 },
|
||||
{ "name": "Light"+suffix, "value": 300, "linkedValue": 580 },
|
||||
{ "name": "Regular"+suffix, "value": 400, "linkedValue": 660, "flags":0x2 },
|
||||
{ "name": "Medium"+suffix, "value": 500, "linkedValue": 780 },
|
||||
{ "name": "SemiBold"+suffix, "value": 580, "linkedValue": 900 },
|
||||
{ "name": "Bold"+suffix, "value": 660 },
|
||||
{ "name": "ExtraBold"+suffix, "value": 780 },
|
||||
{ "name": "Light"+suffix, "value": 300, "linkedValue": 600 },
|
||||
{ "name": "Regular"+suffix, "value": 400, "linkedValue": 700,
|
||||
"flags":FLAG_DEFAULT },
|
||||
{ "name": "Medium"+suffix, "value": 500, "linkedValue": 800 },
|
||||
{ "name": "SemiBold"+suffix, "value": 600, "linkedValue": 900 },
|
||||
{ "name": "Bold"+suffix, "value": 700 },
|
||||
{ "name": "ExtraBold"+suffix, "value": 800 },
|
||||
{ "name": "Black"+suffix, "value": 900 },
|
||||
]},
|
||||
]
|
||||
@ -90,11 +94,12 @@ def stat_locations(is_italic):
|
||||
{ "name": "Thin"+suffix, "location":{"wght":100, "ital":ital} },
|
||||
{ "name": "ExtraLight"+suffix, "location":{"wght":200, "ital":ital} },
|
||||
{ "name": "Light"+suffix, "location":{"wght":300, "ital":ital} },
|
||||
{ "name": "Regular"+suffix, "location":{"wght":400, "ital":ital}, "flags":0x2 },
|
||||
{ "name": "Regular"+suffix, "location":{"wght":400, "ital":ital},
|
||||
"flags":FLAG_DEFAULT },
|
||||
{ "name": "Medium"+suffix, "location":{"wght":500, "ital":ital} },
|
||||
{ "name": "SemiBold"+suffix, "location":{"wght":580, "ital":ital} },
|
||||
{ "name": "Bold"+suffix, "location":{"wght":660, "ital":ital} },
|
||||
{ "name": "ExtraBold"+suffix, "location":{"wght":780, "ital":ital} },
|
||||
{ "name": "SemiBold"+suffix, "location":{"wght":600, "ital":ital} },
|
||||
{ "name": "Bold"+suffix, "location":{"wght":700, "ital":ital} },
|
||||
{ "name": "ExtraBold"+suffix, "location":{"wght":800, "ital":ital} },
|
||||
{ "name": "Black"+suffix, "location":{"wght":900, "ital":ital} },
|
||||
]
|
||||
|
||||
@ -313,12 +318,16 @@ def gen_stat(ttfont):
|
||||
#buildStatTable(ttfont, STAT_AXES, locations=locations)
|
||||
|
||||
|
||||
# def fixup_fvar(ttfont):
|
||||
# fvar = ttfont['fvar']
|
||||
# for a in fvar.axes:
|
||||
# if a.axisTag == "wght":
|
||||
# a.defaultValue = 400
|
||||
# break
|
||||
def fixup_fvar(ttfont):
|
||||
fvar = ttfont['fvar']
|
||||
for i in fvar.instances:
|
||||
wght = round(i.coordinates['wght'] / 100) * 100
|
||||
# print(f"wght {i.coordinates['wght']} -> {wght}")
|
||||
i.coordinates['wght'] = wght
|
||||
# for a in fvar.axes:
|
||||
# if a.axisTag == "wght":
|
||||
# a.defaultValue = 400
|
||||
# break
|
||||
|
||||
|
||||
# def fixup_os2(ttfont):
|
||||
@ -355,8 +364,8 @@ def main():
|
||||
# build STAT table
|
||||
gen_stat(font)
|
||||
|
||||
# # fixup fvar table (set default wght value)
|
||||
# fixup_fvar(font)
|
||||
# fixup fvar table
|
||||
fixup_fvar(font)
|
||||
|
||||
# # fixup OS/2 table (set usWeightClass)
|
||||
# fixup_os2(font)
|
||||
|
@ -2541,6 +2541,9 @@ opsz = {
|
||||
wght = {
|
||||
100 = 100;
|
||||
400 = 400;
|
||||
600 = 580;
|
||||
700 = 670;
|
||||
800 = 780;
|
||||
900 = 900;
|
||||
};
|
||||
};
|
||||
@ -4630,7 +4633,7 @@ weightClass = 500;
|
||||
{
|
||||
axesValues = (
|
||||
14,
|
||||
580
|
||||
600
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -4654,8 +4657,8 @@ value = "9.4";
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
"11F4534A-B963-4AB5-820F-DAF9A20CD933" = 0.64;
|
||||
"D0EC06BF-13F9-4C88-A6F5-B8203AF6C77E" = 0.36;
|
||||
"11F4534A-B963-4AB5-820F-DAF9A20CD933" = 0.6;
|
||||
"D0EC06BF-13F9-4C88-A6F5-B8203AF6C77E" = 0.4;
|
||||
};
|
||||
isItalic = 1;
|
||||
linkStyle = SemiBold;
|
||||
@ -4675,7 +4678,7 @@ weightClass = 600;
|
||||
{
|
||||
axesValues = (
|
||||
14,
|
||||
660
|
||||
700
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -4699,8 +4702,8 @@ value = (
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
"11F4534A-B963-4AB5-820F-DAF9A20CD933" = 0.48;
|
||||
"D0EC06BF-13F9-4C88-A6F5-B8203AF6C77E" = 0.52;
|
||||
"11F4534A-B963-4AB5-820F-DAF9A20CD933" = 0.4;
|
||||
"D0EC06BF-13F9-4C88-A6F5-B8203AF6C77E" = 0.6;
|
||||
};
|
||||
isBold = 1;
|
||||
isItalic = 1;
|
||||
@ -4711,7 +4714,7 @@ weightClass = 700;
|
||||
{
|
||||
axesValues = (
|
||||
14,
|
||||
780
|
||||
800
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -4735,8 +4738,8 @@ value = "9.4";
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
"11F4534A-B963-4AB5-820F-DAF9A20CD933" = 0.24;
|
||||
"D0EC06BF-13F9-4C88-A6F5-B8203AF6C77E" = 0.76;
|
||||
"11F4534A-B963-4AB5-820F-DAF9A20CD933" = 0.2;
|
||||
"D0EC06BF-13F9-4C88-A6F5-B8203AF6C77E" = 0.8;
|
||||
};
|
||||
isItalic = 1;
|
||||
linkStyle = ExtraBold;
|
||||
@ -5085,7 +5088,7 @@ weightClass = 500;
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
580
|
||||
600
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -5113,8 +5116,8 @@ value = 0;
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
m008 = 0.64;
|
||||
m010 = 0.36;
|
||||
m008 = 0.6;
|
||||
m010 = 0.4;
|
||||
};
|
||||
isItalic = 1;
|
||||
linkStyle = SemiBold;
|
||||
@ -5143,7 +5146,7 @@ weightClass = 600;
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
660
|
||||
700
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -5171,8 +5174,8 @@ value = 0;
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
m008 = 0.48;
|
||||
m010 = 0.52;
|
||||
m008 = 0.4;
|
||||
m010 = 0.6;
|
||||
};
|
||||
isBold = 1;
|
||||
isItalic = 1;
|
||||
@ -5202,7 +5205,7 @@ weightClass = 700;
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
780
|
||||
800
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -5230,8 +5233,8 @@ value = 0;
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
m008 = 0.24;
|
||||
m010 = 0.76;
|
||||
m008 = 0.2;
|
||||
m010 = 0.8;
|
||||
};
|
||||
isItalic = 1;
|
||||
linkStyle = ExtraBold;
|
||||
|
@ -2541,6 +2541,9 @@ opsz = {
|
||||
wght = {
|
||||
100 = 100;
|
||||
400 = 400;
|
||||
600 = 580;
|
||||
700 = 670;
|
||||
800 = 780;
|
||||
900 = 900;
|
||||
};
|
||||
};
|
||||
@ -4600,7 +4603,7 @@ weightClass = 500;
|
||||
{
|
||||
axesValues = (
|
||||
14,
|
||||
580
|
||||
600
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -4620,8 +4623,8 @@ value = (
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
"5C20EF92-B63D-42A8-8878-93C2863E0093" = 0.36;
|
||||
"C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265" = 0.64;
|
||||
"5C20EF92-B63D-42A8-8878-93C2863E0093" = 0.4;
|
||||
"C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265" = 0.6;
|
||||
};
|
||||
name = SemiBold;
|
||||
properties = (
|
||||
@ -4670,7 +4673,7 @@ weightClass = 700;
|
||||
{
|
||||
axesValues = (
|
||||
14,
|
||||
780
|
||||
800
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -4690,8 +4693,8 @@ value = (
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
"5C20EF92-B63D-42A8-8878-93C2863E0093" = 0.76;
|
||||
"C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265" = 0.24;
|
||||
"5C20EF92-B63D-42A8-8878-93C2863E0093" = 0.8;
|
||||
"C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265" = 0.2;
|
||||
};
|
||||
name = ExtraBold;
|
||||
properties = (
|
||||
@ -5004,7 +5007,7 @@ weightClass = 500;
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
580
|
||||
600
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -5028,8 +5031,8 @@ value = 0;
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
m007 = 0.64;
|
||||
m009 = 0.36;
|
||||
m007 = 0.6;
|
||||
m009 = 0.4;
|
||||
};
|
||||
name = SemiBold;
|
||||
properties = (
|
||||
@ -5110,7 +5113,7 @@ weightClass = 700;
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
780
|
||||
800
|
||||
);
|
||||
customParameters = (
|
||||
{
|
||||
@ -5134,8 +5137,8 @@ value = 0;
|
||||
}
|
||||
);
|
||||
instanceInterpolations = {
|
||||
m007 = 0.24;
|
||||
m009 = 0.76;
|
||||
m007 = 0.2;
|
||||
m009 = 0.8;
|
||||
};
|
||||
name = ExtraBold;
|
||||
properties = (
|
||||
|
Loading…
Reference in New Issue
Block a user