Skip to content

Conversation

karl-zylinski
Copy link
Contributor

Fix for fontstash crash because it didn't fetch the offset of the first font correctly. The old setup didn't work with TTC files that contain multiple fonts.

…st font correctly. The old setup didn't work with TTC files that contain multiple fonts.
stbtt.InitFont(&res.info, &res.loadedData[0], 0)
// Get offset of first font (if the font is a TTC then it can contain multiple fonts)
// Note: There is currently no support for specifying any other font than first one.
font_offset := stbtt.GetFontOffsetForIndex(raw_data(res.loadedData), 0)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of hardcoding, I'd give AddFontMem and AddFontFile a default ttc_index := 0 param, with a little comment that that param determines which ttf file in a .ttc to load, defaulting to the first (or only for .ttf).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Reasonable. I'll fix it tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@Kelimion Kelimion merged commit 227be05 into odin-lang:master Oct 10, 2025
6 of 7 checks passed
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