SFML community forums
Help => Graphics => Topic started by: scyth3s on May 18, 2011, 04:58:40 pm
-
I have this code, which, for test purposes, I copied and pasted directly from the 1.6 tutorial.
sf::Font MyFont = sf::Font::GetDefaultFont();
// Create a graphical string
sf::String Hello;
Hello.SetText("Hello !\nHow are you ?");
Hello.SetFont(MyFont);
Hello.SetColor(sf::Color(0, 128, 128));
Hello.SetPosition(100.f, 100.f);
Hello.SetRotation(15.f);
Hello.SetSize(50.f);
And I get the runtime error in the title bar. I've tried having SFML load Xirod font, which I put in the project folder (VS 2010) and the executable folder. No dice.
-
Do NOT use the default font. Last I checked, it's completely broken and results in errors. It might just be a specific version of SFML, though.
-
The default font should work fine. But maybe it's the copy that is broken, try to get a reference on the default font instead of copying it.
-
Do NOT use the default font. Last I checked, it's completely broken and results in errors. It might just be a specific version of SFML, though.
That's odd. Isn't it just a copy of the Arial font? Should I always provide a font file instead? Sorry for the thread-hijacking, just curious.
-
Do NOT use the default font. Last I checked, it's completely broken and results in errors. It might just be a specific version of SFML, though.
I also tried loading Xirod TTF. Is there a specific spot on my hard drive it must be in?
maybe it's the copy that is broken, try to get a reference on the default font instead of copying it
As in sf::Font &MyFont = sf::Font::GetDefaultFont(); ?
I have tried both of these, and neither lent any dice. Linking with the debug libraries has yielded nothing as well.
Some more code snippets:
GButton.h
/////////////////////
/// The font that the button class will use
/////////////////////
const sf::Font *font;
GButton.cpp
GButton::GButton(sf::RenderWindow& window, std::string text, sf::Color selectedColor, sf::Color deselectedColor)
{
//set the render window
this->window = &window;
//set the colors
this->selectedColor = selectedColor;
this->deselectedColor = deselectedColor;
//reference to the default font
font = &sf::Font::GetDefaultFont();
this->text = sf::String(text, *font, 30);
}
GButton.cpp
void GButton::Draw()
{
window->Draw(text);
}
I couldn't get a module level const variable reference to compile, so I tried a pointer. Still the same runtime error. However, I did notice that no matter what I do, the font for the sf::String 'text' seems to have an invalid size
(http://i128.photobucket.com/albums/p187/LaKrakken/relaventerror.png)[/img]
-
Would a minimal example (just a window, the font and a text) still reproduce the error? If so, copy it there and I'll test it.
-
I did some digging, and apparently, SFML was/is buggy with VS2010? I compiled my project in VS2008 and it worked all fine and dandy.
-
The VC2008 libs are not compatible with VC2010, you must recompile SFML to use it with VC2010.
-
AHA! This solved it. I never read about compiling it myself before! Interesting that it never caused me any issues until that text thing.