Page 1 of 1

love.graphics.newFont crash segmentation fault on Fedora 19

Posted: Fri Jul 12, 2013 6:49 pm
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!

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

Posted: Fri Jul 12, 2013 6:56 pm
by T-Bone
Sounds like something that should be in the bug tracker.

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

Posted: Fri Jul 12, 2013 7:30 pm
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

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

Posted: Fri Jul 12, 2013 7:41 pm
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. :)

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

Posted: Fri Jul 12, 2013 8:23 pm
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?

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

Posted: Fri Jul 12, 2013 8:25 pm
by raidho36
Running out of memory doesn't causes segfault.

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

Posted: Sat Jul 13, 2013 7:33 am
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.

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

Posted: Sat Jul 13, 2013 7:42 am
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.

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

Posted: Sat Jul 13, 2013 9:22 am
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.

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

Posted: Sat Jul 13, 2013 1:56 pm
by Robin
Glad your issue is now resolved! Don't hesitate to ask again later if you have other issues.