diff --git a/Lib/ufo2ft/outlineCompiler.py b/Lib/ufo2ft/outlineCompiler.py index e46f44a5..aa17db48 100644 --- a/Lib/ufo2ft/outlineCompiler.py +++ b/Lib/ufo2ft/outlineCompiler.py @@ -407,7 +407,7 @@ def setupTable_name(self): preferredSubfamilyName = getAttrWithFallback( font.info, "openTypeNamePreferredSubfamilyName" ) - fullName = f"{preferredFamilyName} {preferredSubfamilyName}" + fullName = f"{preferredFamilyName} {preferredSubfamilyName}".strip() nameVals = { 0: getAttrWithFallback(font.info, "copyright"), diff --git a/tests/outlineCompiler_test.py b/tests/outlineCompiler_test.py index 6a0e702a..c6e1786d 100644 --- a/tests/outlineCompiler_test.py +++ b/tests/outlineCompiler_test.py @@ -312,6 +312,16 @@ def test_setupTable_name(self, quadufo): actual = compiler.otf["name"].getName(1, 3, 1, 1033).string assert actual == "Custom Name for Windows" + def test_setupTable_name_empty_styleName(self, quadufo): + """nameID=4 (full name) should not have trailing space when styleName is empty.""" + quadufo.info.styleName = "" + quadufo.info.styleMapFamilyName = None + quadufo.info.openTypeNamePreferredSubfamilyName = None + compiler = OutlineTTFCompiler(quadufo) + compiler.compile() + fullName = compiler.otf["name"].getName(4, 3, 1, 1033).string + assert fullName == fullName.strip() + def test_post_underline_without_public_key(self, quadufo): compiler = OutlineTTFCompiler(quadufo) compiler.compile()