Fonts

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

Post by Robin »

kikito wrote:I agree with the first part of your phrase (everyone should pre-create fonts) but not with the second (except if they are too wasteful).
Perhaps I wasn't clear. I never meant to suggest it's okay if they are wasteful with resources, but merely that they would bring themselves in impossible situations anyway, with or without creating fonts.
kikito wrote:It is also a problem of "unclear interface". Nothing in the name of the functions suggests that a new font is created. Tutorials use these functions but don't specify that. This confuses people. Not only people learning LÖVE, but also from the love core team.
True, this should be in the docs.
Help us help you: attach a .love.
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: Fonts

Post by qubodup »

I skipped thread, sorry for that!

Unicode support yay! Pyglet does it for example http://www.flickr.com/photos/qubodup/4282981539/

Don't forget to add RtL support (right to left) so I can type العربية the right way (hurr-hurr, I said "right"). Pyglet doesn't support RtL currently. and I'm obsessed with comparison.
Last edited by qubodup on Mon Feb 01, 2010 9:21 am, edited 1 time in total.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Fonts

Post by rude »

kikito wrote:It is also a problem of "unclear interface". Nothing in the name of the functions suggests that a new font is created.
You're right. This shouldn't be documented, it should be changed.
Odysseus
Prole
Posts: 2
Joined: Mon Feb 08, 2010 6:37 am

Re: Fonts

Post by Odysseus »

Here is an idea about unicode support inspired by discussion in this topic. Instead of rasterizing the whole unicode font and sending it to GPU, text can be pre-rendered to some image, and then only this image could be sent to GPU. Pre-rendering itself could be not so fast, but once it is done the resulting image could be cached and then drawn at the speed of arbitrary image drawing.

To facilitate the reuse of pre-rendered image "printf" concept could be changed to "text box" concept. Thus, instead of

Code: Select all

love.graphics.setFont(filename, size);
love.graphics.draw("I LÖVE Unicode", 100, 100);
one would write something like

Code: Select all

tb = love.graphics.newTextBox("I LÖVE Unicode", filename, size);
love.graphics.draw(tb, 100, 100);
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

Post by Robin »

Odysseus wrote:Here is an idea about unicode support inspired by discussion in this topic. Instead of rasterizing the whole unicode font and sending it to GPU, text can be pre-rendered to some image, and then only this image could be sent to GPU. Pre-rendering itself could be not so fast, but once it is done the resulting image could be cached and then drawn at the speed of arbitrary image drawing.
May works well with static text, but I think much of the text used in games will be dynamic anyway, which defeats the whole purpose of pre-rendering.
Odysseus wrote:To facilitate the reuse of pre-rendered image "printf" concept could be changed to "text box" concept. Thus, instead of

Code: Select all

love.graphics.setFont(filename, size);
love.graphics.draw("I LÖVE Unicode", 100, 100);
one would write something like

Code: Select all

tb = love.graphics.newTextBox("I LÖVE Unicode", filename, size);
love.graphics.draw(tb, 100, 100);
I assume you meant love.graphics.print in both examples. ;)
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Fonts

Post by kikito »

To facilitate the reuse of pre-rendered image "printf" concept could be changed to "text box" concept.
On its current state, text rendering is slow (or so others say; I haven't tested this myself) so any kind of caching would help. So I see some utility on having some sort of caching, specially if text rendering can't be done faster.

However, I don't like your proposed implementation (the "textbox"). I think it is too limited to text.

It would be better if we could render any draw function onto an imageData object (feature requested already) so one could do something like this:

Code: Select all

font = love.graphics.newFont(filename, size)
...
local text = "I LÖVE Unicode"
-- create an imageData as tall and wide as the text on the created font
local width, height = font:getWidth(text), font:getLineHeight()*font:getHeight()
local imageData = love.image.newImageData(width, height)
love.graphics.setFont(font)
imageData:print(text,0,0) -- Print the text on imageData
imageData:rectangle('line',0,0,width,height) -- This adds a rectangle. I could do more stuff here, like adding other sprites, etc
image = love.graphics.newImage(imageData)
...
love.graphics.draw(image, 100, 100)
This isn't possible right now since imageData only admits setPixel and pasting squared sections from other imageDatas.
When I write def I mean function.
Odysseus
Prole
Posts: 2
Joined: Mon Feb 08, 2010 6:37 am

Re: Fonts

Post by Odysseus »

Robin wrote: I assume you meant love.graphics.print in both examples. ;)
Yes, sorry for typos :)
Robin wrote: May works well with static text, but I think much of the text used in games will be dynamic anyway, which defeats the whole purpose of pre-rendering.
As far as I understand from the thread mentioned above, caching is done anyway at GPU level. So the suggestion was actually to replace caching of 65000+ unicode character glyphs (which seems to be major showstopper to unicode support) with caching of much more limited number of pre-composed messages that use these glyphs.
kikito wrote: However, I don't like your proposed implementation (the "textbox"). I think it is too limited to text.
Well, your suggested approach is more flexible and "textboxes" could be easily implemented on top of it in pure Lua, so I vote for it. The only additional feature request would be the ability to draw unicode text onto imageData.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests