在opengl中编写阿拉伯语文本
我想使用 freetype 2 在我的 opengl 程序中编写阿拉伯语文本 我该怎么做 任何人都可以向我发送源代码或向我展示方法,甚至对 nehe 第 43 课进行任何修改,以在 opengl 中编写阿拉伯语,其中解释了使用 freetype 来显示阿拉伯文本
我之前看过第 13 课和第 43 课,但问题是当我渲染它时,它只显示矩形边框,没有任何阿拉伯字母,我使用 glUseOutline ,它从左到右显示字母,但没有将它们连接在一起,阿拉伯字母的问题是有一些字母必须考虑它的位置,例如字母(乙) 当这个字母位于单词(字符串)的开头时,它有自己的形状,并且在中间和结尾,因此,如果有专门为其编写的源代码,那么它将非常好,如下所示的单词示例: 乙字以乙字开头 ea ea 字母 巴 位于中间 rib 字母 б 位于最后
I want to write arabic text in my opengl program using freetype 2 how I can do it any one can send me asource code or show me the way or even any modification on nehe lesson 43 to write arabic in opengl which explain using freetype to display the arabic text
I saw lesson 13 and lesson 43 before,but the problem is when I render it ,it shows me just rectangle borders without any arabic letter,and I used glUseOutline and it shows me the letters from left to right and without connecting it together,the problems in arabic letter is that there are some letters must consider the position of it such as letter (ب)
when this letter is at the beginning of the word(string) it has the own shape and also in the middle and the end therefore, if there is a source code specially be writen for it it'll be very good the word example as below:
بيع the letter ب is at the beginning
يبيع the letter ب is at the middle
ريب the letter ب is at the end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
查看有关使用 OpenGL 渲染位图字体的 NeHe 教程 13 。 如果您想表示阿拉伯文本,您可能需要使用宽字符而不是 8 位字符。 那里有几个示例,其中一些使用 Linux 和 FreeType。 Freetype 渲染 Unicode 字符应该不会有问题。 这个 FreeType 教程可能会有所帮助。
Check out the NeHe tutorial 13 about rendering Bitmap fonts with OpenGL. You probably want to use wide characters instead of 8 bit ones if you want to represent arabic text. There are a couple of examples there, some of them use Linux and FreeType. Freetype shouldn't have a problem rendering Unicode characters. This FreeType tutorial might help.
这看起来应该可行:
https:/ /github.com/Accorpa/Arabic-Converter-From-and-To-Arabic-Presentation-Forms-B/blob/master/ArabicConverter.m
阿拉伯字形转换为相应的表示形式 B,并且应该正确呈现,又名正确加入。 从它的外观来看,它使用了上面 jheriko 的伪代码。
编辑(2016 年 9 月 26 日):我知道这是很久以前我发布的原始答案。 虽然没有错,但与此同时,我最终使用以下代码来转换阿拉伯字母。 这是获取阿拉伯字母表示形式的非常简单的解决方案。
https://github.com/eloraiby/arabtype/blob/master/arabtype.c
。
This looks like something that should work:
https://github.com/Accorpa/Arabic-Converter-From-and-To-Arabic-Presentation-Forms-B/blob/master/ArabicConverter.m
Arabic glyphs are converted to their corresponding presentation forms B and should render correctly, aka correctly joined. From the looks of it, it is using jheriko's pseudocode from above.
EDIT (Sept. 26, 2016): I am aware this is a long time ago that I posted the original answer. While not wrong, in the meantime, I ended up using the following code to convert Arab letters. It is a very straightforward solution to get the presentation forms for Arabic letters.
https://github.com/eloraiby/arabtype/blob/master/arabtype.c
.
看看 a>(阿拉伯语),这是阿拉伯语论坛中的讨论,涵盖了在 OpenGL 中渲染阿拉伯语文本时遇到的所有问题,甚至是高级问题。
我不知道你是否会说阿拉伯语,但在第二页中,你会找到一个示例代码,它告诉你如何使用 GDI+ 编写阿拉伯文本:
另一位成员更改了代码以使用 OpenGL,结果是成功的:
(来源:agdn-online.com)
您可以在此处下载代码。
Take a look at نصوص عربية في أوبن جي إل (Arabic), that's a discussion in an Arabic forum which covers all the issues you'll face when rendering Arabic text in OpenGL, even the advanced ones.
I don't know if you speak Arabic or not, but in the second page, you'll find a sample code, which tells how to write Arabic text using GDI+:
Another member changed the code to work with OpenGL, and the result was successful:
(source: agdn-online.com)
You can download the code here.
您可能想要使用中间表示,以便所有四种形式的字符在输入时都转换为一种形式。 然后,如果您创建一个类/结构数组,其中包含对四种形式正确字符代码中每一种的引用,您可以修改文本渲染器读取的字符串,以便它使用某种逻辑选择正确的字符串,如下伪代码:
You might want to use an intermediary representation, so that all of the four forms of characters are converted to just one form on input. Then if you make an array of classes/structs containing references to each of the four forms correct character codes you can modify the string as read by the text renderer so that it chooses the correct one with some kind of logic like this psuedocode:
如何在此代码中添加阿拉伯语支持?
结束类
How to put Arabic support in this code?
End Class