1
Graphics / Re: SF::Text not properly rendering
« on: September 01, 2021, 12:21:01 pm »The Get_Font_By_Name function returns a reference to a Font. But it only contains a return for the font found path, if a font wasn't found there's no return, meaning it is returning an invalid reference.Thank you for the advice. I am returning the first element in the array if the font isn't found, but I decided to keep it out of the code example to reduce the noise.
But that's a separate issue (assuming you don't ask for a font with the wrong name).
The main problem appears to be ThisFont in _LoadFonts. The header comments for sfml's loadFromMemory say that the buffer must remain valid for the life of the font (so sounds like it doesn't copy the data, just uses it). But ThisFont is temporary, it is deleted when it goes out of scope after each font in the loop.This was it, I had missed that note. I should not have assumed the loadFromMemory() function for fonts would work the same way as for textures. Thank you for the quick and helpful reply!
You'll need to store the data you get back from the database in something more persistent, copy it into a block of heap memory and store the pointer and size of that block in the Font_t struct as well.