Skip to content

Can't load codepoints needed for Unicode text rendering #427

Description

@TheSheridan

As far as I've looked, if you want to use text with foreign characters you need to specify codepoints --the conversion codes from UTF-x to real Unicode-- in the Font object. The examples I've looked include iterating for a specific range of characters to match the language you want (for C Raylib).

// Source - https://stackoverflow.com/q/73248125
// Posted by Dmitriy, modified by community. See post 'Timeline' for change history
// Retrieved 2026-09-18, License - CC BY-SA 4.0

int codepoints[512] = { 0 };
for (int i = 0; i < 95; i++) codepoints[i] = 32 + i;
for (int i = 0; i < 255; i++) codepoints[96 + i] = 0x400 + i;
Font font = LoadFontEx("arial.ttf", 32, codepoints, 512);

I've tried something similar in a project:

 // codepoints
  std::vector<int> codepoints;
  // Load codepoints from a Unicode subset (Basic Latin)
  for (int cp = 0x20; cp <= 0x7E; ++cp)
    codepoints.push_back(cp);

  raylib::Font font{"src/Milonga-Regular.ttf", 30, codepoints.data(),
                    static_cast<int>(codepoints.size())};

  raylib::Text text{text_str, 30, WHITE, font};

  (...)
  while (!w.ShouldClose()) // Detect window close button or ESC key
  {
    // Update
    // TODO: Update your variables here
	(...)

    // Draw
    BeginDrawing();
    ClearBackground(GetColor(gunmetalGray));

	(...)
    text.Draw(Vector2{20, 20});

    EndDrawing();
  }

...but it doesn't work.

Image

Another solution in Raylib is using GetCodepoints() for a string, but there's no bindings for that.
There's a recommended approach for raylib-cpp or...?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions