3

アプリケーションで文字の形をベクトル形式(点と曲線)で取得する必要があります。Fontインスタンスを簡単に取得でき、 GlyphVectorクラスで必要なShapeを取得できるようです。しかし、 FontからGlyphVectorを作成するには、 FontRenderContexが必要です。

何かをレンダリングしている間ではなく、この操作を実行するため、そのFontRenderContexを取得する方法がわかりません。デフォルトのFontRenderContexを作成するか、それをバイパスすることは可能ですか?

4

2 に答える 2

1

Graphics2Dを拡張するアプリケーションに何かありますか?そうすれば、getFontRenderContextメソッドにアクセスできます。

つまり、コンストラクターの1つを使用するだけですが、 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.
于 2012-08-15T13:51:10.840 に答える
1

これが機能するかどうかはわかりませんが、 BufferedImageオブジェクトのGraphics2DオブジェクトからFontRenderContextを取得できます。

BufferedImage img = new BufferedImage(8, 8, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.getGraphics();
FontRenderContext frc = g2.getFontRenderContext();
于 2012-08-15T14:01:30.003 に答える