How to load font from InputStream in SWT?

匿名 (未验证) 提交于 2019-12-03 09:19:38

问题:

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?

回答1:

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



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