aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/font_utils.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-12-11 17:00:05 -0800
committerGuy Harris <guy@alum.mit.edu>2015-12-12 01:01:46 +0000
commitb8b77aecc38f8ada88de78939e4d35d0fa535bd4 (patch)
tree8e4920303bff3e98213c8c527d9485ba85a0c59b /ui/gtk/font_utils.c
parent2ebfa30ffd8c5ef76d06f1705cb7e7797bda954a (diff)
Clamp zooming so that we don't get zero or negative font sizes.
Those are obviously wrong. Also, clean up some stuff left over from the GTK+ 1.x days; GTK+ 2.x doesn't expose raw XLFD font names, it lets you specify a font by name and size, and font_zoom() doesn't determine whether the font is resizeable - it just constructs a new font name/size pair and leaves it up to its callers to try to load the font, so "there's no such font as Wingdings Gothic" and "you can't blow up Fraktur to 10 million points" both show up as errors loading the font by name. Bug: 8854 Change-Id: I6af142c75c9ebabd1a95308c203f8cb1f36dd82f Reviewed-on: https://code.wireshark.org/review/12549 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/gtk/font_utils.c')
-rw-r--r--ui/gtk/font_utils.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/ui/gtk/font_utils.c b/ui/gtk/font_utils.c
index 825d13f552..4fb41dacf1 100644
--- a/ui/gtk/font_utils.c
+++ b/ui/gtk/font_utils.c
@@ -79,8 +79,7 @@ view_zoom_in_cb(GtkWidget *w _U_, gpointer d _U_)
case FA_SUCCESS:
break;
- case FA_FONT_NOT_RESIZEABLE:
- /* "font_apply()" popped up an alert box. */
+ case FA_ZOOMED_TOO_FAR:
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
break;
@@ -105,8 +104,7 @@ view_zoom_out_cb(GtkWidget *w _U_, gpointer d _U_)
case FA_SUCCESS:
break;
- case FA_FONT_NOT_RESIZEABLE:
- /* "font_apply()" popped up an alert box. */
+ case FA_ZOOMED_TOO_FAR:
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
break;
@@ -131,8 +129,7 @@ view_zoom_100_cb(GtkWidget *w _U_, gpointer d _U_)
case FA_SUCCESS:
break;
- case FA_FONT_NOT_RESIZEABLE:
- /* "font_apply()" popped up an alert box. */
+ case FA_ZOOMED_TOO_FAR:
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
break;
@@ -180,9 +177,7 @@ font_zoom(char *gui_font_name)
long font_point_size_l;
if (recent.gui_zoom_level == 0) {
- /* There is no zoom factor - just return the name, so that if
- this is GTK+ 1.2[.x] and the font name isn't an XLFD font
- name, we don't fail. */
+ /* There is no zoom factor - just return the name */
return g_strdup(gui_font_name);
}
@@ -196,6 +191,9 @@ font_zoom(char *gui_font_name)
/* calculate the new font size */
font_point_size_l = strtol(font_name_p, NULL, 10);
font_point_size_l += recent.gui_zoom_level;
+ /* make sure the size didn't become zero or negative */
+ if (font_point_size_l <= 0)
+ return NULL;
/* build a new font name */
new_font_name = g_strdup_printf("%s %ld", font_name_dup, font_point_size_l);
@@ -213,16 +211,8 @@ user_font_apply(void) {
/* convert font name to reflect the zoom level */
gui_font_name = font_zoom(prefs.gui_gtk2_font_name);
- if (gui_font_name == NULL) {
- /*
- * This means the font name isn't an XLFD font name.
- * We just report that for now as a font not available in
- * multiple sizes.
- */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Your current font isn't available in any other sizes.\n");
- return FA_FONT_NOT_RESIZEABLE;
- }
+ if (gui_font_name == NULL)
+ return FA_ZOOMED_TOO_FAR;
/* load normal font */
new_r_font = pango_font_description_from_string(gui_font_name);