Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fonts named Oblique instead of Italic #1034

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/glyphsLib/builder/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def to_ufo_names(self, ufo, master, family_name):
styleMapFamilyName, styleMapStyleName = build_stylemap_names(
family_name=family_name,
style_name=styleName,
is_bold=(styleName == "Bold"),
is_bold=(styleName in ("Bold", "Bold Italic", "Bold Oblique")),
is_italic=is_italic,
)
ufo.info.styleMapFamilyName = styleMapFamilyName
Expand Down Expand Up @@ -99,7 +99,7 @@ def _get_linked_style(style_name, is_bold, is_italic):
is_regular = False
elif part == "Bold" and is_bold:
is_bold = False
elif part == "Italic" and is_italic:
elif (part == "Italic" or part == "Oblique") and is_italic:
is_italic = False
else:
linked_style.appendleft(part)
Expand Down
29 changes: 25 additions & 4 deletions Lib/glyphsLib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ def _joinName(self):
if self.italicAngle:
if names == ["Regular"]:
return "Italic"
if "Italic" not in self.customName:
if "Italic" not in self.customName and "Oblique" not in self.customName:
names.append("Italic")
return " ".join(names)

Expand Down Expand Up @@ -3311,7 +3311,14 @@ def windowsFamily(self):
value = self.customParameters["styleMapFamilyName"]
if value:
return value
if self.name not in ("Regular", "Bold", "Italic", "Bold Italic"):
if self.name not in (
"Regular",
"Bold",
"Italic",
"Oblique",
"Bold Italic",
"Bold Oblique",
):
return self.familyName + " " + self.name
else:
return self.familyName
Expand All @@ -3322,7 +3329,14 @@ def windowsFamily(self, value):

@property
def windowsStyle(self):
if self.name in ("Regular", "Bold", "Italic", "Bold Italic"):
if self.name in (
"Regular",
"Bold",
"Italic",
"Oblique",
"Bold Italic",
"Bold Oblique",
):
return self.name
else:
return "Regular"
Expand All @@ -3331,7 +3345,14 @@ def windowsStyle(self):
def windowsLinkedToStyle(self):
value = self.linkStyle
return value
if self.name in ("Regular", "Bold", "Italic", "Bold Italic"):
if self.name in (
"Regular",
"Bold",
"Italic",
"Oblique",
"Bold Italic",
"Bold Oblique",
):
return self.name
else:
return "Regular"
Expand Down
16 changes: 16 additions & 0 deletions tests/classes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,13 @@ def test_name(self):
master.italicAngle = 10.0
self.assertEqual("Italic", master.name)

# Test that bold italic gets properly named.
master = GSFontMaster()
master.weight = "Bold"
master.width = "Regular"
master.italicAngle = 10.0
self.assertEqual("Bold Italic", master.name)

# Test that we don't get an extra "Italic" in the name of masters
# whose customName already contain the string "Italic"
master = GSFontMaster()
Expand All @@ -680,6 +687,15 @@ def test_name(self):
master.italicAngle = 10.0
self.assertEqual("Italic", master.name)

# Test that we don't get an extra "Italic" in the name of masters
# whose customName contains the string "Oblique"
master = GSFontMaster()
master.weight = "Regular"
master.width = "Regular"
master.customName = "Oblique"
master.italicAngle = 10.0
self.assertEqual("Oblique", master.name)

def test_name_assignment(self):
test_data = [
# <name>, <expected weight>, <expected width>, <expected custom>
Expand Down
Loading