From 0733eb725df081e2b3a14055d4b1fafca1cbb25c Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 18 Dec 1999 02:03:13 +0000 Subject: [PATCH] When handling a single character (text length == 1), don't handle it as if 1999-12-18 Tor Lillqvist * 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. --- ChangeLog | 6 ++++++ ChangeLog.pre-2-0 | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gdk/win32/gdkfont-win32.c | 30 ++++++++++++++++++++++++------ 8 files changed, 66 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99af5ca197..15bb44444e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 99af5ca197..15bb44444e 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 99af5ca197..15bb44444e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 99af5ca197..15bb44444e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 99af5ca197..15bb44444e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 99af5ca197..15bb44444e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 99af5ca197..15bb44444e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +1999-12-18 Tor Lillqvist + + * 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. + 1999-12-11 Tor Lillqvist * Makefile.am: Distribute README.win32. 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);