Skip to content

Replace LCD MonoFont with embedded Barlow Regular font (SFML)#123

Merged
nathansttt merged 1 commit into
PDB-refactorfrom
claude/nifty-robinson-43bf5e
Jun 18, 2026
Merged

Replace LCD MonoFont with embedded Barlow Regular font (SFML)#123
nathansttt merged 1 commit into
PDB-refactorfrom
claude/nifty-robinson-43bf5e

Conversation

@nathansttt

Copy link
Copy Markdown
Collaborator

Summary

  • Removes the custom segment-based MonoFont LCD-style text renderer from the SFML drawing path.
  • Adds EmbeddedFont.h — Barlow Regular TTF (SIL Open Font License 1.1) encoded as a C byte array, included only inside SFML_HOG.cpp. No external font files are required at runtime.
  • Upgrades sf::Windowsf::RenderWindow throughout SFML_HOG.cpp/SFML_HOG.h to gain access to pushGLStates/popGLStates and sf::Text rendering.
  • Adds DrawTextSFML() which:
    • Lazily loads the embedded font via sf::Font::openFromMemory.
    • Converts HOG viewport coordinates to pixel positions using the existing ViewportToScreen / screenRect infrastructure.
    • Maps all textAlign (Left, Center, Right) and textBaseline (Top, Middle, Bottom) values to SFML origin offsets.
    • Wraps the draw in pushGLStates / popGLStates to safely interleave with OpenGL rendering.
  • Replaces both font.GetTextLines() + DrawLines() call sites (background text and foreground text loops) with DrawTextSFML().

Reviewer notes

  • MonoFont is still compiled (it's used by other non-SFML code paths); only the SFML call sites are replaced.
  • Barlow Regular was chosen as it is openly licensed (SIL OFL 1.1), metrically clean, and was already present on the development machine. The encoded array is ~99 KB / ~6 200 lines.
  • sf::RenderWindow is a drop-in subclass of sf::Window; all existing event handling, setFramerateLimit, etc. are unaffected.

Test plan

  • Build the SFML target and confirm text renders with a crisp proportional font instead of the LCD segments.
  • Verify textAlignCenter / textAlignRight and textBaselineTop / textBaselineMiddle positions look correct in a demo that exercises those paths.
  • Confirm no regression in OpenGL geometry rendering (the pushGLStates/popGLStates pair should restore state cleanly).

🤖 Generated with Claude Code

Switch SFML text rendering from the custom segment-based MonoFont
(which simulated an LCD display) to a real TrueType font rendered
through SFML's sf::Text, with no runtime file dependencies.

- Add EmbeddedFont.h: Barlow Regular TTF (SIL OFL 1.1) encoded as a
  C array (kEmbeddedFontData / kEmbeddedFontSize), included only
  inside SFML_HOG.cpp.
- Change sf::Window → sf::RenderWindow throughout SFML_HOG.cpp and
  SFML_HOG.h so that pushGLStates/popGLStates and sf::Text drawing
  are available.
- Add EnsureFontLoaded() to lazily open the font from memory on first
  text draw.
- Add DrawTextSFML() which converts HOG viewport coordinates and
  textAlign/textBaseline to SFML pixel positions and draws with the
  embedded font, properly suspending OpenGL state around the draw.
- Replace both font.GetTextLines() + DrawLines() calls (background
  text and foreground text) with DrawTextSFML().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nathansttt nathansttt merged commit 3d9cf82 into PDB-refactor Jun 18, 2026
3 checks passed
@nathansttt nathansttt deleted the claude/nifty-robinson-43bf5e branch June 18, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant