SFML community forums

Help => Graphics => Topic started by: Doodlemeat on April 28, 2014, 06:36:54 pm

Title: SFML text outline
Post by: Doodlemeat on April 28, 2014, 06:36:54 pm
Hello.

I really must have outline on my text and I am wondering how to do it - the real way. I know that there is no real way but let go with some examples like Photoshop or maybe the HTML5 2d context.

I have found 2 solutions for how to do it.

* Increase size and change color of the outline text and render it before the real text.
* Get some sort of vertices and draw fat lines with a rounded line join by all vertices.

I think the first solution is the best, but it seems so "hacky".
I can see that freetype has outline support(http://www.freetype.org/freetype2/docs/reference/ft2-glyph_management.html#FT_OutlineGlyph).
Can I implement by myself someway?
Why does not SFML has support for it?
Title: Re: SFML text outline
Post by: zsbzsb on April 28, 2014, 06:41:25 pm
Fast and easy method: offset text in 4 direction and draw it using the outline color, then without any offset draw it using the foreground color.

More and advanced method: like the first method, but instead of 4 directions write a loop that goes 1-360, then use sin/cos to offset the text depending on the angle and draw the outline. Note: you might want to step 25 degrees with this method.
Title: Re: SFML text outline
Post by: Doodlemeat on April 28, 2014, 06:43:18 pm
That is definitly a hacky solution. I need some official kind of solution. Because I guess the freetype has support for it? Do you know if that is true?
Title: Re: SFML text outline
Post by: Laurent on April 28, 2014, 07:13:47 pm
FreeType supports it, yes. And it will probably be exposed when SFML uses an OpenGL 2 architecture internally.