Search code examples
c++xcodefontssfml

Failed to load font in SFML


if (!font.loadFromFile("sansation.ttf"))
        {
            std::cout << "Failed to load font   ";
            return -1;
        }

Here is my code when I try to compile I get this error: Failed to load font "sansation.ttf" (failed to create the font face) Failed to load font Program ended with exit code: 255

Can anyone help me I have tried ./sansation.ttf I have tried the full directory and yet still no results I am using XCode.

Any help will be appreciated thanks, Rhys


Solution

  • I realized I had to Select "Edit Scheme…" in the "Product" menu;

    • Check the box "use custom working directory";
    • Fill the text field with the folder path containing your resources;