Linux console tools development discussion
 help / color / mirror / Atom feed
* Re: [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage
  @ 2009-05-16 19:15     ` Michael Schutte
  2009-05-18 18:00       ` Michael Schutte
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Schutte @ 2009-05-16 19:15 UTC (permalink / raw)
  To: kbd; +Cc: Jakub Wilk, 528357

[-- Attachment #1: Type: text/plain, Size: 1484 bytes --]

Hi Alexey,

Somewhere between 2.6.26 and 2.6.29, a change in the Linux kernel has
caused showconsolefont to print garbage instead of spaces.  A Debian
user has provided these two screenshots in his bug report [1]:

    http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=15;filename=showconsolefont-lenny.png;att=1;bug=528357	
    http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=showconsolefont-garbage.png;att=1;bug=528357

[1] http://bugs.debian.org/528357

This happens only when the console is in Unicode mode, which makes it
quite clear that the space character becomes something different in each
unimap showconsolefont switches to.  And indeed, if "\xef\x80\xa0"
(which is the UTF-8 representation of U+F020, a straight-to-font space)
is used instead of " ", everything is fine again for Unicode consoles;
but, not surprisingly, this produces rubbish in XLATE mode.

One way to solve this would be to check which mode the VT is in and then
using the appropriate way to print spaces.  Another idea is forcibly
switching the console to Unicode mode, dumping the font using UTF-8
characters, and then reverting the mode change if necessary, but that
would involve a near-complete rewrite of showconsolefont.c.  There might
be better solutions, but I don’t even know which commit from
linux-2.6.git introduces these problems.

Perhaps I’m also missing something obvious.  Any comments?

All the best,
-- 
Michael Schutte <michi@uiae.at>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage
  2009-05-16 19:15     ` [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage Michael Schutte
@ 2009-05-18 18:00       ` Michael Schutte
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Schutte @ 2009-05-18 18:00 UTC (permalink / raw)
  To: kbd, 528357, Jakub Wilk


[-- Attachment #1.1: Type: text/plain, Size: 300 bytes --]

tag 528357 + patch
thanks

On Sat, May 16, 2009 at 09:15:25PM +0200, Michael Schutte wrote:
> One way to solve this would be to check which mode the VT is in and then
> using the appropriate way to print spaces.

The attached patch uses this approach.

-- 
Michael Schutte <michi@uiae.at>

[-- Attachment #1.2: 528357.patch --]
[-- Type: text/x-diff, Size: 2436 bytes --]

From 8c30fa09c9738b6b3605d94d681cee5e5ca2b371 Mon Sep 17 00:00:00 2001
From: Michael Schutte <michi@uiae.at>
Date: Mon, 18 May 2009 19:47:00 +0200
Subject: [PATCH] showconsolefont: Print adequate space chars
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Figure out whether the console is in Unicode or XLATE mode to decide
whether to use a direct-to-font (U+F020) or a simple ASCII space
character, respectively.  This avoids showconsolefont’s output becoming
a mess, cf. <http://bugs.debian.org/528357>.

Signed-off-by: Michael Schutte <michi@uiae.at>
---
 src/showconsolefont.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/showconsolefont.c b/src/showconsolefont.c
index c0b58d6..733e634 100644
--- a/src/showconsolefont.c
+++ b/src/showconsolefont.c
@@ -116,7 +116,8 @@ usage(void) {
 int
 main (int argc, char **argv) {
 	int c, n, cols, rows, nr, i, j, k;
-	char *sep, *console = NULL;
+	int mode;
+	char *space, *sep, *console = NULL;
 	int list[64], lth, info = 0, verbose = 0;
 
 	set_progname(argv[0]);
@@ -148,6 +149,17 @@ main (int argc, char **argv) {
 	if (optind != argc)
 		usage();
 
+	fd = getfd(console);
+
+	if (ioctl(fd, KDGKBMODE, &mode)) {
+		perror("KDGKBMODE");
+		leave(1);
+	}
+	if (mode == K_UNICODE)
+		space = "\xef\x80\xa0";	/* U+F020 (direct-to-font space) */
+	else
+		space = " ";
+
         if (info) {
 	    nr = rows = cols = 0;
 	    n = getfont(fd, NULL, &nr, &rows, &cols);
@@ -164,8 +176,6 @@ main (int argc, char **argv) {
 	    leave(0);
 	  }
 
-	fd = getfd(console);
-
 	settrivialscreenmap();
 	getoldunicodemap();
 
@@ -175,7 +185,7 @@ main (int argc, char **argv) {
 	cols = ((n > 256) ? 32 : 16);
 	nr = 64/cols;
 	rows = (n+cols-1)/cols;
-	sep = ((cols == 16) ? "  " : " ");
+	sep = ((cols == 16) ? "%1$s%1$s" : "%1$s");
 
 	for (i=0; i<rows; i++) {
 		if (i % nr == 0) {
@@ -185,12 +195,12 @@ main (int argc, char **argv) {
 					list[lth++] = k+j*rows;
 			setnewunicodemap(list, lth);
 		}
-		printf("    ");
+		printf("%1$s%1$s%1$s%1$s", space);
 		for(j=0; j < cols && i+j*rows < n; j++) {
 			putchar(BASE + (i%nr)*cols+j);
-			printf("%s", sep);
+			printf(sep, space);
 			if (j%8 == 7)
-				printf("%s", sep);
+				printf(sep, space);
 		}
 		putchar('\n');
 		if (i%8 == 7)
-- 
1.6.2.4


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-18 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-16 19:15     ` [kbd] Bug#528357: /usr/bin/showconsolefont: produces garbage Michael Schutte
2009-05-18 18:00       ` Michael Schutte

Linux console tools development discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/kbd/0 kbd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kbd kbd/ http://lore.altlinux.org/kbd \
		kbd@lists.altlinux.org kbd@lists.altlinux.ru kbd@lists.altlinux.com
	public-inbox-index kbd

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.kbd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git