Skip to content

Fix font header generation hang (#16) - #19

Open
agustux wants to merge 1 commit into
ghostty-org:mainfrom
agustux:fix/font-header-generation-hang
Open

agustux wants to merge 1 commit into
ghostty-org:mainfrom
agustux:fix/font-header-generation-hang

Conversation

@agustux

@agustux agustux commented Oct 15, 2026

Copy link
Copy Markdown

Fixes #16

bin2header.cmake iterated once per byte and expanded the full hex
string each time (O(n^2)). For the bundled font, the build appeared to
hang; the old script did not finish when I cancelled it.

This replaces the loop with two string(REGEX REPLACE) passes:

  1. Each hex pair from file(READ ... HEX) is rewritten in place as
    0xNN,. Pairs are replaced independently, so values and order are
    unchanged.
  2. A second pass inserts a newline and indent after every 12 entries.
    It adds whitespace only.

The script's interface (INPUT, OUTPUT, ARRAY_NAME) is unchanged,
so CMakeLists.txt and main.c are untouched. Only commands available
in CMake 3.19+ are used, and comments explain why, per AGENTS.md.

Output differs from the old script only in whitespace and a trailing
comma after the last element, which is valid C.

Tested:

  • cmake -B build -G Ninja && cmake --build build succeeds (Debug)
  • cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build succeeds, and ./build/ghostling runs
  • On a 2000-byte input, old and new output are identical after
    stripping whitespace and the trailing comma
  • New script time on the font: 0.483s (old script did not finish)

Note: running the Debug build (./build/ghostling) panics with
"incorrect alignment" in libghostty's ghostty_terminal_set. This is
outside this change (main.c and libghostty are untouched).

bin2header.cmake looped per byte and re-expanded the full hex string
each iteration (O(n^2)), so the build appeared stuck on the bundled
font. Replace the loop with two regex passes.

Byte values and order are preserved: the first pass rewrites each hex
pair in place as 0xNN,, and the second only inserts a newline and
indent after every 12 entries. The only output differences are
whitespace and a trailing comma, which is valid C.
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.

Stuck on Generating font_jetbrains_mono.h infinitly during building from source

1 participant