Can't load codepoints needed for Unicode text rendering

未关闭
#427 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
活跃
技术栈
cpp

调研方向

Start by reviewing the raylib-cpp Font usage shown in the issue and the raylib GetCodepoints() API it references. Determine how Unicode text and codepoints should be exposed through the wrapper, then verify that the recommended approach works for the reported rendering case.

由索引模型根据 Issue 内容生成。

描述

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...?

主要语言
C++
星标
960
派生
120
平均合并
10 分钟
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RobLoach/raylib-cpp 的其他 Issue

查看 RobLoach/raylib-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。