SFML community forums

Help => Graphics => Topic started by: Brendon on March 24, 2011, 08:26:28 pm

Title: [Solved] SFML2 - How to draw large fonts
Post by: Brendon on March 24, 2011, 08:26:28 pm
I've started to use SFML2 dotnet and had a beginner's question about how text is rendered.

When I draw small font sizes, it looks fine. But, when I draw a larger font size (font size 4), it renders blurrily:
(http://blendogames.com/dev/dev_text.jpg)

Code: [Select]
scratchString.DisplayedString = "Center";
scratchString.Scale = new Vector2(4, 4);
renderWindow.Draw(scratchString);


How does one correctly render large font sizes?
Title: [Solved] SFML2 - How to draw large fonts
Post by: Laurent on March 24, 2011, 09:57:51 pm
You must load the font with the correct size directly if you want to avoid the scaling ugliness.
Title: [Solved] SFML2 - How to draw large fonts
Post by: Brendon on March 24, 2011, 10:06:30 pm
In SFML1 the font constructor had a size parameter, but SFML2 doesn't seem to include that parameter.

SFML1:
new Font(string filename, uint charSize)

SFML2:
new Font(string filename)
Title: [Solved] SFML2 - How to draw large fonts
Post by: Laurent on March 24, 2011, 10:08:12 pm
Sorry I answered too quickly :)

In SFML 2 the solution is simpler: use CharacterSize instead of Scale.
Title: [Solved] SFML2 - How to draw large fonts
Post by: Brendon on March 24, 2011, 10:32:53 pm
Works perfectly. Thanks Laurent!

Code: [Select]
scratchString.DisplayedString = "Center";
scratchString.Size = 64;
renderWindow.Draw(scratchString);