This commit is contained in:
Matt Breckon 2025-09-18 00:29:16 +02:00 committed by GitHub
commit a577895910
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,9 +21,17 @@ measure_text :: proc "c" (text: clay.StringSlice, config: ^clay.TextElementConfi
font := raylib_fonts[config.fontId].font font := raylib_fonts[config.fontId].font
for i in 0 ..< text.length { byte_index := 0
glyph_index := text.chars[i] - 32 for byte_index < int(text.length) {
// handle utf-8 codepoints
codepoint_bytes: i32 = 0
codepoint := rl.GetCodepoint(
transmute(cstring)&text.chars[byte_index],
&codepoint_bytes,
)
byte_index += int(codepoint_bytes)
glyph_index := rl.GetGlyphIndex(font, codepoint)
glyph := font.glyphs[glyph_index] glyph := font.glyphs[glyph_index]
if glyph.advanceX != 0 { if glyph.advanceX != 0 {