diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 0e7f578b6d..befedc8c56 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6513,39 +6513,22 @@ gtk_widget_update_pango_context (GtkWidget *widget, else { cairo_font_options_t *options; - double dpi = 96.; - GdkSurface *surface; - - surface = gtk_widget_get_surface (widget); - if (surface) - { - GdkDisplay *display; - GdkMonitor *monitor; - - display = gdk_surface_get_display (surface); - monitor = gdk_display_get_monitor_at_surface (display, surface); - if (monitor) - dpi = gdk_monitor_get_dpi (monitor); - } options = cairo_font_options_create (); - cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY); + /* HACK: Use CAIRO_ANTIALIAS_GOOD to communicate 'automatic' to gsk */ + cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GOOD); - if (dpi < 200.) - { - /* Not high-dpi. Prefer sharpness by enabling hinting */ - cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON); - cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_SLIGHT); - } - else - { - /* High-dpi. Prefer precise positioning */ - cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF); - cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE); - } + cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE); + + /* Don't do any rounding during layout. In particular with fractional + * scaling, we want to avoid rounding to application pixels, since the + * may not align with the device pixel grid. + */ + cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF); pango_context_set_round_glyph_positions (context, FALSE); + pango_cairo_context_set_font_options (context, options); cairo_font_options_destroy (options);