Page 1 of 3

Fonts

Posted: Tue Jan 19, 2010 7:35 pm
by rude
The next "big" LÖVE-related task I will undertake is probably better Font support. Let's gather some ideas and requests for what we want.
  • Unicode support.
  • Better performance.
  • Top-left origin as default.
  • Parameterized origin.
  • Allocate same Font only once.
(Warning: just because something appears in the list does not mean it will be implemented. These are ideas for requirements.)

Anything else? Will update the list when suggestions arrive.

Re: Fonts

Posted: Tue Jan 19, 2010 7:38 pm
by Robin
rude wrote:Unicode support.
I am very much in favor of that. 8-)

Re: Fonts

Posted: Tue Jan 19, 2010 8:19 pm
by Virox
Could it be possible to have a choise (boolean) if you want font's bottom left origin or some command...?
But if i'm the only one who wants to keep bottom left, ignore me :)

Re: Fonts

Posted: Tue Jan 19, 2010 8:28 pm
by Robin
Virox wrote:Could it be possible to have a choise (boolean) if you want font's bottom left origin or some command...?
But if i'm the only one who wants to keep bottom left, ignore me :)
Or, in line with .draw(), an ox and oy parameter.

Re: Fonts

Posted: Tue Jan 19, 2010 8:38 pm
by TechnoCat
Maybe not font specific per se, but anyways:
Expand love.graphics's print and printf
from

Code: Select all

love.graphics.print(text, x,y, r, sx,sy)
love.graphics.printf(text, x,y, limit, align)
to

Code: Select all

love.graphics.print(text, x,y, r, sx,sy, ox,oy)
love.graphics.printf(text, x,y, r, sx,sy, ox,oy, limit, align)

Re: Fonts

Posted: Tue Jan 19, 2010 11:20 pm
by kikito
Love should keep track of the already-instantiated fonts, and return them instead of creating new ones.

I mean, if you do this twice:

Code: Select all

  love.newFont(f, 12)
  love.newFont(f, 12)
It should allocate the font only once.

Re: Fonts

Posted: Tue Jan 19, 2010 11:37 pm
by kikito
I'd also like to have a way of controlling the *height* the text will have when making a printf with fixed width.

Or at least the number of lines it will get splitted into. Or both the height & number of lines.

Re: Fonts

Posted: Wed Jan 20, 2010 6:30 am
by bartbes
kikito wrote:Love should keep track of the already-instantiated fonts, and return them instead of creating new ones.
That doesn't happen with images either, and is trivial to write yourself.

Re: Fonts

Posted: Wed Jan 20, 2010 8:40 am
by kikito
mmm I thought so too, at the beginning, but I'm not finding it as trivial as I thought.

My biggest issue comes from the fact that there's no way to tell fonts appart, when they are being created dynamically (i.e. different heights)

Sure enough, I can have complete control over my fonts if I am developing a complete game. I can load/create them on the love.load() stage and then reference them on the game. However, if I am writing a game engine (or a GUI library) this is not that simple. I don't have control over the loading phase. When the user says "use this font, with this height" it is kind of difficult to know whether the font has already been instantiated somewhere with that height, or whether I have to create it myself.

So let me rephrase my request then: I'd like fonts to be more easily identifiable. For example: It would help having a "getParentFont()" & "getOriginalFont()" for fonts created with different heights. If f1 is loaded from a file, and f2 is f1 with height=33, then f2:getParentFont() should return f1. If f3 is f2 with height=14, then f3:getParentFont() will return f2, and f3:getOriginalFont() will return f1.

A "getType()" would also be nice ('string', 'ttf', you get the idea)

EDIT: added f3 and getOriginalFont

Re: Fonts

Posted: Wed Jan 20, 2010 12:11 pm
by Robin
Doesn't this work?

Code: Select all

local loadedFonts = {}
local createFont = love.graphics.newFont
function love.graphics.newFont(fname, fsize)
    fsize = fsize or 'default'
    loadedFonts[fname] = loadedFonts[fname] or {}
    loadedFonts[fname][fsize] = loadedFonts[fname][fsize] or (fsize ~= 'default' and createFont(fname, fsize) or createFont(fname))
    return loadedFonts[fname][fsize]
end