如何在java中使用opengl中的字体?
标题几乎概括了它 - 这是最简单的事情 C++ 和 Windows 中的世界,但 Java 似乎在解决这个问题。
我想远离涉及加载字体位图的解决方案,而是尝试使用本机 truetype 字体加载器(如果可能)。 字距调整和抗锯齿在我的应用程序中非常重要。
The title pretty much sums it up - its the easiest thing in the
world in C++ and Windows, but Java seems to struggle with this issue.
I would like to stay away from solutions involving loading bitmaps of fonts, and instead try go for a native truetype font loader, if possible. Kerning and antialiasing is quite important in my application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
JOGL 有一个类 TextRenderer,它应该可以完成您想要的操作。 它接受 Java“Font”对象,我认为您可以为此类对象指定任何 ttf 文件。 它也支持抗锯齿,我不确定字距调整是什么,但也可能是这样。 :)
不幸的是,JOGL 文档目前...缺失。 不知道他们去了哪里,希望他们很快就会回来(一两天内)。 否则我会将您链接到该课程的文档。 对不起!
JOGL has a class, TextRenderer, which should do what you want. It accepts a Java "Font" object, and I think you can specify any ttf file for such objects. It does also support antialiasing, I'm not sure what kerning is but probably that too. :)
Unfortunately the JOGL docs are currently... missing. Dunno where they went, hopefully they'll be back soon (in a day or two). Otherwise I would link you to the documentation for the class. Sorry!
使用 JOGL/Java 2D 桥:在纹理上渲染字体。
查看“Java 2D 和 JOGL”[1]
[1]:http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html“”
Use the JOGL/Java 2D bridge: render the font on a texture.
Check out "Java 2D and JOGL"[1]
[1]: http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html ""
您可以做的另一件事(例如,如果您想要文本的完整照明功能)是构造一个 GlyphVector 来自字体和字符串并使用 GLUtessellator 将其渲染为一组三角形。
Another thing you can do (e.g. if you want full lighting functionality for the text) is construct a GlyphVector from the font and string and use a GLUtessellator to render it as a set of triangles.
JOGL 相当不错。 我之前使用过Processing(processing.org)来渲染漂亮的文本。 是的,Windows 下的 C++ 和 OpenGL 看起来确实很容易,因为字体管理不同(Linux 和 MacOSX = 我发现使用 OpenGL 处理文本要困难得多)
JOGL is pretty good. I've used Processing (processing.org) before that renders nice text. Yes, C++ and OpenGL under Windows does seem easy as the Font management is different (Linux and MacOSX = Much harder to do text with OpenGL I've found)