Page 1 of 1

Love2D could not open font.ttf. Does not exist

Posted: Fri Feb 21, 2020 4:21 pm
by Afrricyn
I have a file called pong within that is main.lua and font.ttf and my program runs this code ->

mainFont = love.graphics.newFont('font.ttf', 9)
-- used to enter a new font style into memory for use
love.graphics.setFont(mainFont)
However, this gives me an error code, new to this so I have no clue what's wrong. Hope you can help? :oops:

Re: Love2D could not open font.ttf. Does not exist

Posted: Sat Feb 22, 2020 2:21 am
by raidho36
It has to be in the same folder as your main.lua file, because you didn't specify in which folder your font file is.

Re: Love2D could not open font.ttf. Does not exist

Posted: Sat Feb 22, 2020 11:14 am
by Afrricyn
main.lua and font.ttf are within the same folder named 'pong'

Re: Love2D could not open font.ttf. Does not exist

Posted: Sat Feb 22, 2020 2:34 pm
by pgimeno
Afrricyn wrote: Fri Feb 21, 2020 4:21 pm However, this gives me an error code,
What error code?

Re: Love2D could not open font.ttf. Does not exist

Posted: Sat Feb 22, 2020 3:01 pm
by raidho36
Check the spelling because it looks for exact match.

Re: Love2D could not open font.ttf. Does not exist

Posted: Sat Feb 22, 2020 4:56 pm
by Afrricyn
pgimeno wrote: Sat Feb 22, 2020 2:34 pm
Afrricyn wrote: Fri Feb 21, 2020 4:21 pm However, this gives me an error code,
What error code?
Error
Could not open file font.ttf. Does not exist.
Traceback
[C]: at 0x7ffec5fcca30
[C]: in function 'newFont'
main.lua:14: in function 'load'
[C] in function 'xpcall'
[C] in function 'xpcall'

Re: Love2D could not open font.ttf. Does not exist

Posted: Sat Feb 22, 2020 10:13 pm
by pgimeno
Is the file called 'font.ttf' exactly? Or is it like 'Font.ttf'?

Are you sure that the main.lua file you're running is the same that is in the same folder as the font?

There are also a few more things that could be wrong if you're using Windows, like having file extension visibility disabled and having the file called 'font.ttf.ttf'.