widget: Delay deciding font rendering
Don't translate the font rendering setting into font options ahead of time. Instead just avoid rounding to application pixels during layout, and pass the font rendering setting to gsk for a later decision.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user