Browse Source

Add clone() to fix size bug

master
Jongmin Kim 5 years ago committed by GitHub
parent
commit
bf45eee255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/font/index.js
  2. 27
      src/font/util.js

7
src/font/index.js

@ -20,7 +20,8 @@ import {
const DATA = Object.assign({}, UPPER, LOWER, NUMBER, SPECIAL, LATIN); const DATA = Object.assign({}, UPPER, LOWER, NUMBER, SPECIAL, LATIN);
export function typo(v) { export function typo(v) {
var t = DATA[v] || DATA[TOFU]; const t = DATA[v] || DATA[TOFU];
t.v = v; const clone = t.clone();
return t; clone.v = v;
return clone;
} }

27
src/font/util.js

@ -37,7 +37,32 @@ export function generateFontData(w, fw, fh, x1, x2, y1, y2, path) {
y1: y1, y1: y1,
y2: y2, 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;
}
}; };
} }

Loading…
Cancel
Save