Skip to content

Commit

Permalink
fix: fix ofl License info and url records
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Jan 23, 2024
1 parent 3e63084 commit 7e15891
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Lib/gftools/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 14 additions & 0 deletions Lib/gftools/fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 7e15891

Please sign in to comment.