mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-07 11:20:09 +00:00
fontchooser: Use absolute size for the preview text in the list
With absolute sizes, Pango is way better at getting the actual sizes of the fonts to match up. It's a bit harder to compute a proper value for this, whcih makes the code ugly, but as long as it works better...
This commit is contained in:
parent
14154dac31
commit
c1958ae9f2
@ -792,6 +792,22 @@ visible_func (GtkTreeModel *model,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* in pango units */
|
||||||
|
static int
|
||||||
|
gtk_font_chooser_widget_get_preview_text_height (GtkFontChooserWidget *fontchooser)
|
||||||
|
{
|
||||||
|
GtkWidget *treeview = fontchooser->priv->family_face_list;
|
||||||
|
double dpi, font_size;
|
||||||
|
|
||||||
|
dpi = gdk_screen_get_resolution (gtk_widget_get_screen (treeview));
|
||||||
|
gtk_style_context_get (gtk_widget_get_style_context (treeview),
|
||||||
|
gtk_widget_get_state_flags (treeview),
|
||||||
|
"font-size", &font_size,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return dpi / 72.0 * PANGO_SCALE_X_LARGE * font_size * PANGO_SCALE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
|
gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
|
||||||
GtkCellRenderer *cell,
|
GtkCellRenderer *cell,
|
||||||
@ -827,7 +843,7 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column,
|
|||||||
attribute->start_index = to_string_len;
|
attribute->start_index = to_string_len;
|
||||||
pango_attr_list_insert (attrs, attribute);
|
pango_attr_list_insert (attrs, attribute);
|
||||||
|
|
||||||
attribute = pango_attr_scale_new (PANGO_SCALE_X_LARGE);
|
attribute = pango_attr_size_new_absolute (gtk_font_chooser_widget_get_preview_text_height (fontchooser));
|
||||||
attribute->start_index = to_string_len;
|
attribute->start_index = to_string_len;
|
||||||
pango_attr_list_insert (attrs, attribute);
|
pango_attr_list_insert (attrs, attribute);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user