diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-04-02 03:51:01 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-04-02 03:51:01 +0000 |
commit | 131966090f43209020c032996a2f8e63af03906e (patch) | |
tree | 9fab26645f2cdc163c1a03305fed56a3076fd836 /gdk/gdkfont.c | |
parent | 9eec86b770c898b0a7ae8dc016d7b786a4973118 (diff) | |
download | gdk-pixbuf-GTK_1_2_10.tar.gz |
Released 1.2.10.GTK_1_2_10
Sun Apr 1 23:01:31 2001 Owen Taylor <otaylor@redhat.com>
* Released 1.2.10.
Sun Apr 1 22:22:47 2001 Owen Taylor <otaylor@redhat.com>
[ Addition of safety checks to try to avoid segfaulting
on broken setups always. ]
* gdk/gdkfont.c (_gdk_font_wc_to_glyphs): Add a boolean
return value to deal with failure of conversion of
wide characters to glyphs.
* gtk/gtkentry.c gtk/gtklabel.c: Handle failure of
mbstowcs/wcstombs a bit better.
* gdk/gdkfont.c gdk/gdkdraw.c: Deal with failure of
_gdk_font_wc_to_glyphs() gracefully
* gdk/gdkim.c (_gdk_wcstombs_len): quietly return NULL on
failure instead of g_return_if_fail().
Wed Mar 28 16:05:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c (gtk_font_selection_select_size): Fix
problem where fractional sizes caused infinite loop.
(bugzilla.redhat.com #33081)
Wed Mar 28 14:52:08 2001 Owen Taylor <otaylor@redhat.com>
* docs/Makefile.am: Remove excess rules breaking
distcheck.
Diffstat (limited to 'gdk/gdkfont.c')
-rw-r--r-- | gdk/gdkfont.c | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/gdk/gdkfont.c b/gdk/gdkfont.c index ec9dd563d..072852d37 100644 --- a/gdk/gdkfont.c +++ b/gdk/gdkfont.c @@ -403,12 +403,14 @@ gdk_text_width_wc (GdkFont *font, gchar *glyphs; int glyphs_len; - _gdk_font_wc_to_glyphs (font, text, text_length, - &glyphs, &glyphs_len); - - width = gdk_text_width (font, glyphs, glyphs_len); - - g_free (glyphs); + if (_gdk_font_wc_to_glyphs (font, text, text_length, + &glyphs, &glyphs_len)) + { + width = gdk_text_width (font, glyphs, glyphs_len); + g_free (glyphs); + } + else + width = 0; break; } @@ -510,12 +512,14 @@ gdk_char_width_wc (GdkFont *font, { gchar *glyphs; int glyphs_len; - - _gdk_font_wc_to_glyphs (font, &character, 1, &glyphs, &glyphs_len); - - width = gdk_text_width (font, glyphs, glyphs_len); - - g_free (glyphs); + + if (_gdk_font_wc_to_glyphs (font, &character, 1, &glyphs, &glyphs_len)) + { + width = gdk_text_width (font, glyphs, glyphs_len); + g_free (glyphs); + } + else + width = 0; break; } @@ -637,13 +641,26 @@ gdk_text_extents_wc (GdkFont *font, gchar *glyphs; int glyphs_len; - _gdk_font_wc_to_glyphs (font, text, text_length, - &glyphs, &glyphs_len); - - gdk_text_extents (font, glyphs, glyphs_len, - lbearing, rbearing, width, ascent, descent); - - g_free (glyphs); + if (_gdk_font_wc_to_glyphs (font, text, text_length, + &glyphs, &glyphs_len)) + { + gdk_text_extents (font, glyphs, glyphs_len, + lbearing, rbearing, width, ascent, descent); + g_free (glyphs); + } + else + { + if (lbearing) + *lbearing = 0; + if (rbearing) + *rbearing = 0; + if (width) + *width = 0; + if (ascent) + *ascent = 0; + if (descent) + *descent = 0; + } break; } @@ -821,7 +838,7 @@ gdk_char_height (GdkFont *font, return gdk_text_height (font, &character, 1); } -void +gboolean _gdk_font_wc_to_glyphs (GdkFont *font, const GdkWChar *text, gint text_length, @@ -831,8 +848,8 @@ _gdk_font_wc_to_glyphs (GdkFont *font, XFontStruct *xfont; GdkFontPrivate *font_private = (GdkFontPrivate*) font; - g_return_if_fail (font != NULL); - g_return_if_fail (font->type == GDK_FONT_FONT); + g_return_val_if_fail (font != NULL, FALSE); + g_return_val_if_fail (font->type == GDK_FONT_FONT, FALSE); xfont = (XFontStruct *) font_private->xfont; @@ -844,12 +861,14 @@ _gdk_font_wc_to_glyphs (GdkFont *font, char *mbstr = _gdk_wcstombs_len (text, text_length); if (result_length) - *result_length = strlen (mbstr); + *result_length = mbstr ? strlen (mbstr) : 0; if (result) *result = mbstr; else g_free (mbstr); + + return mbstr != NULL; } else { @@ -872,5 +891,7 @@ _gdk_font_wc_to_glyphs (GdkFont *font, if (result_length) *result_length = text_length; + + return TRUE; } } |