## The 'Newfont' function isn't working

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

### The 'Newfont' function isn't working

I was attempting to use a font I downloaded and it gives me this error when I attempt to use the newfront function.

The error message
Error
main.lua:17: attempt to call feild 'NewFont' (a nil value)
Traceback
[C]: in function 'xpcall'

here's the code involved

Code: Select all

end

function love.draw(dt)
love.graphics.draw(Rectongolusbackground.Img, Rectongolusbackground.x, Rectongolusbackground.y)
love.graphics.print("press 'enter' to start", 640, 360)
end

Rectongolusbackground.Img = love.graphics.newImage('Assets/Rectbackground.png')
rng = love.math.newRandomGenerator()
randomNumber = rng:random(1,100)
end

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: The 'Newfont' function isn't working

NewFont isn't capitalized. Proper capitalization is important. It's newFont. All the functions Löve uses are camelCased with the first letter being lowercase. It's one of a few different naming conventions coders use. Like function_name vs. functionName vs. functionname. I prefer camelCase myself. And it just looks weird to capitalize the first character of a function name or variable. But everyone does it different. Since you have a habit of Capitalizing names I can see how you'd make that mistake.

Cheers!

gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

### Re: The 'Newfont' function isn't working

Jasoco wrote:NewFont isn't capitalized. Proper capitalization is important. It's newFont. All the functions Löve uses are camelCased with the first letter being lowercase. It's one of a few different naming conventions coders use. Like function_name vs. functionName vs. functionname. I prefer camelCase myself. And it just looks weird to capitalize the first character of a function name or variable. But everyone does it different. Since you have a habit of Capitalizing names I can see how you'd make that mistake.

Cheers!
Thanks for the help I appreciate it.

Unfortunately I am having a new problem, it's saying it can't find the font, I've included pictures of the error, the way I have the files set up for the game, and a picture of the assets folder itself. Code is the same as in the main post, just with it capitalized like 'newFont'.
Attachments
Assets folder
Screen Shot 2016-05-13 at 11.29.56 PM.png (25.68 KiB) Viewed 920 times
File Set up
Screen Shot 2016-05-13 at 11.29.43 PM.png (23.05 KiB) Viewed 920 times
Error
Screen Shot 2016-05-13 at 11.29.30 PM.png (35.72 KiB) Viewed 920 times

Tjakka5
Party member
Posts: 240
Joined: Thu Dec 26, 2013 12:17 pm

### Re: The 'Newfont' function isn't working

You typed .tff instead of .ttf
Check out my portfolio: http://tjakka5.sorunome.de/

gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

### Re: The 'Newfont' function isn't working

Tjakka5 wrote:You typed .tff instead of .ttf
omg I feel so dumb, lol, thanks!

### Who is online

Users browsing this forum: Google [Bot], Ulydev and 20 guests