Font
EditFont objects are used to render text with Pass:text. The active font can be changed using Pass:setFont. The default font is Varela Round, which is used when no font is active, and can be retrieved using lovr.graphics.getDefaultFont. Custom fonts can be loaded from TTF and BMFont files using lovr.graphics.newFont.
Each Font uses a Rasterizer to load the font and create images for each glyph. As text is drawn, the Font uploads images from the Rasterizer to a GPU texture atlas as needed. The Font also performs text layout and mesh generation for strings of text.
For TTF fonts, LÖVR uses a text rendering technique called "multichannel signed distance fields" (MSDF), which makes the font rendering remain crisp when text is viewed up close.
Constructors
| lovr.graphics.newFont | Create a new Font. |
| lovr.graphics.getDefaultFont | Get the default Font. |
Methods
| Font:getAscent | Get the ascent of the Font. |
| Font:getDescent | Get the descent of the Font. |
| Font:getHeight | Get the height of the Font. |
| Font:getKerning | Get the kerning between 2 glyphs. |
| Font:getLineSpacing | Get the line spacing of the Font. |
| Font:getLines | Wrap a string into a sequence of lines. |
| Font:getPixelDensity | Get the pixel density of the Font. |
| Font:getRasterizer | Get the Font's Rasterizer. |
| Font:getVertices | Get the vertices for a piece of text. |
| Font:getWidth | Get the width of rendered text. |
| Font:setLineSpacing | Set the line spacing of the Font. |
| Font:setPixelDensity | Set the pixel density of the Font. |
| Object:release | Immediately release the Lua reference to an object. |
| Object:type | Get the type name of the object. |
Notes
MSDF text requires a special shader to work. LÖVR will automatically switch to this shader if no shader is active on the Pass. This font shader is also available as a DefaultShader.