卸载使用SWT的Display.loadFont API安装的字体 [英] Uninstall fonts installed using SWT's Display.loadFont API

查看:64
本文介绍了卸载使用SWT的Display.loadFont API安装的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在eclipse插件下工作,并尝试将字体作为资源加载到应用程序中,因此它们将出现在项目资源管理器树中.

I am working under eclipse plugin and trying to load fonts into the application as resources, so they will appear in project explorer tree.

在SWT中,我们有Display类的loadFont方法,该方法从指定的文件中加载字体,因此它将出现在应用程序的可用字体列表中.我正在使用这种方法.

In SWT we have method loadFont of Display class which loads font from specified file, so it will appear in list of available fonts of application. I am using this method.

但是当我尝试从项目资源管理器中删除字体时,出现以下异常:

But when I am trying to delete the font from project explorer I am getting following exception:

org.eclipse.core.internal.resources.ResourceException:删除资源时遇到的问题

org.eclipse.core.internal.resources.ResourceException: Problems encountered while deleting resources

我有以下问题:

  1. 是否可以从SWT中的应用程序中卸载字体?
  2. 有什么办法可以解决吗?
  3. 是否有另一种方案可以处理Eclipse中的自定义字体?

推荐答案

不需要处理FontData类型的类,因为它们仅包含少量有关字体的信息.当您创建实际的Font对象时,是的,您有责任调用.dispose()并释放这些资源.

Classes of the type FontData don't need to be disposed of, as they simply contain a small amount of information about the font. When you create an actual Font object then yes, it is your responsibility to call .dispose() and free up those resources.

如果同时使用JFace和SWT,则可能需要查看FontRegistry,它有助于跟踪字体资源.

If you are using JFace as well as SWT, then you may want to look at FontRegistry, which assists in keeping track of font resources.

很抱歉,没有链接任何javadocs,SWT文档现在还没有为我加载.我确实找到了 FontRegistry用法的一个小例子,它解释了FontData之间的区别和字体.

Apologies for not linking any javadocs, the SWT docs aren't loading for me right now. I did find a small example of FontRegistry usage which explains the difference between FontData and Font.

这篇关于卸载使用SWT的Display.loadFont API安装的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆