From 8c30fa09c9738b6b3605d94d681cee5e5ca2b371 Mon Sep 17 00:00:00 2001 From: Michael Schutte 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. . Signed-off-by: Michael Schutte --- 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