Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] SFML2 - How to draw large fonts  (Read 1886 times)

0 Members and 1 Guest are viewing this topic.

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
[Solved] SFML2 - How to draw large fonts
« 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:


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


How does one correctly render large font sizes?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Solved] SFML2 - How to draw large fonts
« Reply #1 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.
Laurent Gomila - SFML developer

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
[Solved] SFML2 - How to draw large fonts
« Reply #2 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)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Solved] SFML2 - How to draw large fonts
« Reply #3 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.
Laurent Gomila - SFML developer

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
[Solved] SFML2 - How to draw large fonts
« Reply #4 on: March 24, 2011, 10:32:53 pm »
Works perfectly. Thanks Laurent!

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

 

anything