为什么我的 UnicodeFont (Slick2D) 不绘制?

发布于 2025-01-04 20:11:08 字数 463 浏览 3 评论 0原文

所以我尝试使用 Slick2D 的 UnicodeFont 绘制字体。加载字体的代码:

Font font = new Font("Arial", Font.BOLD, 20);
UnicodeFont uFont = new UnicodeFont(font);
uFont.addAsciiGlyphs(); 
uFont.getEffects().add(new ColorEffect(java.awt.Color.BLACK));
uFont.loadGlyphs();

它或多或少是从 wiki 复制和粘贴的。接下来,在一个帧中,我使用 gluOrtho2d() 并重置投影和模型视图矩阵。然后我调用

this.font.drawString(100, 50, "some text goes here");

实际绘制文本。但我得到的只是一个空屏幕,没有任何错误。

So I am trying to draw a font using Slick2D's UnicodeFont. The code that loads the font:

Font font = new Font("Arial", Font.BOLD, 20);
UnicodeFont uFont = new UnicodeFont(font);
uFont.addAsciiGlyphs(); 
uFont.getEffects().add(new ColorEffect(java.awt.Color.BLACK));
uFont.loadGlyphs();

It's more or less copied and pasted from the wiki. Next, during a frame I use gluOrtho2d() and reset the projection and modelview matrices. Then I call

this.font.drawString(100, 50, "some text goes here");

to actually draw the text. But all I get is an empty screen, an no errors of any kind.

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

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

发布评论

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

评论(1

心舞飞扬 2025-01-11 20:11:08

考虑到 UnicodeFonts 在当前版本的 slick 2d 中已被弃用,我建议您按照我的步骤在这个相关问题上使用 AngelCodeFonts:Slick2D 字体不起作用

Considering that UnicodeFonts are depreciated in the current version of slick 2d, I recomend you folow my steps for using AngelCodeFonts on this related question: Slick2D Fonts don't work

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