freetype 的 Unicode 问题 (C)

发布于 2024-08-06 17:50:53 字数 709 浏览 3 评论 0 原文

我目前正在为 NekoVM 开发一个库,以创建与 Freetype 2. 它是用纯 c 编写的,一切都工作得非常好,除了当用户输入一些 unicode 字符,如“ü”、“Ä”或“ ß" 它们将被转变成一些丑陋的方形字母。
当我从 NekoVM 收到数据时,您使用 val_string 返回一个char*。函数 (FT_Load_Char) 将数据推入 freetype 时需要使用 unsigned long 作为 char 代码。 (每个字母都会单独处理。)

如何才能正确呈现字符?在将它们提交到 C 编写的库之前,我还可以选择将它们转换为任何 ISO-8859-XX 代码页。

I currently working on a library for the NekoVM to create a binding to Freetype 2. It is written in plain c and it all works really nice, except when the user enters some unicode chars like "ü", "Ä" or "ß" they will be transformed into to some ugly square-like letters.
When I recieve the data from the NekoVM you use val_string which returns a char*. The function (FT_Load_Char) where you push the data into freetype expects a unsigned long as char code. (Every letter is processed on its own.)

What to do get the characters rendered correctly? I also have the option to convert them into any ISO-8859-XX code page before submitting them into the c written library.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哀由 2024-08-13 17:50:53

小方框意味着您的字符不包含在字体中。这可能意味着两件事:

  1. 使用包含这些字符的字体

  2. 使用正确的编码。请参阅 FT_CharMapFT_Encoding

A little square box means that your character isn't contained in the font. That can mean two things:

  1. Use a font which contains these characters

  2. Use the correct encoding. See FT_CharMap and FT_Encoding.

玻璃人 2024-08-13 17:50:53

解决方案非常简单:

for (i=0;i<l;i++) {
    unsigned long c = FT_Get_Char_Index(face,r[i]);
    FT_Load_Glyph(face,uc,FT_LOAD_RENDER);
    ....
}

这使得 freetype 自己处理所有“编码内容”。

The solution was quite simple:

for (i=0;i<l;i++) {
    unsigned long c = FT_Get_Char_Index(face,r[i]);
    FT_Load_Glyph(face,uc,FT_LOAD_RENDER);
    ....
}

This makes freetype handle all the "encoding-stuff" at it own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文