♻️ refactor(prototype): 模拟 Figma 里的中文字符范围改用转义写法
This commit is contained in:
1 parent
4f4511426e
commit
33a1b5d57c
1 file changed
+1
-1
+1
-1
@@ -32,7 +32,7 @@ function fakeFigma(options = {}) {
|
|||||||
};
|
};
|
||||||
const dirty = (node) => { mark(node, ++stamp); };
|
const dirty = (node) => { mark(node, ++stamp); };
|
||||||
const fontKey = (font) => `${font.family}/${font.style}`;
|
const fontKey = (font) => `${font.family}/${font.style}`;
|
||||||
const cjk = /[ -鿿-]/;
|
const cjk = /[\u3000-\u9fff\uff00-\uffef]/;
|
||||||
const textWidth = (node) => {
|
const textWidth = (node) => {
|
||||||
let width = 0;
|
let width = 0;
|
||||||
for (const char of node._characters) width += cjk.test(char) ? node.fontSize : node.fontSize * 0.55;
|
for (const char of node._characters) width += cjk.test(char) ? node.fontSize : node.fontSize * 0.55;
|
||||||
|
|||||||
Reference in new issue
Block a user