是否有可能从字体获得矢量形式的字符? [英] Is it possible to get vector form of characters from Font?

查看:144
本文介绍了是否有可能从字体获得矢量形式的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在应用程序中获取矢量形式(点和曲线)中的字母形状。我可以轻松获得 Font 实例,似乎 GlyphVector 类能够给我所需的形状。但要从 GlyphVector href =http://docs.oracle.com/javase/6/docs/api/java/awt/Font.html =nofollow>字体,我需要有一些 FontRenderContex



我在执行这个操作的时候并不是在渲染的时候,因此我看不到如何获得这个 FontRenderContex 。是否可以创建一些默认的 FontRenderContex 或绕过它?

解决方案

有什么在您的应用程序,扩展 Graphics2D ?这样,您就可以访问 getFontRenderContext 方法。



我的意思是你可以只是使用其中一个构造函数,但是我在 FontRenderContext

 通常情况下,FontRenderContext的实例是从Graphics2D对象中获得的。 
直接构造的FontRenderContext很可能不会代表
任何实际的图形设备,并且可能会导致意外或不正确的结果。


I need to get shapes of letters in vector form (points and curves) in my application. I can obtain Font instance easily, and it seems that GlyphVector class is able to give me the required Shape. But to create GlyphVector from Font, I need to have some FontRenderContex.

I perform this operation not while rendering something, thus I can't see the way to get that FontRenderContex. Is it possible to create some default FontRenderContex or bypass it?

解决方案

Is there anything in your application that extends Graphics2D? That way, you have access to the getFontRenderContext method.

I mean you can just use one of the constructors, but I saw this in the docs for FontRenderContext:

Typically, instances of FontRenderContext are obtained from a Graphics2D object.
A FontRenderContext which is directly constructed will most likely not represent
any actual graphics device, and may lead to unexpected or incorrect results.

这篇关于是否有可能从字体获得矢量形式的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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