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

Author Topic: Problem changing fonts  (Read 4479 times)

0 Members and 1 Guest are viewing this topic.

Galax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problem changing fonts
« on: March 03, 2008, 05:14:17 pm »
Hello,
I have problem changing the font of my sf::String. Do I have to put the .tff in  the directorie of my project? I tried this code :

sf::String Text("text", "arial.tff", 36.f);

and this one after :

Text.SetFont("arial.tff");

When I compile, Text has the sans serif font. I also tried with other fonts and with some I found on internet. Sans serif again and again.

Can someone tell me what is my problem?

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Re: Problem changing fonts
« Reply #1 on: March 03, 2008, 05:43:14 pm »
Quote
Do I have to put the .tff in  the directory of my project?

Yes, otherwise the built-in font will be used.
Also, there is no need for Text.SetFont() after
sf::String Text("text", "arial.tff", 36.f);
as it already sets the "arial.ttf" as active font.
(I could be wrong since I always sync with the svn repository).

Galax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problem changing fonts
« Reply #2 on: March 05, 2008, 05:54:45 pm »
I know there's no need for the .SetFont(). I just wanted to tell you that i tried both methods. I put the .tff in the directorie of m project. Sans serif again.

Does somebody knows what is the problem?

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Problem changing fonts
« Reply #3 on: March 05, 2008, 06:19:59 pm »
If you are using VisualStudio, make sure it is in your working directory.
What happens if you try to load an image from that directory?

I figured out, that the lettering could be a problem.
If your file is named "Arial.ttf" and you try to load it as "arial.ttf", it will fail (at least under linux).

T.T.H.

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Problem changing fonts
« Reply #4 on: March 06, 2008, 12:11:54 am »
When using Visual Studio please note that in the project settings is an option Configuration Properties -> Debugging -> Working Directory which sets the working directory. AFAIK in VS2003 it's a difference whether you start the exe from within the IDE (with F5) which used that option then or whether starting the exe manually which automatically sets the working directory at the directory the exe is in or from where you call the exe. In VS2005 the whole project is in a subdirectory so when loading stuff the path "..\\myimage.jpg" works.

All in all just care what your working directory is and where your exe file is located and where your image/font/resource file is located. Yes, it's a mess  :roll: