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:
1 parent
0f97382fa3
commit
79912b3a98
1 file changed
+4
-1
Vendored
+4
-1
@@ -335,7 +335,10 @@ AddFontMem :: proc(
|
|||||||
res.freeLoadedData = freeLoadedData
|
res.freeLoadedData = freeLoadedData
|
||||||
res.name = strings.clone(name)
|
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
|
ascent, descent, line_gap: i32
|
||||||
|
|
||||||
stbtt.GetFontVMetrics(&res.info, &ascent, &descent, &line_gap)
|
stbtt.GetFontVMetrics(&res.info, &ascent, &descent, &line_gap)
|
||||||
|
|||||||
Reference in new issue
Block a user