love icon indicating copy to clipboard operation
love copied to clipboard

Add way to convert GlyphData to something usable

Open steveRoll-git opened this issue 2 years ago • 4 comments

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

steveRoll-git avatar Apr 22 '22 18:04 steveRoll-git

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.

boobs regex included

HDPLocust avatar Aug 12 '22 10:08 HDPLocust

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.

HDPLocust avatar Aug 24 '22 00:08 HDPLocust

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.

bjornbytes avatar Aug 24 '22 01:08 bjornbytes

It would be really cool if it was ported to LÖVE!

HDPLocust avatar Dec 11 '22 00:12 HDPLocust