diff --git a/lib/canvas.js b/lib/canvas.js index 7dbb7d4..09d497d 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -434,6 +434,7 @@ Context2d.prototype.__defineSetter__('font', function(val){ var font; if (font = parseFont(val)) { this.lastFontString = val; + this.font = font; } } }); diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index 7859a81..5949cb8 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -797,7 +797,26 @@ Context2d::MoveTo(const Arguments &args) { Handle Context2d::FillText(const Arguments &args) { - + HandleScope scope; + + // Ignore when args are not present + if (!args[0]->IsString()) return Undefined(); + if (!args[1]->IsNumber()) return Undefined(); + if (!args[2]->IsNumber()) return Undefined(); + + String::Utf8Value str(args[0]); + + double x = args[1]->NumberValue() + , y = args[2]->NumberValue(); + + Context2d *context = ObjectWrap::Unwrap(args.This()); + cairo_t *ctx = context->getContext(); + cairo_text_extents_t te; + cairo_select_font_face(ctx, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); + cairo_set_font_size(ctx, 20); // TODO: relative + cairo_move_to(ctx, x, y); + cairo_show_text(ctx, *str); + return Undefined(); }