--- kbd-1.12/man/man8/showconsolefont.8 +++ kbd-1.12/man/man8/showconsolefont.8 2008-05-07 18:19:41.000000000 +0200 @@ -13,15 +13,25 @@ showconsolefont \- Show the current EGA/ .B \-C .I console ] +[ +.B \-i +] + .SH DESCRIPTION The .B showconsolefont command outputs the current console font to stdout. -The option \-v prints additional information, while -the option \-V prints the program version number. -On Linux 2.6.1 and later, the option \-C allows one +The option \fB\-v\fR prints additional information, while +the option \fB\-V\fR prints the program version number. +On Linux 2.6.1 and later, the option \fB\-C\fR allows one to indicate the console involved. Its argument is a pathname. +The option \fB\-i\fR cause +.B showconsolefont +not to show the font table but show the value of the +used ROWS, COLUMNS, and character COUNT of the current +font with the format +.BR ROWS x COLUMNS x COUNT . .SH "SEE ALSO" .BR setfont (8) --- kbd-1.12/src/kdfontop.c +++ kbd-1.12/src/kdfontop.c 2006-07-26 18:14:55.000000000 +0200 @@ -142,8 +142,11 @@ font_charheight(char *buf, int count, in return h; } -/* may be called with buf==NULL if we only want info */ -/* must not exit - we may have cleanup to do */ +/* + * May be called with buf==NULL if we only want info. + * May be called with width==NULL and height==NULL. + * Must not exit - we may have cleanup to do. + */ int getfont(int fd, char *buf, int *count, int *width, int *height) { struct consolefontdesc cfd; @@ -193,6 +196,11 @@ getfont(int fd, char *buf, int *count, i fprintf(stderr, _("bug: getfont called with count<256\n")); return -1; } + if (!buf) + { + fprintf(stderr, _("bug: getfont using GIO_FONT needs buf.\n")); + return -1; + } i = ioctl(fd, GIO_FONT, buf); if (i) { perror("getfont: GIO_FONT"); @@ -206,11 +214,11 @@ getfont(int fd, char *buf, int *count, i int getfontsize(int fd) { - int count, width, height; + int count; int i; - count = width = height = 0; - i = getfont(fd, NULL, &count, &width, &height); + count = 0; + i = getfont(fd, NULL, &count, NULL, NULL); return (i == 0) ? count : 256; } --- kbd-1.12/src/showconsolefont.c +++ kbd-1.12/src/showconsolefont.c 2008-05-07 18:27:36.130879445 +0200 @@ -101,8 +101,15 @@ setnewunicodemap(int *list, int cnt) { static void usage(void) { fprintf(stderr, - _("usage: showconsolefont [-v|-V]\n" - "(probably after loading a font with `setfont font')\n")); + _("usage: showconsolefont -V|--version\n" + " showconsolefont [-C tty] [-v] [-i]\n" + "(probably after loading a font with `setfont font')\n" + "\n" + "Valid options are:\n" + " -C tty Device to read the font from. Default: current tty.\n" + " -v Be more verbose.\n" + " -i Don't print out the font table, just show\n" + " ROWSxCOLSxCOUNT and exit.\n")); exit(1); } @@ -110,7 +117,7 @@ int main (int argc, char **argv) { int c, n, cols, rows, nr, i, j, k; char *sep, *console = NULL; - int list[64], lth, verbose = 0; + int list[64], lth, info = 0, verbose = 0; set_progname(argv[0]); @@ -122,8 +129,11 @@ main (int argc, char **argv) { (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) print_version_and_exit(); - while ((c = getopt(argc, argv, "vC:")) != EOF) { + while ((c = getopt(argc, argv, "ivC:")) != EOF) { switch (c) { + case 'i': + info = 1; + break; case 'v': verbose = 1; break; @@ -135,11 +145,28 @@ main (int argc, char **argv) { } } - if (argc != 1) + if (optind != argc) usage(); fd = getfd(console); + if (info) + { + nr = rows = cols = 0; + n = getfont(fd, NULL, &nr, &rows, &cols); + if (n != 0) + leave(1); + if (verbose) + { + printf("Character count: %d\n", nr); + printf("Font width : %d\n", rows); + printf("Font height : %d\n", cols); + } + else + printf("%dx%dx%d\n", rows, cols, nr); + leave(0); + } + settrivialscreenmap(); getoldunicodemap();