modern-text
v0.7.3
Published
Measure and render text in a way that describes the DOM.
Downloads
2,791
Maintainers
Readme
Usage
import { renderText } from 'modern-text'
const view = document.createElement('canvas')
document.body.append(view)
renderText({
view,
style: {
width: 100,
height: 200,
fontSize: 22,
textDecoration: 'underline',
},
content: [
{
letterSpacing: 3,
fragments: [
{ content: 'He', color: 'red', fontSize: 12 },
{ content: 'llo', color: 'black' },
],
},
{ content: ', ', color: 'grey' },
{ content: 'World!', color: 'black' },
],
})