mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Add a gtk-hint-font-metrics setting
This lets people switch back to font rendering that is closer to what GTK 3 does. It is not perfect - subpixel antialiasing is not going to work. But it give us an Escape hatch while we shake out the bugs in our linear layout. Related: #3787
This commit is contained in:
parent
4dc0e67ac7
commit
b26a370ce4
@ -166,6 +166,7 @@ enum {
|
||||
PROP_XFT_HINTSTYLE,
|
||||
PROP_XFT_RGBA,
|
||||
PROP_XFT_DPI,
|
||||
PROP_HINT_FONT_METRICS,
|
||||
PROP_CURSOR_THEME_NAME,
|
||||
PROP_CURSOR_THEME_SIZE,
|
||||
PROP_ALTERNATIVE_BUTTON_ORDER,
|
||||
@ -556,6 +557,7 @@ gtk_settings_class_init (GtkSettingsClass *class)
|
||||
|
||||
g_assert (result == PROP_XFT_RGBA);
|
||||
|
||||
|
||||
/**
|
||||
* GtkSettings:gtk-xft-dpi:
|
||||
*
|
||||
@ -572,6 +574,25 @@ gtk_settings_class_init (GtkSettingsClass *class)
|
||||
|
||||
g_assert (result == PROP_XFT_DPI);
|
||||
|
||||
/**
|
||||
* GtkSettings:gtk-hint-font-metrics:
|
||||
*
|
||||
* Whether hinting should be applied to font metrics.
|
||||
*
|
||||
* Note that this also turns off subpixel positioning of glyphs,
|
||||
* since it conflicts with metrics hinting.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
result = settings_install_property_parser (class,
|
||||
g_param_spec_boolean ("gtk-hint-font-metrics",
|
||||
P_("Hint Font Metrics"),
|
||||
P_("Whether hinting should be applied to font metrics"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_assert (result == PROP_HINT_FONT_METRICS);
|
||||
|
||||
/**
|
||||
* GtkSettings:gtk-cursor-theme-name:
|
||||
*
|
||||
@ -1439,6 +1460,7 @@ gtk_settings_notify (GObject *object,
|
||||
case PROP_XFT_HINTING:
|
||||
case PROP_XFT_HINTSTYLE:
|
||||
case PROP_XFT_RGBA:
|
||||
case PROP_HINT_FONT_METRICS:
|
||||
settings_update_font_options (settings);
|
||||
gtk_system_setting_changed (settings->display, GTK_SYSTEM_SETTING_FONT_CONFIG);
|
||||
break;
|
||||
@ -1678,6 +1700,7 @@ settings_update_font_options (GtkSettings *settings)
|
||||
cairo_antialias_t antialias_mode;
|
||||
char *rgba_str;
|
||||
cairo_subpixel_order_t subpixel_order;
|
||||
gboolean hint_font_metrics;
|
||||
|
||||
if (settings->font_options)
|
||||
cairo_font_options_destroy (settings->font_options);
|
||||
@ -1687,11 +1710,14 @@ settings_update_font_options (GtkSettings *settings)
|
||||
"gtk-xft-hinting", &hinting,
|
||||
"gtk-xft-hintstyle", &hint_style_str,
|
||||
"gtk-xft-rgba", &rgba_str,
|
||||
"gtk-hint-font-metrics", &hint_font_metrics,
|
||||
NULL);
|
||||
|
||||
settings->font_options = cairo_font_options_create ();
|
||||
|
||||
cairo_font_options_set_hint_metrics (settings->font_options, CAIRO_HINT_METRICS_OFF);
|
||||
cairo_font_options_set_hint_metrics (settings->font_options,
|
||||
hint_font_metrics ? CAIRO_HINT_METRICS_ON
|
||||
: CAIRO_HINT_METRICS_OFF);
|
||||
|
||||
hint_style = CAIRO_HINT_STYLE_DEFAULT;
|
||||
if (hinting == 0)
|
||||
|
@ -6441,8 +6441,16 @@ update_pango_context (GtkWidget *widget,
|
||||
pango_context_set_font_description (context, font_desc);
|
||||
pango_font_description_free (font_desc);
|
||||
|
||||
if (cairo_version () >= CAIRO_VERSION_ENCODE (1, 17, 4))
|
||||
pango_context_set_round_glyph_positions (context, FALSE);
|
||||
settings = gtk_widget_get_settings (widget);
|
||||
|
||||
if (settings &&
|
||||
cairo_version () >= CAIRO_VERSION_ENCODE (1, 17, 4))
|
||||
{
|
||||
gboolean hint_font_metrics;
|
||||
|
||||
g_object_get (settings, "gtk-hint-font-metrics", &hint_font_metrics, NULL);
|
||||
pango_context_set_round_glyph_positions (context, hint_font_metrics);
|
||||
}
|
||||
|
||||
pango_context_set_base_dir (context,
|
||||
_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
|
||||
@ -6450,7 +6458,6 @@ update_pango_context (GtkWidget *widget,
|
||||
|
||||
pango_cairo_context_set_resolution (context, _gtk_css_number_value_get (style->core->dpi, 100));
|
||||
|
||||
settings = gtk_widget_get_settings (widget);
|
||||
font_options = (cairo_font_options_t*)g_object_get_qdata (G_OBJECT (widget), quark_font_options);
|
||||
if (settings && font_options)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user