feat:add letter spacing

This commit is contained in:
Hufe921
2022-04-17 14:49:52 +08:00
parent 6b2d0dc4a4
commit 2152c00238
3 changed files with 7 additions and 0 deletions
+3
View File
@@ -587,6 +587,9 @@ export class Draw {
ctx.font = this._getFont(element)
const fontMetrics = this.textParticle.measureText(ctx, element)
metrics.width = fontMetrics.width * scale
if (element.letterSpacing) {
metrics.width += element.letterSpacing * scale
}
metrics.boundingBoxAscent = (element.value === ZERO ? defaultSize : fontMetrics.actualBoundingBoxAscent) * scale
metrics.boundingBoxDescent = fontMetrics.actualBoundingBoxDescent * scale
if (element.type === ElementType.SUPERSCRIPT) {