From 414c658a2f7bf0b909f37b6439c84c019e2c38fd Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 1 Nov 2010 16:05:06 -0700 Subject: [PATCH] More font size units --- lib/canvas.js | 2 +- test/canvas.test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/canvas.js b/lib/canvas.js index cc1a20a..e7565d9 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -76,7 +76,7 @@ function normalizedColor(prop) { exports.parseFont = function(str){ if (cache[str]) return cache[str]; var obj = {} - , captures = /^ *(?:(normal|bold|bolder|lighter|[1-9](?:00)) *)?(?:(normal|italic|oblique) *)?(\d+)(px|pt) *((?:"([^"]+)"|[\w-]+)( *, *(?:"([^"]+)"|[\w-]+))*)/.exec(str); + , captures = /^ *(?:(normal|bold|bolder|lighter|[1-9](?:00)) *)?(?:(normal|italic|oblique) *)?(\d+)(px|pt|pc|in|cm|mm|%) *((?:"([^"]+)"|[\w-]+)( *, *(?:"([^"]+)"|[\w-]+))*)/.exec(str); if (!captures) return; obj.weight = captures[1] || 'normal'; obj.style = captures[2] || 'normal'; diff --git a/test/canvas.test.js b/test/canvas.test.js index a8d2e62..739c6cc 100644 --- a/test/canvas.test.js +++ b/test/canvas.test.js @@ -66,6 +66,10 @@ module.exports = { , { size: 20, unit: 'px', family: 'Arial' } , '20pt Arial' , { size: 20, unit: 'pt', family: 'Arial' } + , '20% Arial' + , { size: 20, unit: '%', family: 'Arial' } + , '20mm Arial' + , { size: 20, unit: 'mm', family: 'Arial' } , '20px serif' , { size: 20, unit: 'px', family: 'serif' } , '20px sans-serif'