I've implemented FreeType in my program, I can draw text with colors and style (Bold, Italic, Underline).
Now I would like to make an outline effect on my text. How can I do it?
(source: googlecode.com)
- I've tried to draw the text two times, one larger in black in background and the second in white on foreground, result was wrong.
- I've tried to draw the text two time, one in bold and the second in one on foreground, here again the result was wrong.
I would like to make a test again : Draw the "background" text in "outline" mode and the foreground text in regular mode. What do you think about it?
(source: googlecode.com)
Draw the text, then do a second pass over every pixel that was not fully coloured in. For each of those pixels calculate how far away it is from the nearest coloured pixel. If it's less than X where X is the desired width of your outline, colour it in using your outline colour.
It can be slow to do this for large text but it can be optimised and the results cached to make it run acceptably fast. This method allows complete freedom for all kinds of outline and drop shadow effects.