diff --git a/lib/context2d.js b/lib/context2d.js index a8e1a47..2ac1bce 100644 --- a/lib/context2d.js +++ b/lib/context2d.js @@ -48,7 +48,7 @@ var weights = 'normal|bold|bolder|lighter|[1-9]00' var fontre = new RegExp('^ *' + '(?:(' + weights + ') *)?' + '(?:(' + styles + ') *)?' - + '(\\d+)(' + units + ') *' + + '([\\d\\.]+)(' + units + ') *' + '((?:' + string + ')( *, *(?:' + string + '))*)' ); @@ -96,7 +96,7 @@ var parseFont = exports.parseFont = function(str){ // Populate font object font.weight = captures[1] || 'normal'; font.style = captures[2] || 'normal'; - font.size = parseInt(captures[3], 10); + font.size = parseFloat(captures[3]); font.unit = captures[4]; font.family = captures[5]; diff --git a/test/canvas.test.js b/test/canvas.test.js index 9c35359..bb0e766 100644 --- a/test/canvas.test.js +++ b/test/canvas.test.js @@ -56,6 +56,8 @@ module.exports = { , { size: 20, unit: 'px', family: 'Arial' } , '20pt Arial' , { size: 20, unit: 'pt', family: 'Arial' } + , '20.5pt Arial' + , { size: 20.5, unit: 'pt', family: 'Arial' } , '20% Arial' , { size: 20, unit: '%', family: 'Arial' } , '20mm Arial'