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

Author Topic: Cannot load TrueType font - SFML!!!  (Read 5226 times)

0 Members and 1 Guest are viewing this topic.

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Cannot load TrueType font - SFML!!!
« on: April 12, 2015, 04:12:33 pm »
All your help will be appreciated!
Here is my code, I linked all what i need and added DLLs and i have font next to executable in Debug folder, Here's my Visual C++ 2010 Express code:

#include <SFML\Graphics.hpp>
#include <Windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {

    sf::RenderWindow Application(sf::VideoMode(800, 600, 32), "SFML TrueType Font");

    sf::Color ApplicationColor;
    sf::Event event;

    while(Application.isOpen()) {
   
          while(Application.pollEvent(event)) {
        if(event.type == event.Closed)
             Application.close();

        }

    sf::Font font;
    sf::Text text;
   
    font.loadFromFile("stacky.ttf");

    text.setFont(font);
    text.setString("Stacky Font");
    text.setCharacterSize(36);
    text.setPosition(100.0f, 100.0f);
   
    Application.clear(sf::Color::White);
    Application.draw(text);
 
    Application.display();
   
    }

  return 0;
}
Please help, i will explode!!! :D
Born to be C++ Programmer!

S66

  • Full Member
  • ***
  • Posts: 120
  • *-*
    • View Profile
    • Teal
Re: Cannot load TrueType font - SFML!!!
« Reply #1 on: April 12, 2015, 06:53:05 pm »
Look your working directory ?

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #2 on: April 12, 2015, 09:25:53 pm »
But I think that will not help me, because when I start compiled solution...
.exe file starts and crashes and console opens.
But on the beginnig of console it says: 'Failed to load font <XP stacky.ttf'.
But thanks at all!
All resources are next to .exe file!

MasterDeveloper
Born to be C++ Programmer!

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #3 on: April 12, 2015, 09:29:13 pm »
I believe what was meant was "check what your programs current working directory is".
The CWD is not always the same as the dir that holds the .exe, so if you are looking for your font file in the CWD you may not find it if your CWD is not what you think it is.

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #4 on: April 12, 2015, 09:31:44 pm »
What is CWD???
Explain please!
Born to be C++ Programmer!

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #5 on: April 12, 2015, 09:34:14 pm »
I tried setting font directly from Windows\Fonts "arial.ttf"
But, the same problem!
Please can somebody help me!?!?!
All your help will be appreciated!
Born to be C++ Programmer!

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #6 on: April 12, 2015, 09:40:19 pm »
I tried to set font in "C:\Stacky.ttf" Here goes:
font.loadFromFile("C:\\Stacky.ttf");
But the same thing again and again please....
Somebody!
Born to be C++ Programmer!

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
« Last Edit: April 12, 2015, 09:49:34 pm by Jesper Juhl »

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #8 on: April 12, 2015, 09:46:40 pm »
Thanks I will try!  :-[
Born to be C++ Programmer!

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #9 on: April 12, 2015, 09:54:05 pm »
Ohhh my god!!!!! :D
I can't belive what was problem!!!
 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) :o :o :o 8) 8) ::) :-* :) >:(

This font was broken and at the moment all works fine
cos i downloaded another and that worked!!!

But I don't know why arial.ttf not worked, can you make example and write it please!!!
Born to be C++ Programmer!

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #10 on: April 12, 2015, 10:18:55 pm »
Dude, there is an edit button, learn to use it instead of writing 7 posts in 20 minutes. This isn't twitter...  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

MasterDeveloper

  • Newbie
  • *
  • Posts: 14
  • Forever, is not forever!
    • View Profile
    • Email
Re: Cannot load TrueType font - SFML!!!
« Reply #11 on: April 12, 2015, 10:45:50 pm »
I did it... DUDEEE!
Born to be C++ Programmer!

 

anything