Skip to content

Feat(raylib renderer): Make utf8 work with raylib renderer#562

Open
Forelyl wants to merge 2 commits intonicbarker:mainfrom
Forelyl:main
Open

Feat(raylib renderer): Make utf8 work with raylib renderer#562
Forelyl wants to merge 2 commits intonicbarker:mainfrom
Forelyl:main

Conversation

@Forelyl
Copy link
Copy Markdown

@Forelyl Forelyl commented Dec 7, 2025

Main problem was that firstly utf8 in raylib is been drawn in char* format
e.g cyrillic н is been represented as [208, 189] (Wiki - check 'Description' part)

So in short terms

  1. 208 (first number of h) - would overflow and be saved as -48
int index = text.chars[i] - 32
int index = -48 - 32
int index = -80
  1. Then it would cause out of bounds access
    fontToUse.glyphs[index]

The second issue was that

int index = text.chars[i] - 32
Reads only one char, while to decode utf-8 we need to read several of them

Third

Also added check on index to prevent out of bounds (if not all glyphs are loaded)

if (index < 0 || index >= fontToUse.glyphCount) {
    continue;                                       // skip characters not in the font
}

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.

1 participant