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

Author Topic: New implementation for sf::Font in SFML 2  (Read 11521 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New implementation for sf::Font in SFML 2
« Reply #15 on: December 14, 2009, 10:31:51 pm »
I fixed Bold and Underlined styles. It's much much better now ;)

And actually FreeType provides functions for bold (FT_Outline_Embold and FT_Bitmap_Embold -- for fonts not supporting vector outlines) that can be used to generate the bold version of a glyph. So the bold style is no longer faked, it is generated and added to the glyphs texture.
Laurent Gomila - SFML developer

Cierpliwy

  • Newbie
  • *
  • Posts: 23
    • View Profile
New implementation for sf::Font in SFML 2
« Reply #16 on: December 15, 2009, 05:46:35 pm »
That's a great news. I did few tests with different sizes of displayed fonts and styles, and results are really good. Only few FPS lower with styled text. That's how font class should look like form the beginning (I know it wasn't possible ;)). One question although..

What about memory management? I really didn't look at the code. I would spend a lot of time to understand all the concepts, so question is much more convenient.

For example if I use one font, display text size 10 and then use size 50 I bet glyphs are rendered only if I exceed last maximum size? Last one: rendered bold and regular glyphs are held separately?

What are your next plans for sf::String, sf::Text, sf::Font classes ;D?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New implementation for sf::Font in SFML 2
« Reply #17 on: December 15, 2009, 08:38:16 pm »
Quote
For example if I use one font, display text size 10 and then use size 50 I bet glyphs are rendered only if I exceed last maximum size?

No, actually the glyphs are rendered at every requested size. Scaling down a glyph is nearly as ugly as scaling it up ;)
So in this case you will end up with two textures: one containing the glyphs at size 10, and the other for size 50.
If this texture management causes problems, I can add functions to have more control over it (Clear(size), Preload(string, size), etc.). I'll just wait for "real situations" feedback ;)

Quote
Last one: rendered bold and regular glyphs are held separately?

Absolutely. A bold character produces a new glyph, even if the non-bold character is already loaded.

Quote
What are your next plans for sf::String, sf::Text, sf::Font classes ;D?

- sf::String: waiting for more feedback or better ideas; I'm not really satisfied with the current implementation but it will probably stay like that for now
- sf::Text: I'm going to implement text directions (right-to-left, top-to-bottom, etc.)
- sf::Font: I read two excellent articles about text rendering, and tried to improve the text quality in my implementation but I failed so far. I'm also waiting for feedback, but I'm pretty satisfied with the current implementation. It can be optimized regarding texture usage, but I need to tweak sf::Image to do so.
Laurent Gomila - SFML developer

Cierpliwy

  • Newbie
  • *
  • Posts: 23
    • View Profile
New implementation for sf::Font in SFML 2
« Reply #18 on: December 15, 2009, 08:59:53 pm »
Quote
No, actually the glyphs are rendered at every requested size.


So it's nicely done trap ;) For example user want to do effect which looks like:

Code: [Select]
text.SetCharacterSize((frames%100)/100);

And then... oops. My linux suspended in few seconds. No one knows what's going on :) The problem is that this function looks like a "scaling" one. In SFML 1 i used it a lot (but had a different name I think) so others also can misunderstand its meaning.

According to sf::String I will test it for a longer time and say something about it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New implementation for sf::Font in SFML 2
« Reply #19 on: December 15, 2009, 10:03:59 pm »
Absolutely, and that's why:
- SetCharacterSize now takes an unsigned int instead of a float (it no longer looks like a scale)
- The documentation and tutorials will strongly encourage to use SetScale to scale text :)
Laurent Gomila - SFML developer

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
New implementation for sf::Font in SFML 2
« Reply #20 on: December 31, 2009, 05:23:25 pm »
Is there still a default font?
Listen to my band: pencilcase.bandcamp.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New implementation for sf::Font in SFML 2
« Reply #21 on: December 31, 2009, 05:32:52 pm »
Of course, and there will still be a default font regardless of the way sf::Font is implemented, because I embed the Arial.ttf file directly in the source code and use LoadFromMemory.
Laurent Gomila - SFML developer

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
New implementation for sf::Font in SFML 2
« Reply #22 on: December 31, 2009, 05:41:40 pm »
Quote from: "Laurent"
Of course, and there will still be a default font regardless of the way sf::Font is implemented, because I embed the Arial.ttf file directly in the source code and use LoadFromMemory.


Ok, I just had a problem but it was related to the fact that I had a shader program loaded while trying to render stuff ;)
Listen to my band: pencilcase.bandcamp.com

 

anything