Add fontIndex parameter to fontstash that controls which font in a TTC to load

This commit is contained in:
Karl Zylinski
2025-10-10 23:40:29 +02:00
parent 79912b3a98
commit a4350b41ae
3 changed files with 13 additions and 5 deletions
+4 -1
View File
@@ -4,10 +4,13 @@ package fontstash
import "core:log"
import "core:os"
// 'fontIndex' controls which font you want to load within a multi-font format such
// as TTC. Leave it as zero if you are loading a single-font format such as TTF.
AddFontPath :: proc(
ctx: ^FontContext,
name: string,
path: string,
fontIndex: int = 0,
) -> int {
data, ok := os.read_entire_file(path)
@@ -15,6 +18,6 @@ AddFontPath :: proc(
log.panicf("FONT: failed to read font at %s", path)
}
return AddFontMem(ctx, name, data, true)
return AddFontMem(ctx, name, data, true, fontIndex)
}