From b239937e0016cb5fdbb4fb050c38f58fb276426b Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sat, 9 Dec 2017 17:46:32 +0800 Subject: [PATCH] Refactor Font.js --- src/Font.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Font.js b/src/Font.js index cd32f25..4c78bd2 100644 --- a/src/Font.js +++ b/src/Font.js @@ -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]; } }