自定义字体不起作用

发布于 2024-09-01 02:29:58 字数 352 浏览 2 评论 0原文

我创建了一个使用自定义字体的应用程序,并且由于某种原因它曾经可以工作。现在它无法识别我包含在 jar 中的字体,并且它使用默认字体呈现文本。

我真的不明白。当我从 Netbeans 运行应用程序时,一切正常。

有什么想法吗?我清除了 Java 缓存和所有内容,但没有运气。我正在运行 JRE 1.6.0_20。

我什至尝试了这个人的示例,但它不起作用。由于找不到字体,它实际上显示了正方形。

我希望有人能提供解决方案。

I created an application which uses a custom font and it used to work for some reason. Now it doesn't recognize the font I included in the jar and it renders the text using the default font.

I really don't get it. When I run the application from Netbeans everything is OK.

Any ideas? I cleared the Java cache and everything but no luck. I am running JRE 1.6.0_20.

I even tried this guy's example and it does not work. It actually shows squares because of the font not found.

I hope someone has the solution.

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

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

发布评论

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

评论(1

另类 2024-09-08 02:29:58

JavaFX 会缓存字体,因此您必须在使用 javafx.scene.text.Font 类之前注册字体。一旦您使用 javafx Font 类,系统字体就会被缓存,并且永远不会再次查阅。此外,这是 AWT 特定机制,不适用于支持 PRISM 的平台(例如 JavaFX-TV)。

JavaFX caches the fonts, so you must register the font before any use of the javafx.scene.text.Font class. Once you use the javafx Font classes, the system fonts are cached and it is never consulted again. Also, this is an AWT specific mechanism and will not work on platforms that support PRISM, like JavaFX-TV.

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