mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-07 11:51:50 +09:00
WOFF builder
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
# OTFbuild
|
||||
|
||||
Python toolchain that builds an OpenType (CFF) font from the TGA sprite sheets used by the bitmap font engine.
|
||||
Python toolchain that builds an OpenType (CFF) and Web Open Font (WOFF2) font from the TGA sprite sheets used by the bitmap font engine.
|
||||
|
||||
## Building
|
||||
|
||||
```bash
|
||||
pip install fonttools
|
||||
python3 OTFbuild/build_font.py src/assets -o OTFbuild/TerrarumSansBitmap.otf
|
||||
# builds both OTF and WOFF2
|
||||
make all
|
||||
```
|
||||
|
||||
Options:
|
||||
- `--no-bitmap` — skip EBDT/EBLC bitmap strike (faster builds for iteration)
|
||||
- `--no-features` — skip GSUB/GPOS OpenType features
|
||||
|
||||
## Debugging with HarfBuzz
|
||||
|
||||
Install `uharfbuzz` for shaping tests:
|
||||
@@ -118,6 +114,7 @@ print(f"{name}: advance={w}, has_outlines={has_outlines}")
|
||||
| `opentype_features.py` | Generates GSUB/GPOS feature code for feaLib |
|
||||
| `keming_machine.py` | Generates kerning pairs from glyph kern masks |
|
||||
| `hangul.py` | Hangul syllable composition and jamo GSUB data |
|
||||
| `otf2woff2.py` | OTF to WOFF2 wrapper |
|
||||
|
||||
### OpenType features generated (`opentype_features.py`)
|
||||
|
||||
|
||||
19
OTFbuild/Makefile
Normal file
19
OTFbuild/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PYTHON ?= python3
|
||||
ASSETS ?= ../src/assets
|
||||
OTF = TerrarumSansBitmap.otf
|
||||
WOFF2 = TerrarumSansBitmap.woff2
|
||||
|
||||
all: $(OTF) $(WOFF2)
|
||||
|
||||
$(OTF): $(wildcard $(ASSETS)/*.tga) build_font.py font_builder.py glyph_parser.py \
|
||||
bitmap_tracer.py tga_reader.py keming_machine.py hangul.py sheet_config.py \
|
||||
opentype_features.py
|
||||
$(PYTHON) build_font.py $(ASSETS) -o $@
|
||||
|
||||
$(WOFF2): $(OTF) otf2woff2.py
|
||||
$(PYTHON) otf2woff2.py $< $@
|
||||
|
||||
clean:
|
||||
rm -f $(OTF) $(WOFF2)
|
||||
|
||||
.PHONY: all clean
|
||||
Binary file not shown.
10
OTFbuild/otf2woff2.py
Executable file
10
OTFbuild/otf2woff2.py
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Convert an OTF/TTF font to WOFF2 format."""
|
||||
import sys
|
||||
from fontTools.ttLib import TTFont
|
||||
|
||||
src, dst = sys.argv[1], sys.argv[2]
|
||||
font = TTFont(src)
|
||||
font.flavor = 'woff2'
|
||||
font.save(dst)
|
||||
print(f" Written {dst}")
|
||||
@@ -1 +1,2 @@
|
||||
fonttools>=4.47.0
|
||||
brotli>=1.1.0
|
||||
|
||||
Reference in New Issue
Block a user