Draw Outlined Text

BlitzMax Forums/BlitzMax Beginners Area/Draw Outlined Text

mothmanbr(Posted 2007) [#1]
Is there an easy way to do it? I don't mean only draw the text outline, but draw it like in movie subtitles, where the text color is yellow or white, and it has a 1-pixel wide black line surrounding it to make it visible no matter if the background is dark or light.

I've though about drawing the text twice, first in bold and and then normal, but the alignment wouldn't work depending on the font and I would need to draw it letter by letter.

If I couldn't explain myself correctly, here's an image:


Thanks once again :P


GfK(Posted 2007) [#2]
X = 10
Y = 10
SetColor 0,0,0
DrawText "Hello",X-1,Y-1
DrawText "Hello",X-1,Y+1
DrawText "Hello",X+1,Y-1
DrawText "Hello",X+1,Y+1
SetColor 255,255,255
DrawText "Hello",X,Y


Better alternative is to use bitmap fonts, though, since the above code is drawing four times as much text as is actually visible.


mothmanbr(Posted 2007) [#3]
Interesting, thank you :)

And can I convert TTF fonts to bitmap? If so, how do I do the outlining?


impixi(Posted 2007) [#4]
And can I convert TTF fonts to bitmap? If so, how do I do the outlining?


Try Juicy Fonts. (Windows)


mothmanbr(Posted 2007) [#5]
Thank you :)


Beaker(Posted 2007) [#6]
Or Fontext (in my sig below).


mothmanbr(Posted 2007) [#7]
Will try it too :P Thanks.


mothmanbr(Posted 2007) [#8]
Ok, now this is weird. I saved a font as .png and used in my game, it worked perfectly and everything is just fine. So, now I made a new font, and used it in another project. But even after loading the font, the variable remains as null... I copied the font I used in the other project to the new one... Still null. I changed the graphics driver to use DX7 like in the other project, still null. Everything is just the same, why won't the font load in my second project?

GUI class in my first project:

Type TGUI
	Global Neuropol:TImageFont
	Global NeuroBig:TImageFont
	Global Pixel:TImageFont
	Global PixelBig:TImageFont

	Function Init()
		Neuropol = LoadImageFont("fonts\neuropol.ttf", 12)
		NeuroBig = LoadImageFont("fonts\neuropol.ttf", 30)
		
		Pixel = LoadImageFont("fonts\trisk.png",12)
		PixelBig = LoadImageFont("fonts\trisk.png",16)
	EndFunction
EndType


This one loads correctly, no null variables. Now for the second one:

Type TGUI
	Global Pixel:TImageFont
	Global Crosshair:TImage
	
	Function InitGui()
		Pixel = LoadImageFont("fonts\trisk.png",12)
		If Pixel = Null Then Print "didnt load again..."
		Crosshair = LoadImage("gfx/p_crosshair.png")
	End Function
End Type


Why? I even execute the functions in the same order in both projects, first I create the game window, set mask color and blend mode, then I execute the init function. The path is correct, and it will load as a normal image.

So... If the font worked with my first project, why won't the same font work now in this second one? Is there anything I can do to find out why the font isn't loading and remains as null?


mothmanbr(Posted 2007) [#9]
I'm an idiot. The only reason I thought it was working in the other game is because I was using the method GfK posted and I forgot to remove it :P

So forget the question above.