mirror of
https://github.com/rsms/inter.git
synced 2024-11-28 22:13:40 +03:00
change "Display" opsz value to 32 (was 28)
This commit is contained in:
parent
70faa70bf2
commit
59063ec875
@ -27,14 +27,19 @@ from fontTools.otlLib.builder import buildStatTable
|
||||
|
||||
FLAG_DEFAULT = 0x2 # elidable value, effectively marks a location as default
|
||||
|
||||
OPSZ_MIN = 0 # set at runtime to fvar.axes['opsz'].minValue
|
||||
OPSZ_MAX = 0 # set at runtime to fvar.axes['opsz'].maxValue
|
||||
|
||||
|
||||
# stat_axes_format_2 is used for making a STAT table with format 1 & 2 records
|
||||
def stat_axes_format_2(is_italic):
|
||||
OPSZ_MID = OPSZ_MIN + int(round((OPSZ_MAX - OPSZ_MIN) / 2))
|
||||
return [
|
||||
dict(name="Optical Size", tag="opsz", ordering=0, values=[
|
||||
dict(nominalValue=14, rangeMinValue=14, rangeMaxValue=21, name="Text",
|
||||
flags=FLAG_DEFAULT, linkedValue=28),
|
||||
dict(nominalValue=28, rangeMinValue=21, rangeMaxValue=28, name="Display"),
|
||||
dict(nominalValue=OPSZ_MIN, rangeMinValue=OPSZ_MIN, rangeMaxValue=OPSZ_MID,
|
||||
name="Text", flags=FLAG_DEFAULT, linkedValue=OPSZ_MAX),
|
||||
dict(nominalValue=OPSZ_MAX, rangeMinValue=OPSZ_MID, rangeMaxValue=OPSZ_MAX,
|
||||
name="Display"),
|
||||
]),
|
||||
dict(name="Weight", tag="wght", ordering=1, values=[
|
||||
dict(nominalValue=100, rangeMinValue=100, rangeMaxValue=150, name="Thin"),
|
||||
@ -55,53 +60,53 @@ def stat_axes_format_2(is_italic):
|
||||
]
|
||||
|
||||
|
||||
# stat_axes_format_3 is used for making a STAT table with format 1 & 3 records
|
||||
def stat_axes_format_3(is_italic):
|
||||
# see https://learn.microsoft.com/en-us/typography/opentype/spec/
|
||||
# stat#axis-value-table-format-3
|
||||
suffix = " Italic" if is_italic else ""
|
||||
return [
|
||||
{ "name": "Optical Size", "tag": "opsz" },
|
||||
{ "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": 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 },
|
||||
]},
|
||||
]
|
||||
# # stat_axes_format_3 is used for making a STAT table with format 1 & 3 records
|
||||
# def stat_axes_format_3(is_italic):
|
||||
# # see https://learn.microsoft.com/en-us/typography/opentype/spec/
|
||||
# # stat#axis-value-table-format-3
|
||||
# suffix = " Italic" if is_italic else ""
|
||||
# return [
|
||||
# { "name": "Optical Size", "tag": "opsz" },
|
||||
# { "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": 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 },
|
||||
# ]},
|
||||
# ]
|
||||
|
||||
|
||||
# STAT_AXES is used for making a STAT table with format 4 records
|
||||
STAT_AXES = [
|
||||
{ "name": "Optical Size", "tag": "opsz" },
|
||||
{ "name": "Weight", "tag": "wght" },
|
||||
{ "name": "Italic", "tag": "ital" }
|
||||
]
|
||||
# # STAT_AXES is used for making a STAT table with format 4 records
|
||||
# STAT_AXES = [
|
||||
# { "name": "Optical Size", "tag": "opsz" },
|
||||
# { "name": "Weight", "tag": "wght" },
|
||||
# { "name": "Italic", "tag": "ital" }
|
||||
# ]
|
||||
|
||||
# stat_locations is used for making a STAT table with format 4 records
|
||||
def stat_locations(is_italic):
|
||||
# see https://learn.microsoft.com/en-us/typography/opentype/spec/
|
||||
# stat#axis-value-table-format-4
|
||||
ital = 1 if is_italic else 0
|
||||
suffix = " Italic" if is_italic else ""
|
||||
return [
|
||||
{ "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":FLAG_DEFAULT },
|
||||
{ "name": "Medium"+suffix, "location":{"wght":500, "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} },
|
||||
]
|
||||
# # stat_locations is used for making a STAT table with format 4 records
|
||||
# def stat_locations(is_italic):
|
||||
# # see https://learn.microsoft.com/en-us/typography/opentype/spec/
|
||||
# # stat#axis-value-table-format-4
|
||||
# ital = 1 if is_italic else 0
|
||||
# suffix = " Italic" if is_italic else ""
|
||||
# return [
|
||||
# { "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":FLAG_DEFAULT },
|
||||
# { "name": "Medium"+suffix, "location":{"wght":500, "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} },
|
||||
# ]
|
||||
|
||||
|
||||
WINDOWS_ENGLISH_IDS = 3, 1, 0x409
|
||||
@ -348,31 +353,40 @@ def main():
|
||||
args = argparser.parse_args()
|
||||
|
||||
# load font
|
||||
font = TTFont(args.input, recalcBBoxes=False, recalcTimestamp=False)
|
||||
ttfont = TTFont(args.input, recalcBBoxes=False, recalcTimestamp=False)
|
||||
|
||||
# infer axis extremes
|
||||
global OPSZ_MIN
|
||||
global OPSZ_MAX
|
||||
for a in ttfont["fvar"].axes:
|
||||
if a.axisTag == "opsz":
|
||||
OPSZ_MIN = int(a.minValue)
|
||||
OPSZ_MAX = int(a.maxValue)
|
||||
break
|
||||
|
||||
# set family name
|
||||
if not args.family:
|
||||
args.family = "Inter Variable"
|
||||
setFamilyName(font, args.family)
|
||||
setFamilyName(ttfont, args.family)
|
||||
|
||||
# set style name
|
||||
stylename = remove_substring(getStyleName(font), "Display")
|
||||
stylename = remove_substring(getStyleName(ttfont), "Display")
|
||||
if stylename == '':
|
||||
stylename = 'Regular'
|
||||
setStyleName(font, stylename)
|
||||
setStyleName(ttfont, stylename)
|
||||
|
||||
# build STAT table
|
||||
gen_stat(font)
|
||||
gen_stat(ttfont)
|
||||
|
||||
# fixup fvar table
|
||||
fixup_fvar(font)
|
||||
fixup_fvar(ttfont)
|
||||
|
||||
# # fixup OS/2 table (set usWeightClass)
|
||||
# fixup_os2(font)
|
||||
# fixup_os2(ttfont)
|
||||
|
||||
# save font
|
||||
outfile = args.output or args.input
|
||||
font.save(outfile)
|
||||
ttfont.save(outfile)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -50,14 +50,21 @@ def fixup_instance(designspace, instance):
|
||||
|
||||
|
||||
def fixup_instances(designspace):
|
||||
USE_DISPLAY_AS_DEFAULT = False
|
||||
i = len(designspace.instances)
|
||||
while i > 0:
|
||||
i -= 1
|
||||
instance = designspace.instances[i]
|
||||
if instance.name.find('Inter Display') != -1:
|
||||
fixup_instance(designspace, instance)
|
||||
if USE_DISPLAY_AS_DEFAULT:
|
||||
if instance.name.find('Inter Display') != -1:
|
||||
fixup_instance(designspace, instance)
|
||||
else:
|
||||
del designspace.instances[i]
|
||||
else:
|
||||
del designspace.instances[i]
|
||||
if instance.name.find('Inter Display') == -1:
|
||||
fixup_instance(designspace, instance)
|
||||
else:
|
||||
del designspace.instances[i]
|
||||
|
||||
|
||||
# def fixup_axes_defaults(designspace):
|
||||
|
@ -2535,8 +2535,7 @@ name = "Axis Mappings";
|
||||
value = {
|
||||
opsz = {
|
||||
14 = 14;
|
||||
22 = 25;
|
||||
28 = 28;
|
||||
32 = 32;
|
||||
};
|
||||
wght = {
|
||||
100 = 100;
|
||||
@ -3674,7 +3673,7 @@ GSOffsetVertical = 10;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
100
|
||||
);
|
||||
customParameters = (
|
||||
@ -3734,12 +3733,12 @@ size = "-16";
|
||||
name = "Axis Location";
|
||||
value = (
|
||||
{
|
||||
Axis = Weight;
|
||||
Location = 100;
|
||||
Axis = "Optical size";
|
||||
Location = 32;
|
||||
},
|
||||
{
|
||||
Axis = "Optical size";
|
||||
Location = 28;
|
||||
Axis = Weight;
|
||||
Location = 100;
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -3969,7 +3968,7 @@ GSOffsetVertical = 72;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
400
|
||||
);
|
||||
customParameters = (
|
||||
@ -4029,12 +4028,12 @@ size = "-16";
|
||||
name = "Axis Location";
|
||||
value = (
|
||||
{
|
||||
Axis = Weight;
|
||||
Location = 400;
|
||||
Axis = "Optical size";
|
||||
Location = 32;
|
||||
},
|
||||
{
|
||||
Axis = "Optical size";
|
||||
Location = 28;
|
||||
Axis = Weight;
|
||||
Location = 400;
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -4266,7 +4265,7 @@ GSOffsetVertical = 150;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
900
|
||||
);
|
||||
customParameters = (
|
||||
@ -4326,12 +4325,12 @@ size = "-16";
|
||||
name = "Axis Location";
|
||||
value = (
|
||||
{
|
||||
Axis = Weight;
|
||||
Location = 900;
|
||||
Axis = "Optical size";
|
||||
Location = 32;
|
||||
},
|
||||
{
|
||||
Axis = "Optical size";
|
||||
Location = 28;
|
||||
Axis = Weight;
|
||||
Location = 900;
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -4802,7 +4801,7 @@ weightClass = 900;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
100
|
||||
);
|
||||
customParameters = (
|
||||
@ -4858,7 +4857,7 @@ value = "Inter Display";
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
200
|
||||
);
|
||||
customParameters = (
|
||||
@ -4916,7 +4915,7 @@ weightClass = 200;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
300
|
||||
);
|
||||
customParameters = (
|
||||
@ -4974,7 +4973,7 @@ weightClass = 300;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
400
|
||||
);
|
||||
customParameters = (
|
||||
@ -5029,7 +5028,7 @@ value = Italic;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
500
|
||||
);
|
||||
customParameters = (
|
||||
@ -5087,7 +5086,7 @@ weightClass = 500;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
600
|
||||
);
|
||||
customParameters = (
|
||||
@ -5145,7 +5144,7 @@ weightClass = 600;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
700
|
||||
);
|
||||
customParameters = (
|
||||
@ -5204,7 +5203,7 @@ weightClass = 700;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
800
|
||||
);
|
||||
customParameters = (
|
||||
@ -5262,7 +5261,7 @@ weightClass = 800;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
900
|
||||
);
|
||||
customParameters = (
|
||||
|
@ -2535,8 +2535,7 @@ name = "Axis Mappings";
|
||||
value = {
|
||||
opsz = {
|
||||
14 = 14;
|
||||
22 = 25;
|
||||
28 = 28;
|
||||
32 = 32;
|
||||
};
|
||||
wght = {
|
||||
100 = 100;
|
||||
@ -3685,7 +3684,7 @@ GSOffsetVertical = 64;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
100
|
||||
);
|
||||
customParameters = (
|
||||
@ -3745,12 +3744,12 @@ size = "-16";
|
||||
name = "Axis Location";
|
||||
value = (
|
||||
{
|
||||
Axis = Weight;
|
||||
Location = 100;
|
||||
Axis = "Optical size";
|
||||
Location = 32;
|
||||
},
|
||||
{
|
||||
Axis = "Optical size";
|
||||
Location = 28;
|
||||
Axis = Weight;
|
||||
Location = 100;
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -3975,7 +3974,7 @@ GSOffsetVertical = 100;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
400
|
||||
);
|
||||
customParameters = (
|
||||
@ -4035,12 +4034,12 @@ size = "-16";
|
||||
name = "Axis Location";
|
||||
value = (
|
||||
{
|
||||
Axis = Weight;
|
||||
Location = 400;
|
||||
Axis = "Optical size";
|
||||
Location = 32;
|
||||
},
|
||||
{
|
||||
Axis = "Optical size";
|
||||
Location = 28;
|
||||
Axis = Weight;
|
||||
Location = 400;
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -4266,7 +4265,7 @@ GSOffsetVertical = 200;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
900
|
||||
);
|
||||
customParameters = (
|
||||
@ -4326,12 +4325,12 @@ size = "-16";
|
||||
name = "Axis Location";
|
||||
value = (
|
||||
{
|
||||
Axis = Weight;
|
||||
Location = 900;
|
||||
Axis = "Optical size";
|
||||
Location = 32;
|
||||
},
|
||||
{
|
||||
Axis = "Optical size";
|
||||
Location = 28;
|
||||
Axis = Weight;
|
||||
Location = 900;
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -4749,7 +4748,7 @@ weightClass = 900;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
100
|
||||
);
|
||||
customParameters = (
|
||||
@ -4800,7 +4799,7 @@ weightClass = 100;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
200
|
||||
);
|
||||
customParameters = (
|
||||
@ -4852,7 +4851,7 @@ weightClass = 200;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
300
|
||||
);
|
||||
customParameters = (
|
||||
@ -4904,7 +4903,7 @@ weightClass = 300;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
400
|
||||
);
|
||||
customParameters = (
|
||||
@ -4954,7 +4953,7 @@ value = Regular;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
500
|
||||
);
|
||||
customParameters = (
|
||||
@ -5006,7 +5005,7 @@ weightClass = 500;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
600
|
||||
);
|
||||
customParameters = (
|
||||
@ -5058,7 +5057,7 @@ weightClass = 600;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
660
|
||||
);
|
||||
customParameters = (
|
||||
@ -5112,7 +5111,7 @@ weightClass = 700;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
800
|
||||
);
|
||||
customParameters = (
|
||||
@ -5164,7 +5163,7 @@ weightClass = 800;
|
||||
},
|
||||
{
|
||||
axesValues = (
|
||||
28,
|
||||
32,
|
||||
900
|
||||
);
|
||||
customParameters = (
|
||||
|
Loading…
Reference in New Issue
Block a user