我需要在我的应用程序中获取 vector 形式(点和曲线)的字母形状。我可以获得Font实例很容易,似乎GlyphVector类能够给我所需的 Shape .但是要创建GlyphVector来自 Font , 我需要一些 FontRenderContex .
我在渲染某些东西时没有执行此操作,因此我看不到获取该操作的方法 FontRenderContex .是否可以创建一些默认值 FontRenderContex还是绕过它?
最佳答案
您的应用程序中是否有任何扩展 Graphics2D 的内容? ?这样,您就可以访问 getFontRenderContext
方法。
我的意思是你可以只使用其中一个构造函数,但我在 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.
关于java - 是否可以从字体中获取 vector 形式的字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11967854/