Add custom ZebraFontD bitmap TrueType font to reduce Font D rendering diff#12
Add custom ZebraFontD bitmap TrueType font to reduce Font D rendering diff#12Copilot wants to merge 2 commits into
Conversation
Agent-Logs-Url: https://github.com/GOODBOY008/labelize/sessions/a3bd2aa6-4f49-4af1-9b23-331bf524c56e Co-authored-by: GOODBOY008 <13617900+GOODBOY008@users.noreply.github.com>
|
@copilot adjust the new font to enhance the diff report |
…haracter bitmaps with accurate 2-pixel strokes from reference Agent-Logs-Url: https://github.com/GOODBOY008/labelize/sessions/4809d50d-63ae-4027-a30b-a7025d8d2475 Co-authored-by: GOODBOY008 <13617900+GOODBOY008@users.noreply.github.com>
Done in commit 507f81a. Two improvements were made:
|
Font D diffs (kmart, dpdpl, dhlparceluk) are driven by glyph shape mismatch — DejaVu Mono Bold's outlines don't resemble Zebra's built-in bitmap Font D characters at all. Replacing the backing font with one whose glyphs actually match Zebra's pixel patterns reduces this diff.
Changes
scripts/generate_zebra_font_d.py— fonttools-based generator that encodes pixel-accurate 12×14–17 bitmaps (uppercase, digits, punctuation) as filled TrueType rectangles. Characters extracted pixel-by-pixel from Labelary reference images (testdata/kmart.png); remaining characters designed in the same style with accurate 2-pixel-wide strokes matching Zebra Font D. Font metrics are intentionally kept identical to DejaVu Mono Bold (UPM=2048,ascent=1901,descent=-483,h_advance=1233) so the existing2.317advance-width ratio calibration infont.rsrequires no changes.Key generator fixes:
Y_SCALE:ab_glyphusesv_scale_factor = scale.y / height_unscaledwhereheight_unscaled = ascent − descent = 2384, not UPM. The old formula rendered each bitmap row at 0.859 px instead of 1 px. Fixed toY_SCALE = 2384 / (18 × 7/6) ≈ 113.52.(and)extended to 17 rows to match the reference descender zone.src/assets/fonts/ZebraFontD.ttf— Regenerated font embedded as a static asset (~38 KB).src/assets/mod.rs— ExposesFONT_ZEBRA_Dstatic byte slice.src/drawers/renderer.rs— Routes font name"D"toFONT_ZEBRA_Dinstead of DejaVu Mono Bold:Diff impact