I have tested outlined text rendering. See link, example png and full sources. Two questions.

1) fill color for outlined textHow should I give a fill color for the outlined text or gradient paint. Now I render it two times. First render a normal text or gradient paint. Then I render outline text on top of it. But see an example picture how background and outline does not always match properly. "W" char is best to how color overflow.

2) reset state of Graphics2D before next method callI call "sayWorld" method twice but with different parameters. I set various g2d properties before drawing a text. All settings reflect to the end of current paint method. Is there an easy way to reset g2d back to the state it was before calling a method. I would like a method call see it always as a "clean state" object.

Thx, both were so simple answers. I have uploaded outlinetext.zip and image2.png showing how it looks after suggested changes. A lot better results.

I take it that temporary g2d instances constain all attributes I have set at the start of paint method. I set rendering hints, default color and font.

Outlined text does not look good for smaller <20px font sizes, but it must be due to a smaller count of pixels available for rendering. I think I try creating +40px font size texts and then scale image to smaller if that gives better results for smaller text lines. But thx for these two valuable bits.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org