Skip to content

Commit

Permalink
change "Display" opsz value to 32 (was 28)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsms committed Nov 19, 2023
1 parent 70faa70 commit 59063ec
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 113 deletions.
130 changes: 72 additions & 58 deletions misc/tools/bake-vf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@

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"),
Expand All @@ -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 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_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_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
Expand Down Expand Up @@ -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__':
Expand Down
13 changes: 10 additions & 3 deletions misc/tools/gen-var-designspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
51 changes: 25 additions & 26 deletions src/Inter-Italic.glyphspackage/fontinfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2535,8 +2535,7 @@ name = "Axis Mappings";
value = {
opsz = {
14 = 14;
22 = 25;
28 = 28;
32 = 32;
};
wght = {
100 = 100;
Expand Down Expand Up @@ -3674,7 +3673,7 @@ GSOffsetVertical = 10;
},
{
axesValues = (
28,
32,
100
);
customParameters = (
Expand Down Expand Up @@ -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;
}
);
},
Expand Down Expand Up @@ -3969,7 +3968,7 @@ GSOffsetVertical = 72;
},
{
axesValues = (
28,
32,
400
);
customParameters = (
Expand Down Expand Up @@ -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;
}
);
}
Expand Down Expand Up @@ -4266,7 +4265,7 @@ GSOffsetVertical = 150;
},
{
axesValues = (
28,
32,
900
);
customParameters = (
Expand Down Expand Up @@ -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;
}
);
},
Expand Down Expand Up @@ -4802,7 +4801,7 @@ weightClass = 900;
},
{
axesValues = (
28,
32,
100
);
customParameters = (
Expand Down Expand Up @@ -4858,7 +4857,7 @@ value = "Inter Display";
},
{
axesValues = (
28,
32,
200
);
customParameters = (
Expand Down Expand Up @@ -4916,7 +4915,7 @@ weightClass = 200;
},
{
axesValues = (
28,
32,
300
);
customParameters = (
Expand Down Expand Up @@ -4974,7 +4973,7 @@ weightClass = 300;
},
{
axesValues = (
28,
32,
400
);
customParameters = (
Expand Down Expand Up @@ -5029,7 +5028,7 @@ value = Italic;
},
{
axesValues = (
28,
32,
500
);
customParameters = (
Expand Down Expand Up @@ -5087,7 +5086,7 @@ weightClass = 500;
},
{
axesValues = (
28,
32,
600
);
customParameters = (
Expand Down Expand Up @@ -5145,7 +5144,7 @@ weightClass = 600;
},
{
axesValues = (
28,
32,
700
);
customParameters = (
Expand Down Expand Up @@ -5204,7 +5203,7 @@ weightClass = 700;
},
{
axesValues = (
28,
32,
800
);
customParameters = (
Expand Down Expand Up @@ -5262,7 +5261,7 @@ weightClass = 800;
},
{
axesValues = (
28,
32,
900
);
customParameters = (
Expand Down
Loading

0 comments on commit 59063ec

Please sign in to comment.