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.
标题几乎总结了它 - 它是C ++和Windows中世界上最简单的东西,但Java似乎很难解决这个问题。
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.
我想远离涉及加载字体位图的解决方案,而是尝试使用本机truetype字体加载器,如果可能的话。在我的应用程序中,字距调整和抗锯齿非常重要。
4 个解决方案
#1
Use the JOGL/Java 2D bridge: render the font on a texture.
使用JOGL / Java 2D桥:在纹理上渲染字体。
Check out "Java 2D and JOGL"[1]
查看“Java 2D和JOGL”[1]
[1]: http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html ""
[1]:http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html“”
#2
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. :)
JOGL有一个类TextRenderer,它应该做你想要的。它接受Java“Font”对象,我认为你可以为这些对象指定任何ttf文件。它也支持抗锯齿,我不确定是什么字距,但可能也是如此。 :)
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文档目前正在......失踪。他们去的Dunno,希望他们很快就会回来(一两天)。否则我会链接到课程的文档。抱歉!
#3
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.
您可以做的另一件事(例如,如果您想要文本的完全照明功能)是从字体和字符串构造GlyphVector并使用GLUtessellator将其渲染为一组三角形。
#4
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)
JOGL很不错。我之前使用了Processing(processing.org)来渲染漂亮的文本。是的,Windows下的C ++和OpenGL似乎很容易,因为字体管理不同(Linux和MacOSX =用OpenGL我发现的文本更难做)
#1
Use the JOGL/Java 2D bridge: render the font on a texture.
使用JOGL / Java 2D桥:在纹理上渲染字体。
Check out "Java 2D and JOGL"[1]
查看“Java 2D和JOGL”[1]
[1]: http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html ""
[1]:http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html“”
#2
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. :)
JOGL有一个类TextRenderer,它应该做你想要的。它接受Java“Font”对象,我认为你可以为这些对象指定任何ttf文件。它也支持抗锯齿,我不确定是什么字距,但可能也是如此。 :)
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文档目前正在......失踪。他们去的Dunno,希望他们很快就会回来(一两天)。否则我会链接到课程的文档。抱歉!
#3
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.
您可以做的另一件事(例如,如果您想要文本的完全照明功能)是从字体和字符串构造GlyphVector并使用GLUtessellator将其渲染为一组三角形。
#4
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)
JOGL很不错。我之前使用了Processing(processing.org)来渲染漂亮的文本。是的,Windows下的C ++和OpenGL似乎很容易,因为字体管理不同(Linux和MacOSX =用OpenGL我发现的文本更难做)