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

Author Topic: SF::Font - somehow a glyph getting corrupted.  (Read 12543 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SF::Font - somehow a glyph getting corrupted.
« Reply #15 on: July 28, 2018, 05:27:23 pm »
You mentioned threads? Do you use Font in few? getGlyph is marked as const but it can do modifications and it's not threadsafe.
Back to C++ gamedev with SFML in May 2023

Cheeseness

  • Newbie
  • *
  • Posts: 13
  • I write, make, draw, play, game & everything else
    • View Profile
    • Cheese Talks
Re: SF::Font - somehow a glyph getting corrupted.
« Reply #16 on: July 29, 2018, 02:31:43 am »
What really confuses me is the fact that not only your glyphs are somehow mangled, they're also not using the correct dimensions/alignment. As such I still think it's some weird issue in Freetype rather than SFML. Not 100% sure though.
This was my first thought when I encountered it. It's definitely not something I'm willing to rule out, but hopping between Freetype versions and trawling their issue tracker hasn't shown anything that's stood out as relevant to me so far.

You mentioned threads? Do you use Font in few? getGlyph is marked as const but it can do modifications and it's not threadsafe.
We assign the font to Text variables (via sfe::RichText) outside of the main thread, but we do the actual rendering in the main thread. From what I understand of how SFML's font class works, new glyphs are loaded as part of draw() calls rather than during font/string assignment (it's another possibility I don't want to rule out, though).

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SF::Font - somehow a glyph getting corrupted.
« Reply #17 on: July 29, 2018, 03:01:48 am »
Getting bounds of sf::Text triggers a rebuild too and you seem to be doing that in RichText::Line::updateTextAndGeometry which is called by RichText::Line::updateGeometry (and in appendText) which is called after setting style, color, font, etc. in a Line (which are called by corresponding RichText functions).
Back to C++ gamedev with SFML in May 2023

Cheeseness

  • Newbie
  • *
  • Posts: 13
  • I write, make, draw, play, game & everything else
    • View Profile
    • Cheese Talks
Re: SF::Font - somehow a glyph getting corrupted.
« Reply #18 on: July 29, 2018, 08:57:40 am »
Getting bounds of sf::Text triggers a rebuild too and you seem to be doing that in RichText::Line::updateTextAndGeometry which is called by RichText::Line::updateGeometry (and in appendText) which is called after setting style, color, font, etc. in a Line (which are called by corresponding RichText functions).
Ah ha, right you are!

From what I'm reading in the SFML source, it seems like we should only be encountering problems when getGlyph() calls are called outside the main thread for glyphs that haven't already been cached, so my workaround of pre-populating the cache with every character when the font is loaded should get us in the clear for this use-case?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SF::Font - somehow a glyph getting corrupted.
« Reply #19 on: July 30, 2018, 05:32:18 am »
Yes, I think so.
Back to C++ gamedev with SFML in May 2023

Cheeseness

  • Newbie
  • *
  • Posts: 13
  • I write, make, draw, play, game & everything else
    • View Profile
    • Cheese Talks
Re: SF::Font - somehow a glyph getting corrupted.
« Reply #20 on: July 30, 2018, 01:29:32 pm »
Cheers. Many thanks for walking through this one with us!

 

anything