SFML community forums
Bindings - other languages => Python => Topic started by: Nya-chan Production on May 30, 2011, 04:17:48 pm
-
Got a weird error on Win7, while trying to import font to my game via this class:
class StartText(GameText):
def Create(self, text, xpos, ypos, active):
font = sf.Font()
font.LoadFromFile('Arial.ttf')
self.active = active
if self.active == False:
self.text = sf.String(text, font, Size = 10)
else:
self.text = sf.String(text, font, Size = 12)
self.text.Italic
self.text.SetColor(sf.Color(0, 0, 0))
self.text.SetPosition(xpos, ypos)
On suggestion from IRC I simplified it to this in a separate file:
from PySFML import sf
font = sf.Font()
print 1
font.LoadFromFile(" Arial.ttf ")
print 2
This prints 1 and then crashes without an error, python just stops working. In both cases Arial.ttf is in the same folder as the script and is correctly capitalized. Anyone else experienced this or knows how to fix it? ^^
-
Your method looks correct. Back when I used SFML 1.6, I used to load fonts like you did in the second example.
However, those extra spaces around 'Arial.ttf' seem weird to me.
And you say that Python crashes "without an error" -- as in nothing appears in the console window? Are you running Python from the command line?
If it still doesn't work, then maybe your Arial.ttf file is faulty somehow?
Also, if you're starting a new project, I'd recommand using the new SFML 2 binding: https://github.com/bastienleonard/pysfml2-cython
-
Hello,
I have the same problem, runs fine under Linux and XP, but not
under Vista.
Can someone tell me, when SFML 2 is released?
Andreas
-
Can someone tell me, when SFML 2 is released?
No (http://www.sfml-dev.org/forum/viewtopic.php?t=5014) ;)
But you can already use the Git version now.
-
Hello,
can anyone tell me, how I can use the Git version?
Andreas
-
Use a Git client (TortoiseGit on Windows) to get the source directly from the repository, or download a snapshot from the download page of the website. Then follow the tutorial (the only one for 2.0) to compile SFML.