|
|
@ -93,7 +93,15 @@ function normalizedColor(prop) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
exports.parseFont = function(str){ |
|
|
|
/** |
|
|
|
* Parse font `str`. |
|
|
|
* |
|
|
|
* @param {String} str |
|
|
|
* @return {Object} |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
var parseFont = exports.parseFont = function(str){ |
|
|
|
if (cache[str]) return cache[str]; |
|
|
|
var obj = {} |
|
|
|
, captures = font.exec(str); |
|
|
@ -391,6 +399,7 @@ Context2d.prototype.__defineSetter__('strokeStyle', function(val){ |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineGetter__('strokeStyle', normalizedColor('lastStrokeStyle')); |
|
|
|
|
|
|
|
/** |
|
|
|
* Set the shadow color with the given css color string. |
|
|
|
* |
|
|
@ -419,3 +428,23 @@ Context2d.prototype.__defineSetter__('shadowColor', function(val){ |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineGetter__('shadowColor', normalizedColor('lastShadowColor')); |
|
|
|
|
|
|
|
Context2d.prototype.__defineSetter__('font', function(val){ |
|
|
|
if ('string' == typeof val) { |
|
|
|
var font; |
|
|
|
if (font = parseFont(val)) { |
|
|
|
this.lastFontString = val; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the current font. |
|
|
|
* |
|
|
|
* @see exports.parseFont() |
|
|
|
* @api public |
|
|
|
*/ |
|
|
|
|
|
|
|
Context2d.prototype.__defineGetter__('font', function(){ |
|
|
|
return this.lastFontString || '10px sans-serif'; |
|
|
|
}); |