如何从SWT中的InputStream加载字体? [英] How to load font from InputStream in SWT?

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

问题描述

我需要从java 加载字体( .otf .ttf )文件。 Resource InputStream 在SWT中。

org.eclipse .swt.graphics.Device.loadFont(String path)允许我(

我正在考虑使用 java.awt.Font.createFont(int fontFormat,InputStream fontStream),然后构建 org .eclipse.swt.graphics.FontData org.eclipse.swt.graphics.Font 对象超出AWT java。 awt.Font object。



因为我还没有尝试过这个选项(我甚至不知道它是否以这种方式工作)只是想知道是否有其他选项可用?

解决方案

不是很好,但你可以总是将流写入临时文件,并使用可用的方法。


I need to load font (.otf or .ttf) file from java Resource or InputStream in SWT.

org.eclipse.swt.graphics.Device.loadFont(String path) allows me (example) to load font from font file path (and it works), but there is no corresponding method to load it from any other source.

I was thinking of using java.awt.Font.createFont(int fontFormat, InputStream fontStream) and then building org.eclipse.swt.graphics.FontData and org.eclipse.swt.graphics.Font objects out of AWT java.awt.Font object.

Since I haven't tried that option yet (I don't even know if it works that way) I was just wondering if there are any other options available?

解决方案

Not great but you can always write the stream to a temporary file, and use the available method.

这篇关于如何从SWT中的InputStream加载字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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