diff --git a/src/font/index.js b/src/font/index.js index 2b0335e..1eaf28f 100644 --- a/src/font/index.js +++ b/src/font/index.js @@ -20,7 +20,8 @@ import { const DATA = Object.assign({}, UPPER, LOWER, NUMBER, SPECIAL, LATIN); export function typo(v) { - var t = DATA[v] || DATA[TOFU]; - t.v = v; - return t; + const t = DATA[v] || DATA[TOFU]; + const clone = t.clone(); + clone.v = v; + return clone; } \ No newline at end of file diff --git a/src/font/util.js b/src/font/util.js index c713956..5d07a3b 100644 --- a/src/font/util.js +++ b/src/font/util.js @@ -37,7 +37,32 @@ export function generateFontData(w, fw, fh, x1, x2, y1, y2, path) { y1: y1, y2: y2, }, - p: arr + p: arr, + clone: () => { + const arr2 = []; + for (let i = 0; i < arr.length; i++) { + arr2[i] = { + d: arr[i].d, + v: arr[i].v + }; + } + const v = { + rect: { + w: w, + h: FONT_HEIGHT, + fw: fw, + fh: fh + }, + ratio: { + x1: x1, + x2: x2, + y1: y1, + y2: y2, + }, + p: arr2, + }; + return v; + } }; }