SWT在RCP应用程序中加载字体 [英] SWT Load Font in a RCP App

查看:91
本文介绍了SWT在RCP应用程序中加载字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我想要做的:

Display.getCurrent().loadFont("fonts/helveticaNeueBold_iOS7.ttf")




  • 在测试仪中工作具有输入点的类)。

  • 不能在RCP应用程序中工作。

    • Works in a tester (i.e. class with entry point).
    • Doesn't work in an RCP app.
    • 加载机制有何不同?我应该获取 ttf 文件,然后提取其路径吗?

      How do the loading mechanisms differ? Should I get the ttf file, then extract the path to it?

      推荐答案

      亚历山大的答案可能对某些人也有帮助。

      Alexander's answer could also be helpful to some.

      对我来说,以下代码片段起到了作用:

      For me, the following snippet did the trick:

      final String path = "fonts/helveticaNeueBold_iOS7.ttf";
      final URL pathUrl = BundleUtility.find(PLUGIN_ID, path);
      final boolean isFontLoaded = Display.getCurrent().loadFont(pathUrl.toExternalForm());
      

      尽管要注意 BundleUtility 的访问权限受到限制。

      Although beware that BundleUtility has restricted access.

      这篇关于SWT在RCP应用程序中加载字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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