SFML community forums

Help => Graphics => Topic started by: zsbzsb on January 17, 2012, 12:20:39 am

Title: A few Questions regarding Text
Post by: zsbzsb on January 17, 2012, 12:20:39 am
So far my project is coming along well. I am currently using .NET SFML 2. I only have a few questions around drawing text. My first question is that sometimes when drawing text at a low font size around 10-20 the text appears blurry. I was reading in some other threads to disable smoothing but I was unable to find that (so maybe an example?). The second question regards drawing text with an outline. I was also reading another (old) thread where the solution was to use a bitmap font or some form of shaders. I really do not want to use bitmap fonts because I load a font that is specified by the user. So that leaves me with only shaders. If using shaders is possible then could someone post an example on using them? (I'm new to the graphics stuff 8) )  Thanks in advance for replies.
Title: A few Questions regarding Text
Post by: Mario on January 18, 2012, 12:04:57 am
Just look for an edge detector - should work fine (just detect changes in alpha).

Another solution (that might be slower but won't require shaders) would be rendering the same text multiple times:

Render in black at an offset of (-1, -1), (0, -1), (1, -1), etc. (8 positions), then render the final (and colored) text in the center (offset (0,0)). That way you'll get a nice thin outline, but you have to essentially draw the text 9 times. Depending on what you're doing, this might be acceptable or slow you down too much.

To mix, this would as well work by rendering into a RenderTexture, so you don't have to redraw everything every frame.
Title: A few Questions regarding Text
Post by: zsbzsb on January 18, 2012, 02:20:52 am
Quote from: "Mario"
Just look for an edge detector - should work fine (just detect changes in alpha).

Another solution (that might be slower but won't require shaders) would be rendering the same text multiple times:

Render in black at an offset of (-1, -1), (0, -1), (1, -1), etc. (8 positions), then render the final (and colored) text in the center (offset (0,0)). That way you'll get a nice thin outline, but you have to essentially draw the text 9 times. Depending on what you're doing, this might be acceptable or slow you down too much.

To mix, this would as well work by rendering into a RenderTexture, so you don't have to redraw everything every frame.


Thanks for the reply Mario, drawing a border by offsetting the text looks like what I want.