Caixa pixel-tight, accents visibles i zoom ×3 per defecte

This commit is contained in:
2026-04-26 17:37:32 +02:00
parent 805d9499ce
commit 7631f80d76
3 changed files with 104 additions and 34 deletions
+2 -1
View File
@@ -38,8 +38,9 @@ These properties are consumed by the engine and must hold for any change to the
- **`.notdef` detection**: some TTFs return a substitute glyph (with positive advance and a valid bbox) for missing codepoints, which would falsely pass the `getlength(ch) >= 1` check. The tool renders `U+FFFE` as a reference and rejects any char whose pixels match it. See `_is_notdef` inside `build_font_bitmap`.
- **Fallback table** (`CHAR_FALLBACKS`) maps accented ES/CA/VA chars to ASCII equivalents (`À→A`, `ñ→n`, …). When a TTF lacks the accented glyph, the fallback is drawn into the cell **but the original codepoint is recorded in the `.fnt`**, so localised text still resolves at runtime.
- **Vertical placement**: `draw.text((-bbox[0], y_offset), …)` where `y_offset` is computed from the average top of capital letters. Don't "fix" this by removing the offset — it keeps descenders inside the cell and aligns punctuation to the baseline.
- **Vertical placement**: `draw.text((-bbox[0], y_offset), …)` where `y_offset = -min(getbbox.top)` over all chars to draw, so the topmost pixel of any glyph (including the diacritic on À/É/Ç) lands at y=0 in the scratch. Don't revert this to `cap_tops` average — that variant clips accents above the cap line. The `.notdef` detection uses a separate tentative `notdef_scratch_h` / `notdef_y_offset` (consistency between reference and per-char render is all that matters there); the real `scratch_h` and `y_offset` are recomputed from `getbbox` spans after classification.
- **`box_width` auto-mode** uses `max(getlength)` across rendered chars; override with `--box-width` for pixel-exact bitmap strikes.
- **`box_height` auto-mode is pixel-tight**, *not* `ascent + descent`. Glyphs are rendered to a scratch canvas sized to the bbox span, then `box_height = max_opaque_y - min_opaque_y + 1` across all rendered glyphs (and `y_crop = min_opaque_y` is applied during the second pass). This trims unused leading/descent space — for many bitmap fonts the typographic line height reserves rows that no glyph actually paints. Override with `--box-height` to disable.
## GIF mode quirks (CLI-only)