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

Author Topic: PySFML 1.6 + Python 2.7 cannot load font?  (Read 7870 times)

0 Members and 1 Guest are viewing this topic.

Nya-chan Production

  • Newbie
  • *
  • Posts: 1
    • MSN Messenger - lrajecky@centrum.cz
    • AOL Instant Messenger - wolfiinka
    • View Profile
    • http://about.me/Nya_Chan_Production
PySFML 1.6 + Python 2.7 cannot load font?
« 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:

Code: [Select]
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:

Code: [Select]
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? ^^

Chèvre

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: PySFML 1.6 + Python 2.7 cannot load font?
« Reply #1 on: May 31, 2011, 05:09:00 pm »
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

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
Got the same problem
« Reply #2 on: June 14, 2011, 09:24:48 am »
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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Got the same problem
« Reply #3 on: June 14, 2011, 10:36:34 am »
Quote from: "andreaszdw"
Can someone tell me, when SFML 2 is released?
No ;)

But you can already use the Git version now.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
How use Git version
« Reply #4 on: June 14, 2011, 02:29:22 pm »
Hello,

can anyone tell me, how I can use the Git version?

Andreas

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
PySFML 1.6 + Python 2.7 cannot load font?
« Reply #5 on: June 14, 2011, 02:53:18 pm »
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.
Laurent Gomila - SFML developer