From 7e158910ee5e7582a3ffacb4563b87a5ede99caa Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Tue, 23 Jan 2024 13:10:13 +0000 Subject: [PATCH] fix: fix ofl License info and url records --- Lib/gftools/constants.py | 8 ++++++++ Lib/gftools/fix.py | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Lib/gftools/constants.py b/Lib/gftools/constants.py index a94376c34..5d3fec3bd 100644 --- a/Lib/gftools/constants.py +++ b/Lib/gftools/constants.py @@ -85,3 +85,11 @@ PLATFORM_ID__WINDOWS: "WINDOWS", PLATFORM_ID__CUSTOM: "CUSTOM" } + +OFL_LICENSE_INFO = ( + "This Font Software is licensed under the SIL Open Font License, " + "Version 1.1. This license is available with a FAQ at: " + "https://openfontlicense.org" +) + +OFL_LICENSE_URL = "https://openfontlicense.org" \ No newline at end of file diff --git a/Lib/gftools/fix.py b/Lib/gftools/fix.py index ea8597855..a056be2d1 100644 --- a/Lib/gftools/fix.py +++ b/Lib/gftools/fix.py @@ -712,6 +712,18 @@ def fix_nbspace_glyph(ttfont: TTFont): cmap = ttfont.getBestCmap() if 0x00A0 in cmap: return + + +def fix_license_strings(ttfont: TTFont): + """Update font's nametable license and license url strings""" + from gftools.constants import OFL_LICENSE_URL, OFL_LICENSE_INFO + name_table = ttfont["name"] + for r in name_table.names: + if r.nameID == 13: + current_string = r.toUnicode() + if "SIL Open Font License" in current_string: + name_table.setName(OFL_LICENSE_INFO, r.nameID, r.platformID, r.platEncID, r.langID) + name_table.setName(OFL_LICENSE_URL, 14, r.platformID, r.platEncID, r.langID) def fix_font(font, include_source_fixes=False, new_family_name=None, fvar_instance_axis_dflts=None): @@ -721,6 +733,8 @@ def fix_font(font, include_source_fixes=False, new_family_name=None, fvar_instan if fixed_font["OS/2"].version > 1: fixed_font["OS/2"].version = 4 + fix_license_strings(fixed_font) + if "fpgm" in fixed_font: fix_hinted_font(fixed_font) else: