From e26f6cecf45715bc236312e376139502b84e2afc Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Sat, 25 Apr 2026 12:24:03 -0400 Subject: [PATCH] Fix trailing space in nameID=4 when styleName is empty When a UFO has styleName set to an empty string, the full font name (nameID=4) was constructed as f"{family} {subfamily}" producing a trailing space. Add .strip() to match the pattern used elsewhere (e.g. styleMapFamilyNameFallback, in fontInfoData.py). --- Lib/ufo2ft/outlineCompiler.py | 2 +- tests/outlineCompiler_test.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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()