diff -uNr kbd-1.03wip.orig/CHANGES kbd-1.03wip/CHANGES --- kbd-1.03wip.orig/CHANGES Wed Sep 29 22:26:42 1999 +++ kbd-1.03wip/CHANGES Tue Aug 1 01:42:21 2000 @@ -120,3 +120,8 @@ Setfont now accepts a text file containing a list of fonts to load. o Made distinction between koi8-r and koi8-u. o spawn_console and spawn_login invoke openvt, not open. + +Changes for 1.03 (garloff@suse.de): + +o Added support for fonts with width != 8. +o Added suse12x22 font, a completed sun12x22 font with some improvements. Binary files kbd-1.03wip.orig/data/consolefonts/suse12x22.psf and kbd-1.03wip/data/consolefonts/suse12x22.psf differ diff -uNr kbd-1.03wip.orig/src/kdfontop.c kbd-1.03wip/src/kdfontop.c --- kbd-1.03wip.orig/src/kdfontop.c Sun Sep 26 01:24:51 1999 +++ kbd-1.03wip/src/kdfontop.c Thu Jul 27 01:14:30 2000 @@ -118,20 +118,22 @@ #endif /* KDFONTOP */ int -font_charheight(char *buf, int count) { - int h, i; +font_charheight(char *buf, int count, int bpl) { + int h, i, x; for (h = 32; h > 0; h--) for (i = 0; i < count; i++) - if (buf[32*i+h-1]) - goto nonzero; + for (x = 0; x < bpl; x++) + if (buf[(32*i+h-1)*bpl+x]) + goto nonzero; + nonzero: return h; } - + int -getfont(int fd, char *buf, int *count, int *height) { +getfont(int fd, char *buf, int *count, int *width, int *height) { struct consolefontdesc cfd; struct console_font_op cfo; int i; @@ -147,11 +149,16 @@ *count = cfo.charcount; if (height) *height = cfo.height; + if (width) + *width = cfo.width; +#if 0 + /* We do support width != 8. */ if (cfo.width != 8) { fprintf(stderr, _("kdfontop.c: only width 8 supported\n")); exit(1); } +#endif return 0; } if (errno != ENOSYS && errno != EINVAL) { @@ -159,6 +166,8 @@ return -1; } + /* The other methods do not support width != 8 */ + if (width) *width = 8; /* Second attempt: GIO_FONTX */ cfd.charcount = *count; cfd.charheight = 0; @@ -166,6 +175,8 @@ i = ioctl(fd, GIO_FONTX, &cfd); if (i == 0) { *count = cfd.charcount; + if (height) + *height = cfd.charheight; return 0; } if (errno != ENOSYS && errno != EINVAL) { @@ -188,18 +199,19 @@ } int -putfont(int fd, char *buf, int count, int height) { +putfont(int fd, char *buf, int count, int width, int height, int hwunit) { struct consolefontdesc cfd; struct console_font_op cfo; int i; - if (!height) - height = font_charheight(buf, count); + if (!width) width = 8; + if (!hwunit) + hwunit = font_charheight(buf, count, width); /* First attempt: KDFONTOP */ cfo.op = KD_FONT_OP_SET; cfo.flags = 0; - cfo.width = 8; + cfo.width = width; cfo.height = height; cfo.charcount = count; cfo.data = buf; diff -uNr kbd-1.03wip.orig/src/kdfontop.h kbd-1.03wip/src/kdfontop.h --- kbd-1.03wip.orig/src/kdfontop.h Sun Sep 26 01:31:01 1999 +++ kbd-1.03wip/src/kdfontop.h Thu Jul 27 01:05:17 2000 @@ -3,15 +3,15 @@ * Return 0 on success -1 on failure. * Sets number of glyphs in COUNT, glyph height in HEIGHT. */ -extern int getfont(int fd, char *buf, int *count, int *height); +extern int getfont(int fd, char *buf, int *count, int *width, int *height); /* * Load kernel font of pointsize HEIGHT from BUF with length COUNT. * Return 0 on success, -1 on failure. */ -extern int putfont(int fd, char *buf, int count, int height); +extern int putfont(int fd, char *buf, int count, int width, int height, int hwunit); /* * Find the maximum height of nonblank pixels (in the 32*COUNT bytes of BUF). */ -extern int font_charheight(char *buf, int count); +extern int font_charheight(char *buf, int count, int bpl); diff -uNr kbd-1.03wip.orig/src/loadunimap.c kbd-1.03wip/src/loadunimap.c --- kbd-1.03wip.orig/src/loadunimap.c Fri Oct 8 21:19:56 1999 +++ kbd-1.03wip/src/loadunimap.c Thu Jul 27 05:06:03 2000 @@ -32,6 +32,7 @@ #include "version.h" int verbose = 0; int force = 0; +int debug = 0; int main(int argc, char *argv[]) { @@ -330,13 +331,29 @@ descr = getunicodemap(fd); list = descr.entries; + for(i=0; i 1) + appendseparator(fp, 1, utf8); +#endif + if (debug) printf ("\nchar %03x: ", i); + for(j=0; jprev; - ul = up->prev; + usl = ul->seq; + while (usl->next) usl = usl->next; us = xmalloc(sizeof(struct unicode_seq)); us->uc = uc; - us->prev = ul->seq->prev; - us->prev->next = us; + us->prev = usl; us->next = NULL; - ul->seq->prev = us; + usl->next = us; + //ul->seq->prev = us; } static unsigned int @@ -63,13 +66,13 @@ static unsigned int assemble_utf8(char **inptr, int cnt) { unsigned char *in; - unsigned int uc, uc2; - int need, bit, bad = 0; + unsigned int uc, uc1, uc2 = 0; + int need, need1, bit, bad = 0; in = (unsigned char *)(* inptr); - uc = *in++; + uc = *in++; need = 0; - bit = 0x80; + bit = 0x80; uc1 = uc; while(uc & bit) { need++; bit >>= 1; @@ -80,6 +83,7 @@ fprintf(stderr, u, progname); exit(EX_DATAERR); } + need1 = need; if (need == 1) bad = 1; else if (need) while(--need) { @@ -91,8 +95,8 @@ uc = ((uc << 6) | (uc2 & 0x3f)); } if (bad) { - char *u = _("%s: bad utf8\n"); - fprintf(stderr, u, progname); + char *u = _("%s: bad utf8 %02x %02x (need %i, cnt %i)\n"); + fprintf(stderr, u, progname, uc1, uc2, need1, cnt); exit(EX_DATAERR); } *inptr = in; @@ -147,8 +151,12 @@ } if (inseq == 0) addpair(up, unichar); - else { - addseq(up, unichar); + else + { + if (inseq == 1) + addpair(up, unichar); + else + addseq(up, unichar); inseq++; } } @@ -177,12 +185,12 @@ int readpsffont(FILE *fontf, char **allbufp, int *allszp, char **fontbufp, int *fontszp, - int *fontlenp, int fontpos0, + int *fontlenp, int *fontwidthp, int fontpos0, struct unicode_list **uclistheadsp) { char *inputbuf = NULL; int inputbuflth = 0; - int inputlth, fontlen, charsize, hastable, ftoffset, utf8; - int i, k, n; + int inputlth, fontlen, fontwidth, charsize, hastable, ftoffset, utf8; + int i, k, n, bpl; /* * We used to look at the length of the input file @@ -190,7 +198,7 @@ * just read the entire file. */ if (fontf) { - inputbuflth = 16384; /* random */ + inputbuflth = MAXFONTSIZE/4; /* random */ inputbuf = xmalloc(inputbuflth); n = 0; @@ -239,6 +247,7 @@ hastable = (psfhdr->mode & (PSF1_MODEHASTAB|PSF1_MODEHASSEQ)); ftoffset = sizeof(struct psf1_header); utf8 = 0; + fontwidth = 8; } else if (inputlth >= sizeof(struct psf2_header) && PSF2_MAGIC_OK((unsigned char *)inputbuf)) { struct psf2_header *psfhdr; @@ -254,6 +263,7 @@ charsize = psfhdr->charsize; hastable = (psfhdr->flags & PSF2_HAS_UNICODE_TABLE); ftoffset = psfhdr->headersize; + fontwidth = psfhdr->width; utf8 = 1; } else return -1; /* not psf */ @@ -282,6 +292,8 @@ *fontszp = fontlen * charsize; if (fontlenp) *fontlenp = fontlen; + if (fontwidth) + *fontwidthp = fontwidth; if (!uclistheadsp) return 0; /* got font, don't need unicode_list */ @@ -360,6 +372,13 @@ perror("appendunimap"); exit(1); } + if (debug) { + printf ("("); + if (!utf8) + printf ("U+"); + while (n < 6) printf ("%02x ", out[n++]); + printf (")"); + } } void @@ -379,18 +398,20 @@ } } -void -writepsffont(FILE *ofil, char *fontbuf, int charsize, int fontlen, - int psftype, struct unicode_list *uclistheads) { +int +writepsffont(FILE *ofil, char *fontbuf, int width, int charsize, int fontlen, + int psftype, struct unicode_list *uclistheads, int fd) { int i; int utf8; int seqs = 0; + int bpl = (width + 7) / 8; + int height = charsize / bpl; - if (uclistheads) + if (uclistheads && uclistheads != (struct unicode_list*)-1) seqs = has_sequences(uclistheads, fontlen); /* Output new font file */ - if ((fontlen != 256 && fontlen != 512) || psftype == 2) { + if ((fontlen != 256 && fontlen != 512) || psftype == 2 || width != 8) { struct psf2_header h; h.magic[0] = PSF2_MAGIC0; @@ -404,8 +425,8 @@ h.flags |= PSF2_HAS_UNICODE_TABLE; h.length = fontlen; h.charsize = charsize; - h.width = 8; - h.height = charsize; + h.width = width; + h.height = height; fwrite(&h, sizeof(h), 1, ofil); utf8 = 1; } else { @@ -423,7 +444,8 @@ utf8 = 0; } fwrite(fontbuf, charsize, fontlen, ofil); - if (uclistheads != NULL) { + /* unimaps: -1 => do nothing: caller will append map */ + if (uclistheads != NULL && uclistheads != (struct unicode_list*)-1) { struct unicode_list *ul; struct unicode_seq *us; @@ -442,5 +464,6 @@ appendseparator(ofil, 0, utf8); } } + return utf8; } diff -uNr kbd-1.03wip.orig/src/psffontop.h kbd-1.03wip/src/psffontop.h --- kbd-1.03wip.orig/src/psffontop.h Mon Sep 27 21:00:49 1999 +++ kbd-1.03wip/src/psffontop.h Thu Jul 27 02:45:11 2000 @@ -1,3 +1,11 @@ +/* psffontop.h */ + +#ifndef _PSFFONTOP_H +#define _PSFFONTOP_H + +/* Maximum font size that we try to handle */ +#define MAXFONTSIZE 65536 + typedef unsigned int unicode; struct unicode_seq { @@ -14,12 +22,14 @@ extern int readpsffont(FILE *fontf, char **allbufp, int *allszp, char **fontbufp, int *fontszp, - int *fontlenp, int fontpos0, + int *fontlenp, int *fontwidhtp, int fontpos0, struct unicode_list **uclistheadsp); -extern void writepsffont(FILE *ofil, char *fontbuf, - int charsize, int fontlen, int psftype, - struct unicode_list *uclistheads); +extern int writepsffont(FILE *ofil, char *fontbuf, int width, + int charsize, int fontlen, int psftype, + struct unicode_list *uclistheads, int fd); extern void appendunicode(FILE *fp, unsigned int uc, int utf8); extern void appendseparator(FILE *fp, int seq, int utf8); + +#endif /* _PSFFONTOP_H */ diff -uNr kbd-1.03wip.orig/src/psfxtable.c kbd-1.03wip/src/psfxtable.c --- kbd-1.03wip.orig/src/psfxtable.c Thu Dec 9 14:52:31 1999 +++ kbd-1.03wip/src/psfxtable.c Thu Jul 27 05:01:55 2000 @@ -225,6 +225,8 @@ } } +int debug = 0; + int main(int argc, char **argv) { char *ifname, *ofname, *itname, *otname; @@ -233,6 +235,7 @@ int i; char *inbuf, *fontbuf; int inbuflth, fontbuflth; + int width = 8; set_progname(argv[0]); @@ -352,7 +355,7 @@ } if (readpsffont(ifil, &inbuf, &inbuflth, &fontbuf, &fontbuflth, - &fontlen, 0, itab ? NULL : &uclistheads) == -1) { + &fontlen, &width, 0, itab ? NULL : &uclistheads) == -1) { char *u = _("%s: Bad magic number on %s\n"); fprintf(stderr, u, progname, ifname); exit(EX_DATAERR); @@ -411,8 +414,8 @@ } if (ofil) { - writepsffont(ofil, fontbuf, charsize, fontlen, psftype, - notable ? NULL : uclistheads); + writepsffont(ofil, fontbuf, width, charsize, fontlen, psftype, + notable ? NULL : uclistheads, 0); fclose(ofil); } diff -uNr kbd-1.03wip.orig/src/setfont.c kbd-1.03wip/src/setfont.c --- kbd-1.03wip.orig/src/setfont.c Tue Oct 26 16:39:25 1999 +++ kbd-1.03wip/src/setfont.c Mon Jul 31 21:36:05 2000 @@ -45,10 +45,10 @@ extern void loadnewmap(int fd, char *mfil); extern void activatemap(void); extern void disactivatemap(void); -extern int font_charheight(char *buf, int count); int verbose = 0; int force = 0; +int debug = 0; /* search for the font in these directories (with trailing /) */ char *fontdirpath[] = { "", DATADIR "/" FONTDIR "/", 0 }; @@ -119,6 +119,8 @@ print_version_and_exit(); } else if (!strcmp(argv[i], "-v")) { verbose = 1; + } else if (!strcmp(argv[i], "-d")) { + debug = 1; } else if (!strcmp(argv[i], "-R")) { restore = 1; } else if (!strcmp(argv[i], "-O")) { @@ -230,37 +232,45 @@ static int erase_mode = 1; static void -do_loadfont(int fd, char *inbuf, int unit, int hwunit, int fontsize, +do_loadfont(int fd, char *inbuf, int width, int unit, int hwunit, int fontsize, char *pathname) { char *buf; int i, buflen; int bad_video_erase_char = 0; + int bpl = (width + 7) / 8; - buflen = 32*fontsize; - if (buflen < 32*128) /* below we access position 32 */ - buflen = 32*128; /* so need at least 32*33 */ + buflen = 32*fontsize*bpl; + if (buflen < 32*128*bpl) /* below we access position 32 */ + buflen = 32*128*bpl; /* so need at least 32*33 */ buf = xmalloc(buflen); memset(buf,0,buflen); if (unit < 1 || unit > 32) { - fprintf(stderr, _("Bad character size %d\n"), unit); + fprintf(stderr, _("Bad character height %d\n"), unit); + exit(EX_DATAERR); + } + if (width < 1 || width > 32) { + fprintf(stderr, _("Bad character width %d\n"), width); exit(EX_DATAERR); } if (!hwunit) hwunit = unit; + //hwunit = (unit > 32? 64: (unit > 16? 32: (unit > 8? 16: 8))); + for (i = 0; i < fontsize; i++) - memcpy(buf+(32*i), inbuf+(unit*i), unit); + memcpy(buf+(32*i*bpl), inbuf+(unit*i*bpl), unit*bpl); + /* * Due to a kernel bug, font position 32 is used * to erase the screen, regardless of maps loaded. * So, usually this font position should be blank. */ if (erase_mode) { - for (i = 0; i < 32; i++) - if (buf[32*32+i]) + for (i = 0; i < 32*bpl; i++) + if (buf[32*32*bpl+i]) bad_video_erase_char = 1; if (bad_video_erase_char) { fprintf(stderr, @@ -270,8 +280,8 @@ case 3: exit(EX_DATAERR); case 2: - for (i = 0; i < 32; i++) - buf[32*32+i] = 0; + for (i = 0; i < 32*bpl; i++) + buf[32*32*bpl+i] = 0; fprintf(stderr, _("%s: wiped it\n"), progname); break; case 1: @@ -286,14 +296,14 @@ if (verbose) { if (pathname) - printf(_("Loading %d-char 8x%d font from file %s\n"), - fontsize, unit, pathname); + printf(_("Loading %d-char %dx%d (%d) font from file %s\n"), + fontsize, width, unit, hwunit, pathname); else - printf(_("Loading %d-char 8x%d font\n"), - fontsize, unit); + printf(_("Loading %d-char %dx%d (%d) font\n"), + fontsize, width, unit, hwunit); } - if (putfont(fd, buf, fontsize, hwunit)) + if (putfont(fd, buf, fontsize, width, unit, hwunit)) exit(EX_OSERR); } @@ -319,15 +329,28 @@ up = xmalloc(maxct * sizeof(struct unipair)); for (i = 0; i < fontsize; i++) { ul = uclistheads[i].next; + if (debug) printf ("char %03x:", i); while(ul) { us = ul->seq; if (us && ! us->next) { up[ct].unicode = us->uc; up[ct].fontpos = i; ct++; + if (debug) printf (" %04x", us->uc); } + else + if (debug) { + printf (" seq: <"); + while (us) { + printf (" %04x", us->uc); + us = us->next; + } + printf (" >"); + } ul = ul->next; + if (debug) printf (","); } + if (debug) printf ("\n"); } if (ct != maxct) { char *u = _("%s: bug in do_loadtable\n"); @@ -372,8 +395,8 @@ int iunit, int hwunit, int no_m, int no_u) { FILE *fpi; char *ifil, *inbuf, *fontbuf, *bigfontbuf; - int inputlth, fontbuflth, fontsize, unit; - int bigfontbuflth, bigfontsize, bigunit; + int inputlth, fontbuflth, fontsize, unit, width, bpl; + int bigfontbuflth, bigfontsize, bigunit, bigwidth; struct unicode_list *uclistheads; int i; @@ -389,6 +412,7 @@ bigfontsize = 0; uclistheads = NULL; bigunit = 0; + bigwidth = 0; for (i=0; i %i (%i)\n", ct, height, unit); + for (c = 0; c < ct; c++) + memmove (buf+height*bpl*c, buf+32*bpl*c, height*bpl); + } + if (unimap_follows) + *utf8 = writepsffont(fpo, buf, width, height*bpl, ct, 0, (struct unicode_list*)-1, fd); + else + writepsffont(fpo, buf, width, height*bpl, ct, 0, 0, fd); + if (verbose) + printf(_("Saved %d-char %dx%d font file on %s\n"), ct, width, unit, ofil); + if (count) + *count = ct; + return; +#if 0 + /* old font save routine */ struct psf1_header psfhdr; psfhdr.magic[0] = PSF1_MAGIC0; @@ -622,6 +679,7 @@ fprintf(stderr, _("Cannot write font file header")); exit(EX_IOERR); } +#endif } if (unit == 0) @@ -643,12 +701,13 @@ static void saveoldfont(int fd, char *ofil) { FILE *fpo; + int utf8; if((fpo = fopen(ofil, "w")) == NULL) { perror(ofil); exit(EX_CANTCREAT); } - do_saveoldfont(fd, ofil, fpo, 0, NULL); + do_saveoldfont(fd, ofil, fpo, 0, NULL, &utf8); fclose(fpo); } @@ -656,14 +715,15 @@ saveoldfontplusunicodemap(int fd, char *Ofil) { FILE *fpo; int ct; + int utf8 = 0; if((fpo = fopen(Ofil, "w")) == NULL) { perror(Ofil); exit(EX_CANTCREAT); } ct = 0; - do_saveoldfont(fd, Ofil, fpo, 1, &ct); - appendunicodemap(fd, fpo, ct, 0); + do_saveoldfont(fd, Ofil, fpo, 1, &ct, &utf8); + appendunicodemap(fd, fpo, ct, utf8); fclose(fpo); }