Fonts

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

Fonts

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

Post by Robin »

rude wrote:Unicode support.
I am very much in favor of that. 8-)
Help us help you: attach a .love.
User avatar
Virox
Citizen
Posts: 64
Joined: Thu Jan 07, 2010 6:24 pm

Re: Fonts

Post 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 :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

Post 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.
Help us help you: attach a .love.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Fonts

Post 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)
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 »

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.
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 »

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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Fonts

Post 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.
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 »

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
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Fonts

Post 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
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 91 guests