Dragonfly Q&A

Unable to load df-font.ttf

0 like 0 dislike

When I call

if (font.loadFromFile(FONT_FILE_DEFAULT) == false) {

return -1;
it keeps returning 1 becuase my font file isn't being loaded.
FONT_FILE_DEFAULT =  "df-font.ttf" right now but I also tried setting FONT_FILE_DEFAULT to the path of the text file but that also didn't work. Any idea as to why this is happening? Thank you
asked Sep 14, 2016 in Engine Development by elgonzalez

1 Answer

0 like 0 dislike
<p>It sounds like the font file is not in the right directory.  Remember, on Windows the code runs in Debug or Release directories.  You can even set the working directory, too (see Step 7 of <a href="http://dragonfly.wpi.edu/engine/setup-vs-2015.html">setup</a>).

<p>You might try to simplify the problem.  Make a separate program that does less - see if Listing 4.68 works as a stand alone (you can download all the Listings from the book web page (<a href="http://dragonfly.wpi.edu/book/listings.zip">zip</a>), so you don't have to type them in).  This will help you narrow down the font loading problem (putting it in the right directory, etc). Once you get that working, it should help you build upward to your engine.
answered Sep 14, 2016 by claypool

Thank you, I just fixed it. The problem was that when I linked it I wasn't using the debug versions of the sfml files, I was just using the regular versions. I also wasn't linking Winmm.lib.


More information about Dragonfly can be found on the Dragonfly Home Page.