Love2d font segmentation fault (core dumped)


Updated
After debugging and tested on several laptop and OS (OSX, Fedora 18 and Windows 8), the culprit is because Nouveau driver (OpenSouce VGA driver for Nvidia) can’t works with OpenGL perfectly. After installing Nvidia properietary drivers, everything must be works. This is because VGA drivers.

Here is my question in Love2D forum

I change my OS with Ubuntu 13.04 which working perfect with Macbook Pro (installation tutorial)

======================================================================================================

As a newcomer with Love2d, i started using custom font with following the tutorials (http://love2d.org/wiki/love.graphics.newFont)

1
2
3
4
5
6
7
8
9
— load ttf file font. set 20px font-size
mainFont = love.graphics.newFont("font.ttf", 20)

function love.draw()
    — set font before draw text
    love.graphics.setFont(mainFont)
    — draw text "Hello world!" at left: 100, top: 200
    love.graphics.print("Hello world!", 100, 200)
end

Which this give me segmentation fault (core dumped) results. I have no idea why this happen. Fyi, I’m using Macbook Pro and Fedora 19.

Then i tried this tutorial (https://love2d.org/wiki/Tutorial:Callback_Functions) :

1
2
3
4
5
6
7
function love.load()
   image = love.graphics.newImage("cake.jpg")
   local f = love.graphics.newFont(12)
   love.graphics.setFont(f)
   love.graphics.setColor(0,0,0,255)
   love.graphics.setBackgroundColor(255,255,255)
end

It’s also showing the same results. After struggling and searching, i found another way around how to use font :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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

I have no idea why this is works. But I know this is wrong. Since we shouldn’t put this on loop function like update() or draw(). Meanwhile I will looking this answer in Love2d forum. Hope this help somebody that just started learn love2d. Don’t give up! This engine is powerfull!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.