@@ -232,7 +232,7 @@ void Context2d::resetState(bool init) {
232
232
state->patternQuality = CAIRO_FILTER_GOOD;
233
233
state->imageSmoothingEnabled = true ;
234
234
state->textDrawingMode = TEXT_DRAW_PATHS;
235
- state->fontDescription = pango_font_description_from_string (" sans serif " );
235
+ state->fontDescription = pango_font_description_from_string (" sans" );
236
236
pango_font_description_set_absolute_size (state->fontDescription , 10 * PANGO_SCALE);
237
237
pango_layout_set_font_description (_layout, state->fontDescription );
238
238
@@ -2533,7 +2533,16 @@ NAN_SETTER(Context2d::SetFont) {
2533
2533
pango_font_description_set_style (desc, Canvas::GetStyleFromCSSString (*style));
2534
2534
pango_font_description_set_weight (desc, Canvas::GetWeightFromCSSString (*weight));
2535
2535
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
+ }
2537
2546
2538
2547
PangoFontDescription *sys_desc = Canvas::ResolveFontDescription (desc);
2539
2548
pango_font_description_free (desc);
0 commit comments