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