我正在使用Java中的graphics2d,并且目前正在使用它将文本绘制到bufferedImage中。
Font font1 = new Font("Arial", Font.PLAIN, 120);
g2d.setFont(font1);
FontMetrics fm1 = g2d.getFontMetrics(font1);
g2d.drawString(s[1], width/2-fm1.stringWidth(s[1])/2, height/4-70);
我想要用不同颜色的轮廓线来描绘这段文字。
GlyphVector gv = font1.createGlyphVector(g2d.getFontRenderContext(), s[1]);
Shape shape = gv.getOutline();
g2d.setStroke(new BasicStroke(4.0f));
g2d.translate(width/2-fm1.stringWidth(s[1])/2, height/4-70);
g2d.draw(shape);
使用这种方法的问题是,我正在使用阿拉伯字符,而使用GlyphVector会颠倒顺序,并且字母之间不会流畅连接。请问有人能够解释一下如何以一种颜色渲染阿拉伯文本,并以另一种颜色呈现轮廓吗?这是一个我将要使用的文本样本:الرحمن。