From 253e200957c8982cf2e0dc231a81a2d7d070dd35 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Tue, 2 Nov 2010 13:53:29 -0700 Subject: [PATCH] Added textBaseline= --- lib/canvas.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/canvas.js b/lib/canvas.js index 99cf0b7..065ff6f 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -41,6 +41,12 @@ exports.cairoVersion = cairoVersion; var cache = {}; +/** + * Text baselines. + */ + +var baselines = ['alphabetic', 'top', 'bottom', 'middle', 'ideographic', 'hanging']; + /** * Font RegExp helpers. */ @@ -502,6 +508,30 @@ Context2d.prototype.__defineGetter__('font', function(){ return this.lastFontString || '10px sans-serif'; }); +/** + * Set text baseline. + * + * @api public + */ + +Context2d.prototype.__defineSetter__('textBaseline', function(val){ + var n = baselines.indexOf(val); + if (~n) { + this.lastBaseline = val; + this.setTextBaseline(n); + } +}); + +/** + * Get the current baseline setting. + * + * @api public + */ + +Context2d.prototype.__defineGetter__('textAlign', function(){ + return this.lastBaseline || 'alphabetic'; +}); + /** * Set text alignment. *