Love2D could not open font.ttf. Does not exist

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
Afrricyn
Prole
Posts: 11
Joined: Fri Feb 21, 2020 4:17 pm

Love2D could not open font.ttf. Does not exist

Post 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:
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post 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.
Afrricyn
Prole
Posts: 11
Joined: Fri Feb 21, 2020 4:17 pm

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

Post by Afrricyn »

main.lua and font.ttf are within the same folder named 'pong'
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Afrricyn wrote: Fri Feb 21, 2020 4:21 pm However, this gives me an error code,
What error code?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post by raidho36 »

Check the spelling because it looks for exact match.
Afrricyn
Prole
Posts: 11
Joined: Fri Feb 21, 2020 4:17 pm

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

Post 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'
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

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

Post 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'.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 84 guests