diff --git a/lib/canvas.js b/lib/canvas.js index 673e2b2..e2c3545 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -109,15 +109,20 @@ function normalizedColor(prop) { var parseFont = exports.parseFont = function(str){ if (cache[str]) return cache[str]; - var obj = {} + var font = {} , captures = fontre.exec(str); + + // Invalid if (!captures) return; - obj.weight = captures[1] || 'normal'; - obj.style = captures[2] || 'normal'; - obj.size = parseInt(captures[3], 10); - obj.unit = captures[4]; - obj.family = captures[5]; - return cache[str] = obj; + + // Populate font object + font.weight = captures[1] || 'normal'; + font.style = captures[2] || 'normal'; + font.size = parseInt(captures[3], 10); + font.unit = captures[4]; + font.family = captures[5]; + + return cache[str] = font; }; /**