Skip to content

Guard missing platform font fallback - #88

Merged
Try merged 3 commits into
Try:masterfrom
tryk016:codex/pr-tempest-font-fallback
Sep 1, 2026
Merged

Guard missing platform font fallback#88
Try merged 3 commits into
Try:masterfrom
tryk016:codex/pr-tempest-font-fallback

Conversation

@tryk016

@tryk016 tryk016 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Platforms without a configured system font fallback return an empty fallback path. The current implementation may then attempt to initialize stb_truetype using an empty font buffer.

This change safely returns an empty glyph when no fallback is available and validates the font data before initializing it. A regression test covers this case.

Testing:

  • TempestTests on macOS: 175 passed
  • iPhoneOS arm64 Release build
  • iPhone Simulator arm64 Release build

Comment thread Engine/formats/font.cpp Outdated
// stbtt_InitFont is undefined behaviour (and crashes on iOS/macOS).
if(path.empty())
return nullLater();
fallback.reset(new Impl(path));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line causes extra copy of std::string. Explicit conversion of path to std::string_view can fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch. I've changed it to std::string_view(path) and updated the test to use U+200B so it actually hits the empty fallback path. All 175 tests pass.

@Try
Try merged commit a0c60f3 into Try:master Sep 1, 2026
4 checks passed
@Try

Try commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Merged, thanks!

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.

2 participants