Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderTextWithLetterSpacing(text: TextBounds, letterSpacing: number) {
if (letterSpacing === 0) {
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
} else {
const letters = toCodePoints(text.text).map(i => fromCodePoint(i));
letters.reduce((left, letter) => {
this.ctx.fillText(letter, left, text.bounds.top + text.bounds.height);
return left + this.ctx.measureText(letter).width;
}, text.bounds.left);
}
}
write(chunk: string) {
this._value = this._value.concat(toCodePoints(chunk));
}