Page 1 of 1

Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 8:12 am
by NobodysSon
I am sure there is a simple answer to this but I have been struggling with the problem for the evening and I am out of ideas.

My game loads a .ttf font and displays it just fine when I run it from the editor, but as soon as I package it into a .love file the font can no longer be found. I get a "Cannot open file font.ttf. Does not exist." error. Opening up the .love file as a .zip file shows that it is certainly in there and the file structure hasn't been altered.

Please tell me what am I doing wrong?

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 8:23 am
by Nixola
Are you sure the case is correct? E.g. you can't load "font.ttf" in a .love file if the file is called "Font.ttf" or "font.TTF" or stuff like that.

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 8:27 am
by yetneverdone
Where is your font? Make sure the font is in your game directory

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 8:50 am
by NobodysSon
Are you sure the case is correct? E.g. you can't load "font.ttf" in a .love file if the file is called "Font.ttf" or "font.TTF" or stuff like that.
Thank you! This turned out to the be the problem... The file is font.TTF and I had it as "font.ttf" in the code. (Told you it would be a simple solution!)

Can you explain why it runs without problem from the editor but not when it is bundled up as a .love file?

Thank you for your input too yetneverdone!

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 8:56 am
by raidho36
It's because you're using Windows, and by extension the single adequate filesystem Windows supports - NTFS, which is not case sensitive. When you ask this filesystem to fetch a file by name, you can type in characters in any combination of capital and lowercase variants and it'll find the file. When the game is packaged, it no longer operates under filesystem, rather, it's hierarchically stored in a zip archive. When you ask zip archive to fetch an individual file, it will look for a file with exactly the characters you requested, if any one is different then lookup will fail. Most non-Microsoft filesystems are case-sensitive, too.

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 8:57 am
by Nixola
You're running this on Windows. While Windows' API for accessing files isn't case sensitive (even though the filesystem is... but that's not relevant), .zip files are. This means it will work flawlessly when loaded from a folder (on Windows only!), but the file will not be found in a .zip.
EDIT: kind of ninja'd, but still, NTFS by itself is case sensitive; it's just Windows' API which isn't. Don't ask me why.

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 9:01 am
by raidho36
Yes I stand corrected, the filesystem itself differentiates between character casing, the OS does not - by default (you can enable case sensitivity in OS configuration).

Re: Font can no longer be found when I make a .love package

Posted: Thu Feb 23, 2017 9:04 am
by NobodysSon
Hats off to all of you for the input!