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

Author Topic: Failed to create font face  (Read 10069 times)

0 Members and 1 Guest are viewing this topic.

0ii0

  • Newbie
  • *
  • Posts: 3
    • View Profile
Failed to create font face
« on: January 01, 2014, 11:34:17 pm »
I am getting this error... "Failed to load font "Georgia.ttf" (failed to create the font face)".

The spelling in my program is correct. And I've more than triple checked that it's in the right location. I've also tried using different fonts, to no avail. Note that in a separate program, the font georgia DOES work

I'm using Xcode if that's any help.
SFML 2.1
And I use a macbook, OS 10.7.5


.cpp
#include <SFML/Graphics.hpp>
#include <main.hpp>

//GlobalVariables (I know they're bad, I'll work on this)

sf::RenderWindow window;

sf::Event event;
sf::Keyboard keyboard;

sf::Font georgia;

//class Initialization______________________________________________
    void Initialization::programInit()
    {
        renderWindow();
        loadGeorgia();
    }

    void Initialization::renderWindow()
    {
        window.create(sf::VideoMode(width, height), "Pong", sf::Style::Default);
        window.setFramerateLimit(frameLimit);
        window.setVerticalSyncEnabled(true);
        window.clear(sf::Color::White);
       
    }

    bool Initialization::loadGeorgia()
    {
        if(!georgia.loadFromFile("Georgia.ttf"))
            return EXIT_FAILURE;
       
        return EXIT_SUCCESS;
    }

//main()______________________________________________
int main()
{
    init.programInit();
    gameFlow.beginGameFlow(); //I didn't include this class, but this is where the font is used
   
    return EXIT_SUCCESS;
}

 

.hpp
#ifndef Pong2_Header_h
#define Pong2_Header_h

class Initialization
{
public:
    static const int width  = 800;
    static const int height = 600;
    static const int frameLimit = 60;
   
    void programInit();

    void renderWindow();
    bool loadGeorgia();
   
};
Initialization init;

int main();

#endif

 
« Last Edit: January 02, 2014, 02:14:00 am by 0ii0 »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Failed to load font face error
« Reply #1 on: January 02, 2014, 12:19:36 am »
  • Don't use global variables... I don't know how many times we need to say this
  • And read this
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

0ii0

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Failed to load font face error
« Reply #2 on: January 02, 2014, 01:27:51 am »
Ok sorry about that. I missed that post. I got rid of a lot of the irrelevant parts of code... as for global variables. I have them now as sort of placeholders, until i can come up with better ways to deal with those specific variables. I am aware that they're bad practice

« Last Edit: January 02, 2014, 01:33:32 am by 0ii0 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Failed to load font face error
« Reply #3 on: January 02, 2014, 01:38:46 am »
It's not just about bad practice, but there are also issues with global construction and destruction orders, besides that, you've already sort structured your code for a class, why not simply put it inside a class? ;)

Have you placed the font in the right directory, so the application can actually find it?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

0ii0

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Failed to load font face error
« Reply #4 on: January 02, 2014, 01:46:40 am »
It's not just about bad practice, but there are also issues with global construction and destruction orders, besides that, you've already sort structured your code for a class, why not simply put it inside a class? ;)

Have you placed the font in the right directory, so the application can actually find it?

Ohh thanks, that makes sense haha. I'm self-teaching so I don't always understand everything (i try though).

And yes, the font is in the right directory. in Xcode, when you drag something into the project navigator, it automatically deals with that for you. BUT i double checked anyways

 

anything