Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Outline text

Started by deonbotha Sep 3, 2005 at 4:49 AM 1 replies 900+ views
Original Post
deonbotha
deonbotha
How would I go about outlining text in my game? I've tried

g.setColor(Color.Black);
g.drawString("test", x - 1, y + 1);
g.drawString("test", x - 1, y - 1);
g.drawString("test", x + 1, y + 1);
g.drawString("test", x + 1, y - 1);

g.setColor(Color.yellow);
g.drawString("test", x, y);

but it doesn't seem to result in a perfect outline. Any help?
-----------------[ serafin studios ]
redmilamber
redmilamber
Dont use that API for drawing at all, it's deprecated (effectively if not officially).

You want Java2D, part of the standard libraries, look for the Grapihcs2D class - theres full docs on the sun java tutorials in the standard place - and all the classes that come from Shape.

All the Shape classes can be "filled" or "drawn", and you have fine control over the thickness of outline etc. IIRC there's text-drawing capabilities wihtin that too (look at the Stroke and Paint classes)
misterX
misterX
...just my two cents: if you're using a very thin font (what i supose. I bet you're using the default one.) you should simply draw the background string in the 9 directions insteand of 4! :P

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.