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.

This commit is contained in:
Karl Zylinski
2025-10-09 00:32:16 +02:00
parent 0f97382fa3
commit 79912b3a98
+4 -1
View File
@@ -335,7 +335,10 @@ AddFontMem :: proc(
res.freeLoadedData = freeLoadedData
res.name = strings.clone(name)
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)
stbtt.InitFont(&res.info, raw_data(res.loadedData), font_offset)
ascent, descent, line_gap: i32
stbtt.GetFontVMetrics(&res.info, &ascent, &descent, &line_gap)