Text on HTML5 Canvas

Render text onto canvases without breaking a sweat

Install

Add canvas-txt to your awesome project 🔥

npm i canvas-txt --save

Usage

Using canvas-txt is pretty straight forward

import canvasTxt from 'canvas-txt'

var c = document.getElementById('myCanvas')
var ctx = c.getContext('2d')

var txt = 'Lorem ipsum dolor sit amet'

canvasTxt.fontSize = 24

canvasTxt.drawText(ctx, txt, 100, 200, 200, 200)

CDN

You can use canvas-txt directly from a CDN

<script src="//unpkg.com/canvas-txt"></script>
var canvasTxt = window.canvasTxt.default
// ...remaining same as above

Documentation

Read the documetation at Github