mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Egmont Koblinger <egmont@uhulinux.hu>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Jan Engelhardt <jengelh@linux01.gwdg.de>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Behdad Esfahbod <behdad@behdad.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] console UTF-8 fixes
Date: Tue, 19 Jun 2007 14:13:02 +0200	[thread overview]
Message-ID: <20070619121302.GA4445@uhulinux.hu> (raw)
In-Reply-To: <20070417102207.GA5629@uhulinux.hu>

Hi folks,

Recently my console UTF-8 patch went mainline. Here I send a very small
additinal patch that fixes two nasty issues and improves a third one,
namely:

1. My patch changed the behavior if a glyph is not found in the Unicode
   mapping table. Previously for Unicode values less than 256 or 512 the
   kernel tried to display the glyph from that position of the glyph table,
   which could lead to a different accented letter being displayed. I
   removed this fallback possibility and changed it to display the
   replacement symbol.

   As Behdad pointed out, some fonts (e.g. sun12x22 from the kbd package)
   lack Unicode mapping information, hence all you get is lots of question
   marks. Though theoretically it's actually a user-space bug (the font
   should be fixed), Behdad and I both believe that it'd be good to work
   around in the kernel by re-introducing the fallback solution for ASCII
   characters only. This sounds a quite reasonable decision, since all fonts
   ship the ASCII characters in the first 128 positions. This way users
   won't be surprised by lots of question marks just because s/he issued a
   not-so-perfectly parameterized setfont command. As this fallback is only
   re-introduced for code points below 128, you still won't see an accented
   letter replaced by another, but at least you'll always get the English
   letters right.

2. My patch introduced "question mark with inverted color attributes" as a
   last resort fallback glyph. Though it perfectly works on VGA console, on
   framebuffer you may end up with question marks that are highlighed but
   shouldn't be, and normal characters that are accidentally highlighed.
   This is caused by missing FLUSHes when changing the color attribute.

3. I've updated the table of double-width character based on Markus's
   updated version. Only ten new code poings (one interval) is added.


Please review and commit this patch... I'm afraid it might be too late, but
it would be nice to see it in 2.6.22 -- as this will be the first stable
release that introduces my work, and the first two issues addressed now are
regressions since 2.6.21.

Thanks,

Signed-off-by: Egmont Koblinger <egmont@uhulinux.hu>

diff -Naur linux-2.6.22-rc5.orig/drivers/char/vt.c linux-2.6.22-rc5/drivers/char/vt.c
--- linux-2.6.22-rc5.orig/drivers/char/vt.c	2007-06-17 04:09:12.000000000 +0200
+++ linux-2.6.22-rc5/drivers/char/vt.c	2007-06-19 13:49:55.000000000 +0200
@@ -1956,7 +1956,7 @@
 DEFINE_MUTEX(con_buf_mtx);
 
 /* is_double_width() is based on the wcwidth() implementation by
- * Markus Kuhn -- 2003-05-20 (Unicode 4.0)
+ * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
  * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
  */
 struct interval {
@@ -1988,8 +1988,8 @@
 	static const struct interval double_width[] = {
 		{ 0x1100, 0x115F }, { 0x2329, 0x232A }, { 0x2E80, 0x303E },
 		{ 0x3040, 0xA4CF }, { 0xAC00, 0xD7A3 }, { 0xF900, 0xFAFF },
-		{ 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 }, { 0xFFE0, 0xFFE6 },
-		{ 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD }
+		{ 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 },
+		{ 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD }
 	};
 	return bisearch(ucs, double_width,
 		sizeof(double_width) / sizeof(*double_width) - 1);
@@ -2187,9 +2187,12 @@
 				    continue; /* nothing to display */
 				}
 				/* Glyph not found */
-				if (!(vc->vc_utf && !vc->vc_disp_ctrl) && !(c & ~charmask)) {
+				if ((!(vc->vc_utf && !vc->vc_disp_ctrl) || c < 128) && !(c & ~charmask)) {
 				    /* In legacy mode use the glyph we get by a 1:1 mapping.
-				       This would make absolutely no sense with Unicode in mind. */
+				       This would make absolutely no sense with Unicode in mind,
+				       but do this for ASCII characters since a font may lack
+				       Unicode mapping info and we don't want to end up with
+				       having question marks only. */
 				    tc = c;
 				} else {
 				    /* Display U+FFFD. If it's not found, display an inverse question mark. */
@@ -2213,6 +2216,7 @@
 				} else {
 					vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4);
 				}
+				FLUSH
 			}
 
 			while (1) {
@@ -2246,6 +2250,10 @@
 				if (tc < 0) tc = ' ';
 			}
 
+			if (inverse) {
+				FLUSH
+			}
+
 			if (rescan) {
 				rescan = 0;
 				inverse = 0;

  reply	other threads:[~2007-06-19 12:34 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17 10:22 Egmont Koblinger
2007-06-19 12:13 ` Egmont Koblinger [this message]
     [not found] <8aT6Q-3iM-17@gated-at.bofh.it>
     [not found] ` <8xLa7-25v-5@gated-at.bofh.it>
2007-06-19 13:54   ` Bodo Eggert
2007-06-19 14:42     ` Egmont Koblinger
2007-06-19 17:10       ` Bodo Eggert
  -- strict thread matches above, loose matches on Subject: below --
2007-04-06 19:12 Egmont Koblinger
2007-04-06 19:43 ` H. Peter Anvin
2007-04-07  9:24   ` Egmont Koblinger
2007-04-07 11:00     ` Jan Engelhardt
2007-04-07 17:26       ` Egmont Koblinger
2007-04-07 17:59         ` H. Peter Anvin
2007-04-10  9:43           ` Egmont Koblinger
2007-04-10 15:43             ` H. Peter Anvin
2007-04-10 17:19               ` Egmont Koblinger
2007-04-10 17:30                 ` H. Peter Anvin
2007-04-10 18:51                   ` Egmont Koblinger
2007-04-11 12:58                     ` Jan Engelhardt
2007-04-10 17:36                 ` Alan Cox
2007-04-10 17:36                   ` H. Peter Anvin
2007-04-11 18:28                   ` Egmont Koblinger
2007-04-11 18:36                     ` H. Peter Anvin
2007-04-12  9:11                       ` Egmont Koblinger
2007-04-12 15:36                         ` H. Peter Anvin
2007-04-12 16:41                           ` Jan Engelhardt
2007-04-12 16:55                             ` Egmont Koblinger
2007-04-12 16:58                               ` H. Peter Anvin
2007-04-12 17:16                                 ` Egmont Koblinger
2007-04-12 17:35                                   ` H. Peter Anvin
2007-04-12 17:44                                     ` Egmont Koblinger
2007-04-12 17:49                                       ` H. Peter Anvin
2007-04-12 18:46                               ` Jan Engelhardt
2007-04-12 12:54                       ` Egmont Koblinger
2007-04-12 13:13                         ` Alan Cox
2007-04-12 14:06                           ` Egmont Koblinger
2007-04-12 14:38                         ` Roman Zippel
2007-04-12 14:58                           ` Egmont Koblinger
2007-04-12 15:52                             ` Roman Zippel
2007-04-12 16:36                               ` Egmont Koblinger
2007-04-12 18:09                                 ` Roman Zippel
2007-04-11 19:00                     ` Jan Engelhardt
2007-04-12  9:22                       ` Egmont Koblinger
2007-04-11 19:36 ` Pavel Machek
2007-04-12  8:14   ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070619121302.GA4445@uhulinux.hu \
    --to=egmont@uhulinux.hu \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=behdad@behdad.org \
    --cc=hpa@zytor.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome