Uninstall fonts installed using SWT's Display.loadFont API

筅森魡賤 提交于 2021-01-28 05:21:42

问题


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

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: Problems encountered while deleting resources

I have following questions:

  1. Is it possible to unload font from application in SWT ?
  2. Is there any way to deal with it?
  3. Is there another scenario to deal with custom fonts in eclipse?

回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/4898904/uninstall-fonts-installed-using-swts-display-loadfont-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!