This demo demonstrate how to render text with Shaku using Font Textures.
A Font Texture is basically a spritesheet that Shaku generates at runtime from a font (and size). It looks like this:
Once created, the Gfx manager can use it to convert any string into a collection of sprites that when rendered will draw the text with the given font.
The following is a minimal code example on how to draw text.
// load font texture asset
let fontTexture = await Shaku.assets.loadFontTexture('assets/DejaVuSansMono.ttf', {fontName: 'DejaVuSansMono'});
// create text sprite batch
let textSpriteBatch = new Shaku.gfx.TextSpriteBatch();
// generate text
let textGroup = Shaku.gfx.buildText(fontTexture, "This is a multiline text..\nAligned left.", 24, Shaku.utils.Color.white, Shaku.gfx.TextAlignments.Left);
textGroup.position.set(100, 100);
// part below goes between startFrame() and endFrame()
// -------------------------------------------------------
// draw the text
textSpriteBatch.begin();
textSpriteBatch.drawText(textGroup);
textSpriteBatch.end();