1
1
mirror of https://github.com/rsms/inter.git synced 2024-10-26 12:39:40 +03:00

change "Display" opsz value to 32 (was 28)

This commit is contained in:
Rasmus Andersson 2023-11-18 16:28:00 -08:00
parent 70faa70bf2
commit 59063ec875
4 changed files with 129 additions and 110 deletions

View File

@ -27,14 +27,19 @@ from fontTools.otlLib.builder import buildStatTable
FLAG_DEFAULT = 0x2 # elidable value, effectively marks a location as default 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 # stat_axes_format_2 is used for making a STAT table with format 1 & 2 records
def stat_axes_format_2(is_italic): def stat_axes_format_2(is_italic):
OPSZ_MID = OPSZ_MIN + int(round((OPSZ_MAX - OPSZ_MIN) / 2))
return [ return [
dict(name="Optical Size", tag="opsz", ordering=0, values=[ dict(name="Optical Size", tag="opsz", ordering=0, values=[
dict(nominalValue=14, rangeMinValue=14, rangeMaxValue=21, name="Text", dict(nominalValue=OPSZ_MIN, rangeMinValue=OPSZ_MIN, rangeMaxValue=OPSZ_MID,
flags=FLAG_DEFAULT, linkedValue=28), name="Text", flags=FLAG_DEFAULT, linkedValue=OPSZ_MAX),
dict(nominalValue=28, rangeMinValue=21, rangeMaxValue=28, name="Display"), dict(nominalValue=OPSZ_MAX, rangeMinValue=OPSZ_MID, rangeMaxValue=OPSZ_MAX,
name="Display"),
]), ]),
dict(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=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 # # stat_axes_format_3 is used for making a STAT table with format 1 & 3 records
def stat_axes_format_3(is_italic): # def stat_axes_format_3(is_italic):
# see https://learn.microsoft.com/en-us/typography/opentype/spec/ # # see https://learn.microsoft.com/en-us/typography/opentype/spec/
# stat#axis-value-table-format-3 # # stat#axis-value-table-format-3
suffix = " Italic" if is_italic else "" # suffix = " Italic" if is_italic else ""
return [ # return [
{ "name": "Optical Size", "tag": "opsz" }, # { "name": "Optical Size", "tag": "opsz" },
{ "name": "Weight", "tag": "wght", "values": [ # { "name": "Weight", "tag": "wght", "values": [
{ "name": "Thin"+suffix, "value": 100, "linkedValue": 400 }, # { "name": "Thin"+suffix, "value": 100, "linkedValue": 400 },
{ "name": "ExtraLight"+suffix, "value": 200, "linkedValue": 500 }, # { "name": "ExtraLight"+suffix, "value": 200, "linkedValue": 500 },
{ "name": "Light"+suffix, "value": 300, "linkedValue": 600 }, # { "name": "Light"+suffix, "value": 300, "linkedValue": 600 },
{ "name": "Regular"+suffix, "value": 400, "linkedValue": 700, # { "name": "Regular"+suffix, "value": 400, "linkedValue": 700,
"flags":FLAG_DEFAULT }, # "flags":FLAG_DEFAULT },
{ "name": "Medium"+suffix, "value": 500, "linkedValue": 800 }, # { "name": "Medium"+suffix, "value": 500, "linkedValue": 800 },
{ "name": "SemiBold"+suffix, "value": 600, "linkedValue": 900 }, # { "name": "SemiBold"+suffix, "value": 600, "linkedValue": 900 },
{ "name": "Bold"+suffix, "value": 700 }, # { "name": "Bold"+suffix, "value": 700 },
{ "name": "ExtraBold"+suffix, "value": 800 }, # { "name": "ExtraBold"+suffix, "value": 800 },
{ "name": "Black"+suffix, "value": 900 }, # { "name": "Black"+suffix, "value": 900 },
]}, # ]},
] # ]
# STAT_AXES is used for making a STAT table with format 4 records # # STAT_AXES is used for making a STAT table with format 4 records
STAT_AXES = [ # STAT_AXES = [
{ "name": "Optical Size", "tag": "opsz" }, # { "name": "Optical Size", "tag": "opsz" },
{ "name": "Weight", "tag": "wght" }, # { "name": "Weight", "tag": "wght" },
{ "name": "Italic", "tag": "ital" } # { "name": "Italic", "tag": "ital" }
] # ]
# stat_locations is used for making a STAT table with format 4 records # # stat_locations is used for making a STAT table with format 4 records
def stat_locations(is_italic): # def stat_locations(is_italic):
# see https://learn.microsoft.com/en-us/typography/opentype/spec/ # # see https://learn.microsoft.com/en-us/typography/opentype/spec/
# stat#axis-value-table-format-4 # # stat#axis-value-table-format-4
ital = 1 if is_italic else 0 # ital = 1 if is_italic else 0
suffix = " Italic" if is_italic else "" # suffix = " Italic" if is_italic else ""
return [ # return [
{ "name": "Thin"+suffix, "location":{"wght":100, "ital":ital} }, # { "name": "Thin"+suffix, "location":{"wght":100, "ital":ital} },
{ "name": "ExtraLight"+suffix, "location":{"wght":200, "ital":ital} }, # { "name": "ExtraLight"+suffix, "location":{"wght":200, "ital":ital} },
{ "name": "Light"+suffix, "location":{"wght":300, "ital":ital} }, # { "name": "Light"+suffix, "location":{"wght":300, "ital":ital} },
{ "name": "Regular"+suffix, "location":{"wght":400, "ital":ital}, # { "name": "Regular"+suffix, "location":{"wght":400, "ital":ital},
"flags":FLAG_DEFAULT }, # "flags":FLAG_DEFAULT },
{ "name": "Medium"+suffix, "location":{"wght":500, "ital":ital} }, # { "name": "Medium"+suffix, "location":{"wght":500, "ital":ital} },
{ "name": "SemiBold"+suffix, "location":{"wght":600, "ital":ital} }, # { "name": "SemiBold"+suffix, "location":{"wght":600, "ital":ital} },
{ "name": "Bold"+suffix, "location":{"wght":700, "ital":ital} }, # { "name": "Bold"+suffix, "location":{"wght":700, "ital":ital} },
{ "name": "ExtraBold"+suffix, "location":{"wght":800, "ital":ital} }, # { "name": "ExtraBold"+suffix, "location":{"wght":800, "ital":ital} },
{ "name": "Black"+suffix, "location":{"wght":900, "ital":ital} }, # { "name": "Black"+suffix, "location":{"wght":900, "ital":ital} },
] # ]
WINDOWS_ENGLISH_IDS = 3, 1, 0x409 WINDOWS_ENGLISH_IDS = 3, 1, 0x409
@ -348,31 +353,40 @@ def main():
args = argparser.parse_args() args = argparser.parse_args()
# load font # 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 # set family name
if not args.family: if not args.family:
args.family = "Inter Variable" args.family = "Inter Variable"
setFamilyName(font, args.family) setFamilyName(ttfont, args.family)
# set style name # set style name
stylename = remove_substring(getStyleName(font), "Display") stylename = remove_substring(getStyleName(ttfont), "Display")
if stylename == '': if stylename == '':
stylename = 'Regular' stylename = 'Regular'
setStyleName(font, stylename) setStyleName(ttfont, stylename)
# build STAT table # build STAT table
gen_stat(font) gen_stat(ttfont)
# fixup fvar table # fixup fvar table
fixup_fvar(font) fixup_fvar(ttfont)
# # fixup OS/2 table (set usWeightClass) # # fixup OS/2 table (set usWeightClass)
# fixup_os2(font) # fixup_os2(ttfont)
# save font # save font
outfile = args.output or args.input outfile = args.output or args.input
font.save(outfile) ttfont.save(outfile)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -50,14 +50,21 @@ def fixup_instance(designspace, instance):
def fixup_instances(designspace): def fixup_instances(designspace):
USE_DISPLAY_AS_DEFAULT = False
i = len(designspace.instances) i = len(designspace.instances)
while i > 0: while i > 0:
i -= 1 i -= 1
instance = designspace.instances[i] instance = designspace.instances[i]
if USE_DISPLAY_AS_DEFAULT:
if instance.name.find('Inter Display') != -1: if instance.name.find('Inter Display') != -1:
fixup_instance(designspace, instance) fixup_instance(designspace, instance)
else: else:
del designspace.instances[i] del designspace.instances[i]
else:
if instance.name.find('Inter Display') == -1:
fixup_instance(designspace, instance)
else:
del designspace.instances[i]
# def fixup_axes_defaults(designspace): # def fixup_axes_defaults(designspace):

View File

@ -2535,8 +2535,7 @@ name = "Axis Mappings";
value = { value = {
opsz = { opsz = {
14 = 14; 14 = 14;
22 = 25; 32 = 32;
28 = 28;
}; };
wght = { wght = {
100 = 100; 100 = 100;
@ -3674,7 +3673,7 @@ GSOffsetVertical = 10;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
100 100
); );
customParameters = ( customParameters = (
@ -3734,12 +3733,12 @@ size = "-16";
name = "Axis Location"; name = "Axis Location";
value = ( value = (
{ {
Axis = Weight; Axis = "Optical size";
Location = 100; Location = 32;
}, },
{ {
Axis = "Optical size"; Axis = Weight;
Location = 28; Location = 100;
} }
); );
}, },
@ -3969,7 +3968,7 @@ GSOffsetVertical = 72;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
400 400
); );
customParameters = ( customParameters = (
@ -4029,12 +4028,12 @@ size = "-16";
name = "Axis Location"; name = "Axis Location";
value = ( value = (
{ {
Axis = Weight; Axis = "Optical size";
Location = 400; Location = 32;
}, },
{ {
Axis = "Optical size"; Axis = Weight;
Location = 28; Location = 400;
} }
); );
} }
@ -4266,7 +4265,7 @@ GSOffsetVertical = 150;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
900 900
); );
customParameters = ( customParameters = (
@ -4326,12 +4325,12 @@ size = "-16";
name = "Axis Location"; name = "Axis Location";
value = ( value = (
{ {
Axis = Weight; Axis = "Optical size";
Location = 900; Location = 32;
}, },
{ {
Axis = "Optical size"; Axis = Weight;
Location = 28; Location = 900;
} }
); );
}, },
@ -4802,7 +4801,7 @@ weightClass = 900;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
100 100
); );
customParameters = ( customParameters = (
@ -4858,7 +4857,7 @@ value = "Inter Display";
}, },
{ {
axesValues = ( axesValues = (
28, 32,
200 200
); );
customParameters = ( customParameters = (
@ -4916,7 +4915,7 @@ weightClass = 200;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
300 300
); );
customParameters = ( customParameters = (
@ -4974,7 +4973,7 @@ weightClass = 300;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
400 400
); );
customParameters = ( customParameters = (
@ -5029,7 +5028,7 @@ value = Italic;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
500 500
); );
customParameters = ( customParameters = (
@ -5087,7 +5086,7 @@ weightClass = 500;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
600 600
); );
customParameters = ( customParameters = (
@ -5145,7 +5144,7 @@ weightClass = 600;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
700 700
); );
customParameters = ( customParameters = (
@ -5204,7 +5203,7 @@ weightClass = 700;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
800 800
); );
customParameters = ( customParameters = (
@ -5262,7 +5261,7 @@ weightClass = 800;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
900 900
); );
customParameters = ( customParameters = (

View File

@ -2535,8 +2535,7 @@ name = "Axis Mappings";
value = { value = {
opsz = { opsz = {
14 = 14; 14 = 14;
22 = 25; 32 = 32;
28 = 28;
}; };
wght = { wght = {
100 = 100; 100 = 100;
@ -3685,7 +3684,7 @@ GSOffsetVertical = 64;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
100 100
); );
customParameters = ( customParameters = (
@ -3745,12 +3744,12 @@ size = "-16";
name = "Axis Location"; name = "Axis Location";
value = ( value = (
{ {
Axis = Weight; Axis = "Optical size";
Location = 100; Location = 32;
}, },
{ {
Axis = "Optical size"; Axis = Weight;
Location = 28; Location = 100;
} }
); );
}, },
@ -3975,7 +3974,7 @@ GSOffsetVertical = 100;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
400 400
); );
customParameters = ( customParameters = (
@ -4035,12 +4034,12 @@ size = "-16";
name = "Axis Location"; name = "Axis Location";
value = ( value = (
{ {
Axis = Weight; Axis = "Optical size";
Location = 400; Location = 32;
}, },
{ {
Axis = "Optical size"; Axis = Weight;
Location = 28; Location = 400;
} }
); );
} }
@ -4266,7 +4265,7 @@ GSOffsetVertical = 200;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
900 900
); );
customParameters = ( customParameters = (
@ -4326,12 +4325,12 @@ size = "-16";
name = "Axis Location"; name = "Axis Location";
value = ( value = (
{ {
Axis = Weight; Axis = "Optical size";
Location = 900; Location = 32;
}, },
{ {
Axis = "Optical size"; Axis = Weight;
Location = 28; Location = 900;
} }
); );
}, },
@ -4749,7 +4748,7 @@ weightClass = 900;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
100 100
); );
customParameters = ( customParameters = (
@ -4800,7 +4799,7 @@ weightClass = 100;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
200 200
); );
customParameters = ( customParameters = (
@ -4852,7 +4851,7 @@ weightClass = 200;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
300 300
); );
customParameters = ( customParameters = (
@ -4904,7 +4903,7 @@ weightClass = 300;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
400 400
); );
customParameters = ( customParameters = (
@ -4954,7 +4953,7 @@ value = Regular;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
500 500
); );
customParameters = ( customParameters = (
@ -5006,7 +5005,7 @@ weightClass = 500;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
600 600
); );
customParameters = ( customParameters = (
@ -5058,7 +5057,7 @@ weightClass = 600;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
660 660
); );
customParameters = ( customParameters = (
@ -5112,7 +5111,7 @@ weightClass = 700;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
800 800
); );
customParameters = ( customParameters = (
@ -5164,7 +5163,7 @@ weightClass = 800;
}, },
{ {
axesValues = ( axesValues = (
28, 32,
900 900
); );
customParameters = ( customParameters = (