Text Module - Lucas-Code27/Canvas-plus-plus GitHub Wiki

How to Setup

[!NOTE] The Text module DOES NOT handle rendering text, it handles loading custom fonts so if you do not need to laod a custom font and are going to use a default font like serif and sans-serif you DO NOT need to use this module

Import Module

import * as text from "./canvas++/modules/text.js"

Then you can load in a font and have it added to the webpage itself (theoretically you can use this to add fonts to the rest of your website)

// First arg is what you call the font and second is the path in the filesystem to the font in your project
text.addfont("pixel","assets/Micro5-Regular.ttf")

Then you can draw text using the renderer module and call the font name you set

renderer.drawText("48px pixel","PRESS 'R' TO RESTART", 20, 200)