Skip to content

Conversation

@mbreckon
Copy link

I came across this issue (#458) when using fonts from the Fluent icons (https://github.com/microsoft/fluentui-system-icons). These have code points somewhere in the 0xF800 range and measure text was returning an invalid width.

This PR is my attempt to port the fix to Odin. I'm new to the language so would value someone with a bit more experience double checking the approach and style. In github there appears to be a change on the last line of the file - I've made various attempts to resolve it and I can't see any change locally so I'm unsure if this is valid.

@mbreckon
Copy link
Author

I think I'd want to squash this into a single commit but I'm not familiar with github workflows - do I need to do something or can it be done as part of the merge?

@nicbarker
Copy link
Owner

Hello, thanks for opening this PR! I should definitely drop a comment into the code around the text measurement function, but just for context - there are some internal raylib functions (I think GetGlyphIndex is one of them, I can't quite remember) that do a linear scan over all the glyphs in the font to find the one matching the codepoint. We implemented a simplified version that used a direct array lookup from the ASCII code to significantly speed it up.

If it's not too much trouble, would you be able to quickly benchmark this change with some decent size text blobs & fonts to make sure the performance doesn't take a big hit? 🙂

@nicbarker nicbarker changed the title Fix utf8 code points in example odin raylib renderer [Renderers/Odin] Fix utf8 code points in example odin raylib renderer Sep 8, 2025
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