鼠毒下丑陋的摇摆字体

发布于 2024-09-05 18:23:34 字数 426 浏览 2 评论 0原文

我正在 swing 中编写一个小应用程序。我使用 Ratpoison 作为我的窗口管理器(wmname LG3D),并使用 Netbeans 作为 IDE。我的应用程序字体从 KDE 启动或直接从 Netbeans 启动时看起来不错。从ratpoison开始,它们看起来像这样:

Screenshot http://img195.imageshack.us/img195 /8079/swingfontsratpoison.png 点击查看完整尺寸

I am writing a small application in swing. I am using Ratpoison as my window manager (with wmname LG3D) and Netbeans as IDE. My application fonts when started from KDE or directly from Netbeans look ok. Started from ratpoison they looks like this:

Screenshot http://img195.imageshack.us/img195/8079/swingfontsratpoison.png
Click for full size

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

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

发布评论

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

评论(2

输什么也不输骨气 2024-09-12 18:23:34

KDE 可能会在启动时向系统添加更多字体。

在 KDE 和ratpoison 中执行此命令:

fc-list -v  | grep "file:\|fullname:\|^$"

并比较字体列表以查看缺少的内容。

如果某些目录丢失,请将其添加到 /etc/fonts/fonts.conf 中的新条目中。

如果只是缺少一些字体,您可以复制到 ~/.fonts (假设您在 fonts.conf 中配置了此目录)

如果所有字体都相同,请尝试移动 /etc/fonts/conf.d 中的所有配置到临时目录并运行

fc-cache -f

和测试。

如果看起来更好,开始添加一个配置,再次运行 fc-cache -f ,再次重新启动 java 应用程序并进行测试。

重复,直到找到破坏 java 字体的配置。最后,您应该拥有所有配置,减去破坏 java.util.concurrent.java.util.Error 的配置。

通常它的一些配置将字体设置为首选字体,java将盲目地使用更好的字体。

KDE is probably adding more fonts to the system when starting up.

Execute this on the KDE and in the ratpoison:

fc-list -v  | grep "file:\|fullname:\|^$"

and compare the font list to see what is missing.

If some directory is missing, add it to the /etc/fonts/fonts.conf, in to a new entry.

If just missing some fonts, you can copy then to the ~/.fonts (assuming that you have this dir configures in fonts.conf)

if all fonts are the same, try to move all configs in /etc/fonts/conf.d to a temporary directory and run

fc-cache -f

and test.

if looks better, start adding back one more config, run the fc-cache -f again , restart again the java app and test.

repeat until you found the config that breaks the java fonts. In the end you should have all configs minus the one that breaks the java.

Usually its some config that sets a font as preferred, that java will blindly use, over better fonts.

她说她爱他 2024-09-12 18:23:34

实际上,您可以在 Swing 中使用任何系统字体。

很简单,只需添加一句话即可: yourComponent.setFont(new Font("Tahoma", Font.BOLD|Font.ITALIC, 16));

或者您可以更改总体设置: UIManager.put("label.font", new Font("Tahoma", Font.BOLD, 16));

put 方法的“键”通常是表示您想要的内容的字符串改变如下:
label.font、button.font、label.color、textfield.font 等。所有这些都在小案例中。

并且不要忘记在开始时导入 java.awt.Font 和/或 javax.swing.UIManager

Actually, you can use any system font in Swing.

Easily, just by adding one sentence: yourComponent.setFont(new Font("Tahoma", Font.BOLD|Font.ITALIC, 16));

Or you can change the overall settings: UIManager.put("label.font", new Font("Tahoma", Font.BOLD, 16));

The "keys" of the put method are usually strings indicating what you want to change like:
label.font, button.font, label.color, textfield.font, etc. All in small cases.

And don't forget to import java.awt.Font AND/OR javax.swing.UIManager at the beginning!

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