I'm teaching C# and game dev to high school students, and we're using Raylib-cs as a simple introduction to graphics APIs and libraries.
We've hit a small snag: We're swedish, and we'd like to use some special non-ascii letters – namely å, ä and ö (lots of swedish words use them). However, I can't get Raylib-cs to display anything above codepoint 127 – at least not using DrawText.
Instead, all I get is ?.
This is on Windows 10, 64-bit, 20H2. Using dotnet 5 (latest) and primarily the Raylib-cs available as a nuget package.
What I've tried so far:
- 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.
- 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();
}
}
Result in windows (at least for me): Window title bar is "???", as are all characters beyond the second column. Result in debian: Window title bar is "åäö", and all characters are drawn as they should.
Has anyone come across this problem? Anyone got (tested) solutions?
Is there some known quirk in how C# specifically on windows handles strings or something?