Drawing text with outline in java

I am working with graphcis2d in Java and am currently using this to draw text in 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);

I want to draw this text with a different color outline.

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);        

The problem with using this method, which works, is that I work with Arabic characters, and using GlyphVector changes the order and does not make the letters flow with each other.

Can someone explain to me how to display Arabic text in one color and have an outline with another?

Here is an example of text that I would use: ุงู„ุฑุญู…ู†

+5
source share
3 answers

createStrokedShape() Shape, getOutline(). . CompositeStroke, .

+2

layoutGlyphVector(FontRenderContext frc, char[] text, int start, int limit, int flags) 

createGlyphVector

+2

, , +/- x +/- y, . , , .

+1

All Articles