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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
NobodysSon
Prole
Posts: 32
Joined: Tue Oct 30, 2012 10:37 pm

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

Post by NobodysSon » Thu Feb 23, 2017 8:12 am

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?

User avatar
Nixola
Inner party member
Posts: 1942
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Post by Nixola » Thu Feb 23, 2017 8:23 am

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.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
yetneverdone
Party member
Posts: 366
Joined: Sat Sep 24, 2016 11:20 am
Contact:

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

Post by yetneverdone » Thu Feb 23, 2017 8:27 am

Where is your font? Make sure the font is in your game directory

User avatar
NobodysSon
Prole
Posts: 32
Joined: Tue Oct 30, 2012 10:37 pm

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

Post by NobodysSon » Thu Feb 23, 2017 8:50 am

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!

User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post by raidho36 » Thu Feb 23, 2017 8:56 am

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.

User avatar
Nixola
Inner party member
Posts: 1942
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Post by Nixola » Thu Feb 23, 2017 8:57 am

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.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post by raidho36 » Thu Feb 23, 2017 9:01 am

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).

User avatar
NobodysSon
Prole
Posts: 32
Joined: Tue Oct 30, 2012 10:37 pm

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

Post by NobodysSon » Thu Feb 23, 2017 9:04 am

Hats off to all of you for the input!

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests