diff --git a/lib/canvas.js b/lib/canvas.js index e7565d9..4011ccb 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -41,6 +41,12 @@ exports.cairoVersion = cairoVersion; var cache = {}; +/** + * Font RegExp used by parseFont(); + */ + +var font = /^ *(?:(normal|bold|bolder|lighter|[1-9](?:00)) *)?(?:(normal|italic|oblique) *)?(\d+)(px|pt|pc|in|cm|mm|%) *((?:"([^"]+)"|[\w-]+)( *, *(?:"([^"]+)"|[\w-]+))*)/; + /** * Buffer extensions. */ @@ -76,7 +82,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|pc|in|cm|mm|%) *((?:"([^"]+)"|[\w-]+)( *, *(?:"([^"]+)"|[\w-]+))*)/.exec(str); + , captures = font.exec(str); if (!captures) return; obj.weight = captures[1] || 'normal'; obj.style = captures[2] || 'normal';