Browse Source

font size

v1.x
Tj Holowaychuk 15 years ago
parent
commit
1c4d6d44a7
  1. 1
      lib/canvas.js
  2. 4
      src/CanvasRenderingContext2d.cc

1
lib/canvas.js

@ -430,7 +430,6 @@ Context2d.prototype.__defineSetter__('shadowColor', function(val){
Context2d.prototype.__defineGetter__('shadowColor', normalizedColor('lastShadowColor')); Context2d.prototype.__defineGetter__('shadowColor', normalizedColor('lastShadowColor'));
Context2d.prototype.__defineSetter__('font', function(val){ Context2d.prototype.__defineSetter__('font', function(val){
console.log(val);
if ('string' == typeof val) { if ('string' == typeof val) {
var font; var font;
if (font = parseFont(val)) { if (font = parseFont(val)) {

4
src/CanvasRenderingContext2d.cc

@ -815,6 +815,9 @@ Context2d::SetFont(const Arguments &args) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->getContext(); cairo_t *ctx = context->getContext();
// Size
cairo_set_font_size(ctx, size);
// Style // Style
cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL; cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
if (0 == strcmp("italic", *style)) slant = CAIRO_FONT_SLANT_ITALIC; if (0 == strcmp("italic", *style)) slant = CAIRO_FONT_SLANT_ITALIC;
@ -845,7 +848,6 @@ Context2d::FillText(const Arguments &args) {
Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(args.This());
cairo_t *ctx = context->getContext(); cairo_t *ctx = context->getContext();
cairo_text_extents_t te; cairo_text_extents_t te;
cairo_set_font_size(ctx, 20); // TODO: relative
cairo_move_to(ctx, x, y); cairo_move_to(ctx, x, y);
cairo_show_text(ctx, *str); cairo_show_text(ctx, *str);

Loading…
Cancel
Save