extern int loadfont_main(int argc, char **argv) { int fd; if (argc != 1) show_usage(); fd = open("/dev/tty0", O_RDWR); if (fd < 0) perror_msg_and_die("Error opening /dev/tty0"); loadnewfont(fd); return EXIT_SUCCESS; }
static void loadnewfonts(int fd, char **ifiles, int ifilct, int iunit, int hwunit, int no_m, int no_u) { char *ifil, *inbuf, *fontbuf, *bigfontbuf; int inputlth, fontbuflth, fontsize, height, width, bytewidth; int bigfontbuflth, bigfontsize, bigheight, bigwidth; struct unicode_list *uclistheads; int i; lkfile_t fp; if (ifilct == 1) { loadnewfont(fd, ifiles[0], iunit, hwunit, no_m, no_u); return; } /* several fonts that must be merged */ /* We just concatenate the bitmaps - only allow psf fonts */ bigfontbuf = NULL; bigfontbuflth = 0; bigfontsize = 0; uclistheads = NULL; bigheight = 0; bigwidth = 0; for (i=0; i<ifilct; i++) { ifil = ifiles[i]; if (findfont(ifil, &fp) && findpartialfont(ifil, &fp)) { fprintf(stderr, _("Cannot open font file %s\n"), ifil); exit(EX_NOINPUT); } inbuf = fontbuf = NULL; inputlth = fontbuflth = 0; fontsize = 0; if(readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, &width, &fontsize, bigfontsize, no_u ? NULL : &uclistheads)) { fprintf(stderr, _("When loading several fonts, all " "must be psf fonts - %s isn't\n"), fp.pathname); lk_fpclose(&fp); exit(EX_DATAERR); } lk_fpclose(&fp); // avoid zombies, [email protected] (#88501) bytewidth = (width+7) / 8; height = fontbuflth / (bytewidth * fontsize); if (verbose) printf(_("Read %d-char %dx%d font from file %s\n"), fontsize, width, height, fp.pathname); if (bigheight == 0) bigheight = height; else if (bigheight != height) { fprintf(stderr, _("When loading several fonts, all " "must have the same height\n")); exit(EX_DATAERR); } if (bigwidth == 0) bigwidth = width; else if (bigwidth != width) { fprintf(stderr, _("When loading several fonts, all " "must have the same width\n")); exit(EX_DATAERR); } bigfontsize += fontsize; bigfontbuflth += fontbuflth; bigfontbuf = xrealloc(bigfontbuf, bigfontbuflth); memcpy(bigfontbuf+bigfontbuflth-fontbuflth, fontbuf, fontbuflth); } do_loadfont(fd, bigfontbuf, bigwidth, bigheight, hwunit, bigfontsize, NULL); if (uclistheads && !no_u) do_loadtable(fd, uclistheads, bigfontsize); }