@@ -232,7 +232,7 @@ void Context2d::resetState(bool init) {
232232 state->patternQuality = CAIRO_FILTER_GOOD;
233233 state->imageSmoothingEnabled = true ;
234234 state->textDrawingMode = TEXT_DRAW_PATHS;
235- state->fontDescription = pango_font_description_from_string (" sans serif " );
235+ state->fontDescription = pango_font_description_from_string (" sans" );
236236 pango_font_description_set_absolute_size (state->fontDescription , 10 * PANGO_SCALE);
237237 pango_layout_set_font_description (_layout, state->fontDescription );
238238
@@ -2533,7 +2533,16 @@ NAN_SETTER(Context2d::SetFont) {
25332533 pango_font_description_set_style (desc, Canvas::GetStyleFromCSSString (*style));
25342534 pango_font_description_set_weight (desc, Canvas::GetWeightFromCSSString (*weight));
25352535
2536- if (strlen (*family) > 0 ) pango_font_description_set_family (desc, *family);
2536+ if (strlen (*family) > 0 ) {
2537+ // See #1643 - Pango understands "sans" whereas CSS uses "sans-serif"
2538+ std::string s1 (*family);
2539+ std::string s2 (" sans-serif" );
2540+ if (streq_casein (s1, s2)) {
2541+ pango_font_description_set_family (desc, " sans" );
2542+ } else {
2543+ pango_font_description_set_family (desc, *family);
2544+ }
2545+ }
25372546
25382547 PangoFontDescription *sys_desc = Canvas::ResolveFontDescription (desc);
25392548 pango_font_description_free (desc);
0 commit comments