[gtk/gtk-3-24: 1/2] GtkCellRendererProgress: use tabular figures
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24: 1/2] GtkCellRendererProgress: use tabular figures
- Date: Mon, 7 Feb 2022 23:53:51 +0000 (UTC)
commit 503e8f40b9559ce921e9330b71ec6f2bb99c8923
Author: Lukas K <lu 0x83 eu>
Date: Thu Jan 13 21:25:58 2022 +0100
GtkCellRendererProgress: use tabular figures
yields more visually stable appearance
gtk/gtkcellrendererprogress.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c
index 260ed2d8fe..81b550f3dd 100644
--- a/gtk/gtkcellrendererprogress.c
+++ b/gtk/gtkcellrendererprogress.c
@@ -426,6 +426,16 @@ gtk_cell_renderer_progress_set_pulse (GtkCellRendererProgress *cellprogress,
recompute_label (cellprogress);
}
+static void
+set_layout_tnum (PangoLayout *layout)
+{
+ PangoAttrList* attrs = pango_attr_list_new ();
+ PangoAttribute* attribute_font_features = pango_attr_font_features_new ("tnum 1");
+ pango_attr_list_insert (attrs, attribute_font_features);
+ pango_layout_set_attributes (layout, attrs);
+ pango_attr_list_unref (attrs);
+}
+
static void
compute_dimensions (GtkCellRenderer *cell,
GtkWidget *widget,
@@ -438,6 +448,7 @@ compute_dimensions (GtkCellRenderer *cell,
gint xpad, ypad;
layout = gtk_widget_create_pango_layout (widget, text);
+ set_layout_tnum (layout);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
@@ -643,6 +654,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
gfloat text_xalign;
layout = gtk_widget_create_pango_layout (widget, priv->label);
+ set_layout_tnum (layout);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]