[gtk/better-font-rendering-demo: 1/4] gtk-demo: Improve the font rendering demo
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/better-font-rendering-demo: 1/4] gtk-demo: Improve the font rendering demo
- Date: Sun, 5 Sep 2021 01:44:21 +0000 (UTC)
commit 4ac527de74f54f3a3eaafbd4e4a598bc879d9f46
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 4 20:28:59 2021 -0400
gtk-demo: Improve the font rendering demo
Allow changing the character shown in the grid.
demos/gtk-demo/fontrendering.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c
index e95a78f7e7..b032fa335d 100644
--- a/demos/gtk-demo/fontrendering.c
+++ b/demos/gtk-demo/fontrendering.c
@@ -167,10 +167,20 @@ update_image (void)
PangoLayoutRun *run;
PangoGlyphInfo *g;
int i, j;
+ char buf[24] = { 0, };
+ int len;
+
+ if (*text == '\0')
+ text = " ";
+
+ len = g_utf8_next_char (text) - text;
+
+ for (i = 0; i < 4; i++)
+ memcpy (buf + i * len, text, len);
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
- pango_layout_set_text (layout, "aaaa", -1);
+ pango_layout_set_text (layout, buf, -1);
pango_layout_get_extents (layout, &ink, &logical);
pango_extents_to_pixels (&logical, NULL);
@@ -212,7 +222,6 @@ update_image (void)
cairo_surface_destroy (surface);
}
-
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
g_object_unref (pixbuf2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]