SFML community forums

Help => Graphics => Topic started by: Tank on February 19, 2010, 03:22:30 pm

Title: Copying of sf::Fonts fails
Post by: Tank on February 19, 2010, 03:22:30 pm
Hey,

when copying fonts, the destination object is somehow invalid. I guess something doesn't get copied properly.

Minimal example:
#include <SFML/Graphics.hpp>

int main() {
        sf::RenderWindow  window( sf::VideoMode( 800, 600, 32 ), "Muh" );

        sf::Font  afont;

        {
                sf::Font  tmpfont;
                tmpfont.LoadFromFile( "whatever.ttf" );
                afont = tmpfont;
        }

        sf::Text  text( L"Foo", afont, 50 );

        window.Clear();
        window.Draw( text );
        window.Display();

        sf::Sleep( .5f );
}
 

Backtrace:
Code: [Select]
#0  0x00007ffff5cfd1d5 in FT_Request_Size () from /usr/lib/libfreetype.so.6
#1  0x00007ffff5cfd295 in FT_Set_Pixel_Sizes () from /usr/lib/libfreetype.so.6
#2  0x00007ffff76dfce4 in sf::Font::SetCurrentSize(unsigned int) const () from /usr/local/lib/libsfml-graphics.so.2.0
#3  0x00007ffff76e0d0f in sf::Font::LoadGlyph(unsigned int, unsigned int, bool) const () from /usr/local/lib/libsfml-graphics.so.2.0
#4  0x00007ffff76e109c in sf::Font::GetGlyph(unsigned int, unsigned int, bool) const () from /usr/local/lib/libsfml-graphics.so.2.0
#5  0x00007ffff76ec835 in sf::Text::Render(sf::RenderTarget&, sf::Renderer&) const () from /usr/local/lib/libsfml-graphics.so.2.0
#6  0x00007ffff76e785a in sf::RenderTarget::Draw(sf::Drawable const&) () from /usr/local/lib/libsfml-graphics.so.2.0
#7  0x0000000000402bd1 in main () at s.cpp:19

This happens in the line with "window.Draw()", but everything else that accesses the font's properties leads to this error, too.

SFML is version 2, revision 1412 on Debian GNU/Linux.
Title: Copying of sf::Fonts fails
Post by: Laurent on February 19, 2010, 03:30:07 pm
Nice bug :)

I check that right now.
Title: Copying of sf::Fonts fails
Post by: Laurent on February 19, 2010, 03:38:37 pm
Fixed.

Thanks for your feedback and for the code :)
Title: Copying of sf::Fonts fails
Post by: Tank on February 19, 2010, 03:49:52 pm
No problem, been a pleasure. ;) Thanks for the fast fix.