diff options
author | Timm Bäder <mail@baedert.org> | 2021-10-16 15:44:58 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2021-10-17 11:12:14 +0200 |
commit | a61999170e94a972a245822de58595f07de26aaa (patch) | |
tree | 24b680baa32c3051840c0b5e976e1ebe7563c44a /demos | |
parent | beda50f6316fc14bb2687b3e7f0fac61d8db32a4 (diff) | |
download | gtk+-a61999170e94a972a245822de58595f07de26aaa.tar.gz |
fontrendering: Protect against NULL hints
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gtk-demo/fontrendering.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c index c349e54b26..283523f481 100644 --- a/demos/gtk-demo/fontrendering.c +++ b/demos/gtk-demo/fontrendering.c @@ -59,16 +59,18 @@ update_image (void) fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context)); hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting)); - if (strcmp (hint, "none") == 0) - hintstyle = CAIRO_HINT_STYLE_NONE; - else if (strcmp (hint, "slight") == 0) - hintstyle = CAIRO_HINT_STYLE_SLIGHT; - else if (strcmp (hint, "medium") == 0) - hintstyle = CAIRO_HINT_STYLE_MEDIUM; - else if (strcmp (hint, "full") == 0) - hintstyle = CAIRO_HINT_STYLE_FULL; - else - hintstyle = CAIRO_HINT_STYLE_DEFAULT; + hintstyle = CAIRO_HINT_STYLE_DEFAULT; + if (hint) + { + if (strcmp (hint, "none") == 0) + hintstyle = CAIRO_HINT_STYLE_NONE; + else if (strcmp (hint, "slight") == 0) + hintstyle = CAIRO_HINT_STYLE_SLIGHT; + else if (strcmp (hint, "medium") == 0) + hintstyle = CAIRO_HINT_STYLE_MEDIUM; + else if (strcmp (hint, "full") == 0) + hintstyle = CAIRO_HINT_STYLE_FULL; + } cairo_font_options_set_hint_style (fopt, hintstyle); if (gtk_check_button_get_active (GTK_CHECK_BUTTON (hint_metrics))) |