cyl/master
jscyl13849007907 7 days ago
parent 3899b08975
commit 58b17205d8

@ -88,4 +88,16 @@ export default {
// 恢复之前保存的绘图上下文 // 恢复之前保存的绘图上下文
ctx.restore(); ctx.restore();
}, },
calculateTotalWidth (ctx, segments) {
let totalWidth = 0;
segments.forEach((segment) => {
// console.log('segment', segment);
if (segment) {
ctx.font = `${segment.fontWeight} ${segment.fontSize}px Arial`;
totalWidth += ((ctx.measureText(segment.content).width) + (segment.space || 0));
}
});
return totalWidth;
},
} }
Loading…
Cancel
Save