Thick border of hand-drawn strings

Now it seems to me that I searched all over the Internet to find out how to add a border to the text, so I decided to ask here, since you guys always know the answer.

So, how do I, in java, draw a border of about 2 pixels around each letter in a line drawn on a Graphics2D element?

Like this:
Text with 2px border


Thanks in advance.

+5
source share
2 answers

See: Converting shapes, text, and images . Set the "primitive" to "text" and "rendering" to "Stroke and Fill" in the conversion example.

+5
source

Javaworld Java:

g.setColor(Color.red);
g.drawString("Outline", ShiftWest(x, 1), ShiftNorth(y, 1));
g.drawString("Outline", ShiftWest(x, 1), ShiftSouth(y, 1));
g.drawString("Outline", ShiftEast(x, 1), ShiftNorth(y, 1));
g.drawString("Outline", ShiftEast(x, 1), ShiftSouth(y, 1));
g.setColor(Color.yellow);
g.drawString("Outline", x, y);

, , , . , , , .

getOutline(), TextLayout. .

+6

All Articles