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.
This commit is contained in:
Tor Lillqvist 1999-12-18 02:03:13 +00:00 committed by Tor Lillqvist
parent 7b93fcab55
commit 0733eb725d
8 changed files with 66 additions and 6 deletions

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1,3 +1,9 @@
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.
1999-12-11 Tor Lillqvist <tml@iki.fi> 1999-12-11 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Distribute README.win32. * Makefile.am: Distribute README.win32.

View File

@ -1786,10 +1786,20 @@ gdk_text_size (GdkFont *font,
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
wcstr = g_new (wchar_t, text_length); wcstr = g_new (wchar_t, text_length);
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
{
if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1)
g_warning ("gdk_text_size: gdk_nmbstowchar_ts failed"); g_warning ("gdk_text_size: gdk_nmbstowchar_ts failed");
else else
gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, arg); gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, arg);
}
g_free (wcstr); g_free (wcstr);
@ -1885,10 +1895,18 @@ gdk_text_extents (GdkFont *font,
arg.total.cx = arg.total.cy = 0; arg.total.cx = arg.total.cy = 0;
wcstr = g_new (wchar_t, text_length); wcstr = g_new (wchar_t, text_length);
if (text_length == 1)
{
wcstr[0] = (guchar) text[0];
gdk_wchar_text_handle (font, wcstr, 1, gdk_text_size_handler, &arg);
}
else
{
if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1)
g_warning ("gdk_text_extents: gdk_nmbstowchar_ts failed"); g_warning ("gdk_text_extents: gdk_nmbstowchar_ts failed");
else else
gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, &arg); gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, &arg);
}
g_free (wcstr); g_free (wcstr);