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

Author Topic: Cant load font from terminal  (Read 4130 times)

0 Members and 2 Guests are viewing this topic.

quicksilver

  • Newbie
  • *
  • Posts: 7
    • View Profile
Cant load font from terminal
« on: March 11, 2013, 06:57:39 pm »
I'm using Ubuntu 12.04 and Code::Blocks 12.11. I cloned the SFML 2.0 source and built it on my system.

Everything works fine when I run my app from Code::Blocks itself (graphics, sound, font). When I try to open the application from a terminal, however, I get "failed to load font ... (failed to create the font face)."

I have the font copied in the respective bin folders (Release and Debug), so the file path shouldn't be the issue. I am linking to the Release versions of the so files.

Any help?
Thanks in advance.
« Last Edit: March 11, 2013, 07:11:10 pm by quicksilver »

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Re: Cant load font from terminal
« Reply #1 on: March 11, 2013, 07:19:21 pm »
Are both the executable and the resources files located in the working directory (the one from which you launch the executable?)

quicksilver

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Cant load font from terminal
« Reply #2 on: March 11, 2013, 08:30:28 pm »
They are. Both the executable and its resources (only the font file in this particular app) are located in the same directory in each case (Code::Blocks creates executables in both bin/Release and bin/Debug).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Cant load font from terminal
« Reply #3 on: March 11, 2013, 08:35:52 pm »
If you run the application within Code::Blocks the default working directory will be next to the project file and thus the application will search there.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

quicksilver

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Cant load font from terminal
« Reply #4 on: March 11, 2013, 09:19:24 pm »
I understand that, and I have taken that into account. My project folder has the font file in it, as do both my Release and Debug folders. I don't think this is the problem.
« Last Edit: March 11, 2013, 10:42:02 pm by quicksilver »

quicksilver

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Cant load font from terminal
« Reply #5 on: March 11, 2013, 09:31:54 pm »
Update:

I put the absolute file path into the loadFromFile() function and the font loaded from the terminal. However, for any relative path such as "fontfile.ttf" or "./fontfile.ttf", I still get errors (the font file is placed directly with the executable and not in any sub-directories).

I'm used to Code::Blocks 10.04, could this be some change in the newer version?

exafi

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Cant load font from terminal
« Reply #6 on: March 19, 2013, 01:42:41 pm »
both we have same problem

I solved with this method ./fonts/arial.ttf
« Last Edit: March 19, 2013, 01:44:27 pm by exafi »

Steef435

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Cant load font from terminal
« Reply #7 on: March 24, 2013, 01:27:55 pm »
You first need to cd into the directory in which the font file is, and then start the app. Just copying the full path of you executable won't change your working directory to the path of the executable.

 

anything