Question

I load a ttf file and create a bitmap (256x256) with transparent background, I then draw the characters (font glyphs) on the bitmap.

What I would like to do is create an thin (1 or 2 pixels) white outline around all the characters, maybe using edge detection.

How would I accomplish this?

Was it helpful?

Solution

I'm sure there's a more formal/cleaner way to do this, but if you only need a 1 pixel border, why not just render the font as white 4 times, one for each diagonal 1-pixel offset, and then draw the black over it?

I.e, draw white at (x-1,y-1), (x-1,y+1), (x+1,y-1), (x+1,y+1), then draw black at (x,y)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top