Fonts

General discussion about LÖVE, Lua, game development, puns, and unicorns.
rude
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Fonts

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.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

rude wrote:Unicode support.
I am very much in favor of that. 8-)

Virox
Citizen
Posts: 64
Joined: Thu Jan 07, 2010 6:24 pm

Re: Fonts

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

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

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.

TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Fonts

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)

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

Re: Fonts

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.
When I write def I mean function.

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

Re: Fonts

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.
When I write def I mean function.

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Fonts

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.

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

Re: Fonts

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)

When I write def I mean function.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

Doesn't this work?

Code: Select all

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