love
love copied to clipboard
Add way to convert GlyphData to something usable
The documentation on the wiki is not very clear about this, so it took some digging through love's source code to figure out -
GlyphData
's content consists of the glyph's pixels stored in the la8
pixel format.
The problem with this format is that it can't be easily converted to something drawable, because it's not supported by ImageData
or Canvas
es.
So, it makes sense to me that GlyphData
should provide a way to convert it to ImageData
, or get a pixel from its image. Without this, GlyphData
is pretty much pointless on the Lua side, because it just provides methods to get data about the character's metrics, but no way to convert the glyph's graphic to something usable.
GlyphData is already pretty useful. But it would be possible to add a function to convert to imageData of the desired format so as not to mess around with strings (and do not load garbage collection).
Best solution: rasterizer:getGlyph("P"[, "la8", "rgba8", "rgb"])
etc.
Also adding polygon_tbl = Font:getVertices("abcdef")
and/or mesh_tbl = Font:getColoredVertices("abcdef")
should be wery useful for custom "text" objects, for truly vector text, for pseudo 3d (or true 3d) mesh generation etc.
Yes! In LÖVR I recently added both Rasterizer:getCurves(string|codepoint)
(bezier curves for a glyph's outline) and Font:getVertices
(quad vertices for a string). :getVertices lets Lua implement a Text-object-like system for caching glyphs.
It would be really cool if it was ported to LÖVE!