|
|
@ -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'; |
|
|
|