Tweak autohinting
This commit is contained in:
21
README.md
21
README.md
@@ -44,6 +44,8 @@ flatpak install flathub org.fontforge.FontForge
|
||||
|
||||
### macOS preparation
|
||||
|
||||
#### System Python
|
||||
|
||||
On macOS, if you're using the built-in version of Python (via Xcode), you may need to first add a folder to your `PATH` to make `font-line` available, like:
|
||||
|
||||
```bash
|
||||
@@ -54,8 +56,27 @@ pip3 install fonttools font-line
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
#### Homebrew Python
|
||||
|
||||
If you're using `brew install python`, pip requires a virtual environment:
|
||||
|
||||
```bash
|
||||
brew install fontforge ttfautohint
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install fonttools
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
**Note**: If you're using `venv`, you will need to activate it first:
|
||||
|
||||
```
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
If you are just using the system Python, you can skip that step and simply run:
|
||||
|
||||
```
|
||||
python3 build.py
|
||||
```
|
||||
|
||||
16
build.py
16
build.py
@@ -87,6 +87,20 @@ LINE_HEIGHT = 1.0
|
||||
SELECTION_HEIGHT = 1.3
|
||||
ASCENDER_RATIO = 0.8
|
||||
|
||||
# Step 4: ttfautohint options (hinting for Kobo's FreeType renderer)
|
||||
# - Kobo uses FreeType grayscale, so the 1st char of --stem-width-mode
|
||||
# (gray) is the one that matters. n=natural, q=quantized, s=strong.
|
||||
# - Remaining two chars are for GDI and DirectWrite (not used on Kobo).
|
||||
# - Other options are left at ttfautohint defaults; uncomment to override.
|
||||
AUTOHINT_OPTS = [
|
||||
"--no-info",
|
||||
"--stem-width-mode=nss",
|
||||
# "--hinting-range-min=8",
|
||||
# "--hinting-range-max=50",
|
||||
# "--hinting-limit=200",
|
||||
"--increase-x-height=0",
|
||||
]
|
||||
|
||||
# Step 3: Naming and style metadata (used by the rename step)
|
||||
STYLE_MAP = {
|
||||
"Regular": ("Regular", "Book", 400),
|
||||
@@ -642,7 +656,7 @@ def autohint_ttf(ttf_path):
|
||||
|
||||
tmp_path = ttf_path + ".autohint.tmp"
|
||||
result = subprocess.run(
|
||||
["ttfautohint", "--no-info", ttf_path, tmp_path],
|
||||
["ttfautohint"] + AUTOHINT_OPTS + [ttf_path, tmp_path],
|
||||
capture_output=True, text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
|
||||
Reference in New Issue
Block a user