From 7669f81a6cd1e367d95e8234b3b741ba35977371 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 8 Nov 2010 08:05:03 -0800 Subject: [PATCH] Defaulting sans-serif to Arial --- src/CanvasRenderingContext2d.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index fb8f17a..b6fb14e 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -951,7 +951,8 @@ Context2d::SetFont(const Arguments &args) { String::AsciiValue style(args[1]); double size = args[2]->NumberValue(); String::AsciiValue unit(args[3]); - String::AsciiValue family(args[4]); + String::AsciiValue _family(args[4]); + const char *family = *_family; Context2d *context = ObjectWrap::Unwrap(args.This()); cairo_t *ctx = context->getContext(); @@ -959,6 +960,11 @@ Context2d::SetFont(const Arguments &args) { // Size cairo_set_font_size(ctx, size); + // Family + if (0 == strcmp("sans-serif", family)) { + family = "Arial"; + } + // Style cairo_font_slant_t s = CAIRO_FONT_SLANT_NORMAL; if (0 == strcmp("italic", *style)) { @@ -973,7 +979,7 @@ Context2d::SetFont(const Arguments &args) { w = CAIRO_FONT_WEIGHT_BOLD; } - cairo_select_font_face(ctx, *family, s, w); + cairo_select_font_face(ctx, family, s, w); return Undefined(); }