From 20a42fa79079dd158f08b7555477183072355222 Mon Sep 17 00:00:00 2001 From: David King Date: Jun 03 2015 09:38:19 +0000 Subject: Fix font rendering in benchmark dialog (#598277) --- diff --git a/gnome-disk-utility-3.16.2-fix-benchmark-dialog-font-rendering.patch b/gnome-disk-utility-3.16.2-fix-benchmark-dialog-font-rendering.patch new file mode 100644 index 0000000..5d16b0a --- /dev/null +++ b/gnome-disk-utility-3.16.2-fix-benchmark-dialog-font-rendering.patch @@ -0,0 +1,138 @@ +From e7fa99bbd9ab3d854e11cfa43813c84f37a0c597 Mon Sep 17 00:00:00 2001 +From: David King +Date: Tue, 2 Jun 2015 11:03:31 +0100 +Subject: [PATCH] Fix font rendering in benchmark dialog + +Use Pango to render text around the benchmark graph, rather than the toy +Cairo text API. + +https://bugzilla.gnome.org/show_bug.cgi?id=656864 +--- + src/disks/gdubenchmarkdialog.c | 61 +++++++++++++++++++++++++++--------------- + 1 file changed, 39 insertions(+), 22 deletions(-) + +diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c +index 22fe98a..93f1987 100644 +--- a/src/disks/gdubenchmarkdialog.c ++++ b/src/disks/gdubenchmarkdialog.c +@@ -248,6 +248,10 @@ on_drawing_area_draw (GtkWidget *widget, + gdouble access_time_max = 0.0; + gdouble prev_x; + gdouble prev_y; ++ GtkStyleContext *context; ++ PangoFontDescription *font_desc; ++ GdkRGBA fg; ++ PangoLayout *layout; + + G_LOCK (bm_lock); + +@@ -342,9 +346,6 @@ on_drawing_area_draw (GtkWidget *widget, + width = allocation.width; + height = allocation.height; + +- cairo_select_font_face (cr, "sans", +- CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); +- cairo_set_font_size (cr, 8.0); + cairo_set_line_width (cr, 1.0); + + #if 0 +@@ -409,23 +410,35 @@ on_drawing_area_draw (GtkWidget *widget, + gh -= needed; + } + ++ context = gtk_widget_get_style_context (widget); ++ gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); ++ gtk_style_context_get (context, ++ GTK_STATE_FLAG_NORMAL, ++ GTK_STYLE_PROPERTY_FONT, ++ &font_desc, ++ NULL); ++ pango_font_description_set_size (font_desc, 0.8 * 8 * PANGO_SCALE); ++ layout = pango_cairo_create_layout (cr); ++ pango_layout_set_font_description (layout, font_desc); ++ pango_font_description_free (font_desc); ++ + /* draw x markers ("%d%%") + vertical grid */ + for (n = 0; n <= 10; n++) + { +- cairo_text_extents_t te; ++ PangoRectangle extents; + + x = gx + ceil (n * gw / 10.0); + y = gy + gh + x_marker_height/2.0; + + s = g_strdup_printf ("%u%%", n * 10); + +- cairo_text_extents (cr, s, &te); +- ++ pango_layout_set_text (layout, s, -1); ++ pango_layout_get_extents (layout, NULL, &extents); + cairo_move_to (cr, +- x - te.x_bearing - te.width/2, +- y - te.y_bearing - te.height/2); +- cairo_set_source_rgb (cr, 0, 0, 0); +- cairo_show_text (cr, s); ++ x - extents.width/PANGO_SCALE/2, ++ y - extents.height/PANGO_SCALE/2); ++ gdk_cairo_set_source_rgba (cr, &fg); ++ pango_cairo_show_layout (cr, layout); + + g_free (s); + } +@@ -433,37 +446,41 @@ on_drawing_area_draw (GtkWidget *widget, + /* draw left y markers ("%d MB/s") */ + for (n = 0; n <= num_y_markers; n++) + { +- cairo_text_extents_t te; ++ PangoRectangle extents; + + x = gx/2.0; + y = gy + gh - gh * n / num_y_markers; + + s = y_left_markers[n]; +- cairo_text_extents (cr, s, &te); ++ pango_layout_set_text (layout, s, -1); ++ pango_layout_get_extents (layout, NULL, &extents); + cairo_move_to (cr, +- x - te.x_bearing - te.width/2, +- y - te.y_bearing - te.height/2); +- cairo_set_source_rgb (cr, 0, 0, 0); +- cairo_show_text (cr, s); ++ x - extents.width/PANGO_SCALE/2, ++ y - extents.height/PANGO_SCALE/2); ++ gdk_cairo_set_source_rgba (cr, &fg); ++ pango_cairo_show_layout (cr, layout); + } + + /* draw right y markers ("%d ms") */ + for (n = 0; n <= num_y_markers; n++) + { +- cairo_text_extents_t te; ++ PangoRectangle extents; + + x = gx + gw + (width - (gx + gw))/2.0; + y = gy + gh - gh * n / num_y_markers; + + s = y_right_markers[n]; +- cairo_text_extents (cr, s, &te); ++ pango_layout_set_text (layout, s, -1); ++ pango_layout_get_extents (layout, NULL, &extents); + cairo_move_to (cr, +- x - te.x_bearing - te.width/2, +- y - te.y_bearing - te.height/2); +- cairo_set_source_rgb (cr, 0, 0, 0); +- cairo_show_text (cr, s); ++ x - extents.width/PANGO_SCALE/2, ++ y - extents.height/PANGO_SCALE/2); ++ gdk_cairo_set_source_rgba (cr, &fg); ++ pango_cairo_show_layout (cr, layout); + } + ++ g_object_unref (layout); ++ + /* fill graph area */ + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_rectangle (cr, gx + 0.5, gy + 0.5, gw, gh); +-- +2.4.2 + diff --git a/gnome-disk-utility.spec b/gnome-disk-utility.spec index 961744f..e38dd62 100644 --- a/gnome-disk-utility.spec +++ b/gnome-disk-utility.spec @@ -5,13 +5,15 @@ Name: gnome-disk-utility Version: 3.17.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Disks Group: Applications/System License: GPLv2+ URL: https://git.gnome.org/browse/gnome-disk-utility Source0: https://download.gnome.org/sources/%{name}/3.17/%{name}-%{version}.tar.xz +# https://bugzilla.redhat.com/show_bug.cgi?id=598277 +Patch0: gnome-disk-utility-3.16.2-fix-benchmark-dialog-font-rendering.patch BuildRequires: /usr/bin/appstream-util BuildRequires: desktop-file-utils @@ -47,7 +49,7 @@ Disks supports partitioning, file system creation, encryption, fstab/crypttab editing, ATA SMART and other features %prep -%setup -q +%autosetup -p1 %build @@ -109,6 +111,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %changelog +* Wed Jun 03 2015 David King - 3.17.2-2 +- Fix font rendering in benchmark dialog (#598277) + * Mon May 25 2015 David King - 3.17.2-1 - Update to 3.17.2 - Validate AppData in check