1
0
mirror of https://github.com/niklasvh/html2canvas.git synced 2023-08-10 21:13:10 +03:00

Refactor Font.js

This commit is contained in:
MoyuScript 2017-12-09 17:46:32 +08:00
parent f96177f8a8
commit 9670b26696

@ -63,9 +63,11 @@ export class FontMetrics {
return {baseline, middle};
}
getMetrics(font: Font) {
if (this._data[`${font.fontFamily} ${font.fontSize}`] === undefined) {
this._data[`${font.fontFamily} ${font.fontSize}`] = this._parseMetrics(font);
const key = `${font.fontFamily} ${font.fontSize}`;
if (this._data[key] === undefined) {
this._data[key] = this._parseMetrics(font);
}
return this._data[`${font.fontFamily} ${font.fontSize}`];
return this._data[key];
}
}