From 4732909e862ba19e346850a43d947b119fb90157 Mon Sep 17 00:00:00 2001 From: Slavfox Date: Sat, 22 Jul 2023 11:35:06 +0200 Subject: [PATCH] v.1.21.0-woff - Fix OS/2 tables, add woff/woff2 export --- CHANGELOG.md | 9 +++++-- README.md | 3 ++- build.py | 74 ++++++++++++++++++++++++++++++++-------------------- 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c994cfd..258e295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning]. +## [1.21.0-woff] + +Fixed OS/2 tables and added woff/woff2 formats. + ## [1.21.0] The BQN update, brought to you by [dariof4](https://github.com/dariof4)! @@ -2218,8 +2222,9 @@ Still broken on Windows. [keep a changelog]: https://keepachangelog.com/en/1.0.0/ [semantic versioning]: https://semver.org/spec/v2.0.0.html -[unreleased]: https://github.com/slavfox/Cozette/compare/v.1.21.0...HEAD -[1.20.1]: https://github.com/slavfox/Cozette/compare/v.1.20.1...v.1.21.0 +[unreleased]: https://github.com/slavfox/Cozette/compare/v.1.21.0-woff...HEAD +[1.21.0-woff]: https://github.com/slavfox/Cozette/compare/v.1.21.0...v.1.21.0-woff +[1.21.0]: https://github.com/slavfox/Cozette/compare/v.1.20.1...v.1.21.0 [1.20.1]: https://github.com/slavfox/Cozette/compare/v.1.20.0...v.1.20.1 [1.20.0]: https://github.com/slavfox/Cozette/compare/v.1.19.3...v.1.20.0 [1.19.3]: https://github.com/slavfox/Cozette/compare/v.1.19.2-hidpi2...v.1.19.3 diff --git a/README.md b/README.md index 330febe..d38f2b0 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ A bitmap programming font optimized for coziness. - [Roadmap](#roadmap) - [Recommended alternatives](#recommended-alternatives) - [Character map](#character-map) +- [Building](#building) - [Contributors](#contributors) -- [License](#license) +- [License](#license--acknowledgements) # About Cozette diff --git a/build.py b/build.py index 57c7fe3..3bee77c 100644 --- a/build.py +++ b/build.py @@ -5,6 +5,7 @@ from pathlib import Path from shlex import quote from shutil import rmtree from typing import Optional, Sequence, cast +from tempfile import NamedTemporaryFile import crayons # type: ignore @@ -103,35 +104,52 @@ def fix_ttf(ttfpath: Path, name: str): if line.startswith("Version "): version = line.split()[1] break - script = "; ".join( - [ - f'Open("{ttfpath}")', - "SelectWorthOutputting()", - "RemoveOverlap()", - "CorrectDirection()", - "ScaleToEm(2048)", - 'RenameGlyphs("AGL with PUA")', - 'Reencode("unicode")', - f'SetTTFName(0x409, 3, "{name}")', - f'SetTTFName(0x409, 5, "{version}")', - f'SetTTFName(0x409, 8, "Slavfox")', - f'SetTTFName(0x409, 9, "Slavfox")', - f'SetTTFName(0x409, 11, "https://github.com/slavfox/Cozette")', - f'SetTTFName(0x409, 13, "MIT")', - 'SetTTFName(0x409, 14, "https://opensource.org/licenses/MIT")', - f'Generate("{name}.dfont")', - f'Generate("{name}.otf")', - f'Generate("{name}.ttf")', - ] - ) - + with NamedTemporaryFile() as sfd: + subprocess.run( + [f"fontforge -c '" + f"f = open(\"{ttfpath}\"); " + f"f.os2_version = 4; " + f"f.os2_weight_width_slope_only = True; " + f"f.save(\"{sfd.name}\")'"], + cwd=BUILD_DIR, + shell=True, + check=True, + ) + script = ";\n".join( + [ + f'Open("{sfd.name}")', + "SelectWorthOutputting()", + "RemoveOverlap()", + "CorrectDirection()", + "ScaleToEm(2048)", + 'RenameGlyphs("AGL with PUA")', + 'Reencode("unicode")', + f'SetTTFName(0x409, 3, "{name}")', + f'SetTTFName(0x409, 5, "{version}")', + f'SetTTFName(0x409, 8, "Slavfox")', + f'SetTTFName(0x409, 9, "Slavfox")', + f'SetTTFName(0x409, 11, "https://github.com/slavfox/Cozette")', + f'SetTTFName(0x409, 13, LoadStringFromFile({repr(str((REPO_ROOT / "LICENSE").resolve()))}))', + 'SetTTFName(0x409, 14, "https://github.com/slavfox/Cozette/blob/master/LICENSE")', + f'Generate("{name}.dfont")', + f'Generate("{name}.otf")', + f'Generate("{name}.ttf")', + f'Generate("{name}.woff")', + f'Generate("{name}.woff2")', + ] + ) + with NamedTemporaryFile(mode="w+", suffix=".pe") as f: + print(f.name) + f.write(script) + f.flush() + f.seek(0) + subprocess.run( + [f"fontforge -script {f.name}"], + cwd=BUILD_DIR, + shell=True, + check=True, + ) # No idea why this doesn't work without shell=True - subprocess.run( - [f"fontforge -lang ff -c {quote(script)}"], - cwd=BUILD_DIR, - shell=True, - check=True, - ) ttfpath.unlink()