修改:英文字符宽度修改

This commit is contained in:
Linzm committed 2025-12-29 14:32:51 +08:00
1 parent 571d4a72b3
commit c30768d605
1 file changed
+2 -2
+2 -2
View File
@@ -194,7 +194,7 @@ export function createTextPosition({ setData }) {
charWidth = fontSize * 0.6; charWidth = fontSize * 0.6;
} else if (/[a-zA-Z]/.test(char)) { } else if (/[a-zA-Z]/.test(char)) {
// 英文字母:宽度约为 fontSize * 0.6(大写)或 0.5(小写) // 英文字母:宽度约为 fontSize * 0.6(大写)或 0.5(小写)
charWidth = /[A-Z]/.test(char) ? fontSize * 0.65 : fontSize * 0.5; charWidth = /[A-Z]/.test(char) ? fontSize * 0.6 : fontSize * 0.45;
} else if (/[\u3000-\u303f\uff00-\uffef]/.test(char)) { } else if (/[\u3000-\u303f\uff00-\uffef]/.test(char)) {
// 全角符号:宽度约为 fontSize // 全角符号:宽度约为 fontSize
charWidth = fontSize; charWidth = fontSize;
@@ -213,7 +213,7 @@ export function createTextPosition({ setData }) {
} }
// 为文字之间添加2px间距(除了最后一个字符) // 为文字之间添加2px间距(除了最后一个字符)
const spacing = 2; const spacing = 0;
const totalSpacing = (text.length > 1) ? (text.length - 1) * spacing : 0; const totalSpacing = (text.length > 1) ? (text.length - 1) * spacing : 0;
const totalWidthWithSpacing = totalWidth + totalSpacing; const totalWidthWithSpacing = totalWidth + totalSpacing;