diff options
author | Tor Lillqvist <tml@iki.fi> | 1999-12-18 02:03:13 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 1999-12-18 02:03:13 +0000 |
commit | 0733eb725df081e2b3a14055d4b1fafca1cbb25c (patch) | |
tree | 4dc9b0d5e7ef246250b06fb24e22569bc4f0e3ab /gdk/win32 | |
parent | 7b93fcab55362e6e41ce267b3012d122a46a11f1 (diff) | |
download | gtk+-0733eb725df081e2b3a14055d4b1fafca1cbb25c.tar.gz |
When handling a single character (text length == 1), don't handle it as if
1999-12-18 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkfont-win32.c (gdk_text_size, gdk_text_extents):
When handling a single character (text length == 1), don't handle
it as if it was UTF-8.
Diffstat (limited to 'gdk/win32')
-rw-r--r-- | gdk/win32/gdkfont-win32.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c index dce4e0774c..89916d0726 100644 --- a/gdk/win32/gdkfont-win32.c +++ b/gdk/win32/gdkfont-win32.c @@ -1786,10 +1786,20 @@ gdk_text_size (GdkFont *font, g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); wcstr = g_new (wchar_t, text_length); - if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) - g_warning ("gdk_text_size: gdk_nmbstowchar_ts failed"); + if (text_length == 1) + { + /* For single characters, don't try to interpret as UTF-8. + */ + wcstr[0] = (guchar) text[0]; + gdk_wchar_text_handle (font, wcstr, 1, gdk_text_size_handler, arg); + } else - gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, arg); + { + if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) + g_warning ("gdk_text_size: gdk_nmbstowchar_ts failed"); + else + gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, arg); + } g_free (wcstr); @@ -1885,10 +1895,18 @@ gdk_text_extents (GdkFont *font, arg.total.cx = arg.total.cy = 0; wcstr = g_new (wchar_t, text_length); - if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) - g_warning ("gdk_text_extents: gdk_nmbstowchar_ts failed"); + if (text_length == 1) + { + wcstr[0] = (guchar) text[0]; + gdk_wchar_text_handle (font, wcstr, 1, gdk_text_size_handler, &arg); + } else - gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, &arg); + { + if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) + g_warning ("gdk_text_extents: gdk_nmbstowchar_ts failed"); + else + gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, &arg); + } g_free (wcstr); |