Codepoints above 127 not rendering on Windows
See original GitHub issueDrawText as implemented in Raylib-cs only supports codepoints up to 127 in Windows – all characters above that gets rendered as “?”. This is kind of annoying, as I’m a swedish programming teacher, and we have a few special extended ascii-characters; å, ä and ö are part of a lit of swedish words.
Things I’ve tried:
- DrawText and DrawTextEx. Same result.
- Loading different fonts, with or without explicit inclusion of codepoints up to 255. Same result.
- Getting the latest Raylib-cs from the github page. Same result as with the nuget package.
- Running the same code but in a virtual Debian machine. THIS WORKS, so issue seems to be in Windows.
- Asking a friend who’s proficient in C/C++ to try using åäö using Raylib in C++. THIS WORKS, so the issue seems to be specific to Raylib-cs, even though it’s just a wrapper?
- DrawTextCodepoint. THIS WORKS, which means that for some reason the issue is specific to the DrawText methods (and InitWindow). Raylib is supposed to be Unicode-capable, and this proves that at least in theory, it is.
Here’s my simple test code (just writes out characters 0-255):
static void Main(string[] args)
{
int font_size = 10;
Raylib.InitWindow(800, font_size * 64, "åäö");
while (!Raylib.WindowShouldClose())
{
Raylib.BeginDrawing();
Raylib.ClearBackground(Color.BEIGE);
for (int i = 0; i < 255; i++)
{
int col = i / 64;
int x = col * 200;
int y = (i % 64) * font_size;
string text = i.ToString() + " | " + ((char)i).ToString();
Raylib.DrawText(text, x, y, font_size, Color.BLACK);
}
Raylib.EndDrawing();
}
}
It works fine in Debian, as stated, but in Windows columns 3 and 4 are filled with ?😒 and the window titlebar is also just ???.
An nice fellow on StackOverflow, who definitely deems to know more than me about these kind of things, had this to say:
The way the library imports DrawText is faulty; its default behavior “marshals” string values to fit a legacy character encoding, not necessarily UTF-8: github.com/ChrisDill/Raylib-cs/blob/… . (Specifying CharSet=Unicode probably won’t help because the DrawText function doesn’t use wide-character strings, but rather ordinary char* pointers interpreted as UTF-8.)
(Peter O)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Thanks, @ChrisDill, can confirm both workarounds work here as well! I’ll pass the first one on to my students immediately.
Very grateful for fast & helpful response; I’ll be using this as an example in the classroom on how git/github, open source and issue tracking is supposed to work =)
I believe its the same issue, I tried drawing text with a 127 unicode and it drew an underscore. I am also using Raylib-cs 3.7.0.