Skip to content

Commit

Permalink
v.1.21.0-woff - Fix OS/2 tables, add woff/woff2 export
Browse files Browse the repository at this point in the history
  • Loading branch information
slavfox committed Jul 22, 2023
1 parent 4d99930 commit 4732909
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
74 changes: 46 additions & 28 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from shlex import quote
from shutil import rmtree
from typing import Optional, Sequence, cast
from tempfile import NamedTemporaryFile

import crayons # type: ignore

Expand Down Expand Up @@ -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()


Expand Down

0 comments on commit 4732909

Please sign in to comment.