Browse Source

Misc refactoring of parseFont()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
fac90304e6
  1. 19
      lib/canvas.js

19
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;
};
/**

Loading…
Cancel
Save