love.graphics.newFont crash segmentation fault on Fedora 19

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
bashlook
Prole
Posts: 3
Joined: Fri Jul 12, 2013 5:40 pm

love.graphics.newFont crash segmentation fault on Fedora 19

Post by bashlook »

Hi All,

I just learn about Love2D one day ago.
I'm curious about what the reason love.graphics.newFont crash and give me segmentation fault in Fedora 19.

Fyi, i'm installing Love2D from Fedora Repo (0.8.0) and works well without any problems except this custom fonts.

This tutorial http://love2d.org/wiki/love.graphics.newFont doesn't works in Fedora 19 (gave segmentation fault).
I have no idea until i put it on draw() which is i know it's wrong.

This is works

Code: Select all

function love.load()
    -- NEW
    screen_width = 500
    screen_height = 300

    love.graphics.setCaption('GAME')
    love.graphics.setMode(screen_width, screen_height)
end

function useTTFFont(text,x,y,size)
    local font=love.graphics.newFont("font.ttf",size)
    love.graphics.setFont(font)
    love.graphics.print(text,x,y)
end

function love.update(dt)
end

function love.draw()
    useTTFFont("Hello World",210,160,28)
end
Image

Could anybody help me how to solve this issue ?

Many thanks!
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by T-Bone »

Sounds like something that should be in the bug tracker.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by Robin »

Don't call love.graphics.new* in love.update or love.draw, because that creates a new font object every frame.

Interesting that is the one that does work...

Have you tried putting mainFont = love.graphics.newFont("anyfont.ttf", 20) inside love.load? That would make your code:

Code: Select all

function love.load()
    -- NEW
    screen_width = 500
    screen_height = 300

    love.graphics.setCaption('GAME')
    love.graphics.setMode(screen_width, screen_height)
    font=love.graphics.newFont("font.ttf", 28)
    love.graphics.setFont(font)
end

function love.draw()
    love.graphics.print(("Hello World",210,160)
end
Help us help you: attach a .love.
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by slime »

T-Bone wrote:Sounds like something that should be in the bug tracker.
Only if it's still an issue in the latest 0.9.0 nightlies, many bugs have been fixed since 0.8.0's release. :)
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by T-Bone »

Robin wrote:Don't call love.graphics.new* in love.update or love.draw, because that creates a new font object every frame.

Interesting that is the one that does work...

Have you tried putting mainFont = love.graphics.newFont("anyfont.ttf", 20) inside love.load? That would make your code:

Code: Select all

function love.load()
    -- NEW
    screen_width = 500
    screen_height = 300

    love.graphics.setCaption('GAME')
    love.graphics.setMode(screen_width, screen_height)
    font=love.graphics.newFont("font.ttf", 28)
    love.graphics.setFont(font)
end

function love.draw()
    love.graphics.print(("Hello World",210,160)
end
While it will if course be slow to create a new font every frame, it shouldn't just segfault, should it? Or does it perhaps run out of memory?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by raidho36 »

Running out of memory doesn't causes segfault.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by Boolsheet »

I'm unable to reproduce the issue. You say it only happens with one specific font? Are you able to share the font with us?

We're a bit limited to guesses here. If you're familiar with gdb, post a backtrace after the segfault. This should give us good information on the culprit.
Shallow indentations.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by Robin »

T-Bone wrote:While it will if course be slow to create a new font every frame, it shouldn't just segfault, should it? Or does it perhaps run out of memory?
That's what I thought before writing my post, but then I reread bashlook's post and it appears that it works the other way around: it segfaults when they try the thing that doesn't flush memory like crazy.
Help us help you: attach a .love.
bashlook
Prole
Posts: 3
Joined: Fri Jul 12, 2013 5:40 pm

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by bashlook »

Hi All,

Thanks for you replies! I'm very appreciate that!
Finally i find the culprit!

I have tried this on Windows 8 (Different laptop) and OS X Lion (Same laptop) and everything is works!
Funny things, I tried my Pyglet game on Fedora 19 also can't work with font rendering stuff (segmentation fault error as well)

Then, after long debugging, i found the VGA driver nouveau (for Nvidia) doesn't works well with OpenGL.
After revert into Fedora 18 (fresh install), Love2D running smoothy and i can set font in correct way, not update() nor draw()

This issue definitely not about Love2d but more like VGA and OS things.
I'm sorry if i'm asking wrong question here.

Again, thanks for your feedback guys.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: love.graphics.newFont crash segmentation fault on Fedora

Post by Robin »

Glad your issue is now resolved! Don't hesitate to ask again later if you have other issues.
Help us help you: attach a .love.
Post Reply

Who is online

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