wdvi

network DVI viewer
Log | Files | Refs

commit 5b492da8c33c4c70bd2075e88fc67fcff37fa295
parent 4807dc4c0a794ce66c6cd125745fb9bc1ae12eff
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu,  9 Sep 2021 20:48:12 +0000

remove mktexpk support

This did not really work well and adds complexity. Let us assume
document fonts can be found between systems...

Diffstat:
Mfont-open.c | 512++-----------------------------------------------------------------------------
Mxdvi-man.sed | 127-------------------------------------------------------------------------------
Mxdvi.c | 8--------
Mxdvi.h | 8--------
4 files changed, 11 insertions(+), 644 deletions(-)

diff --git a/font-open.c b/font-open.c @@ -28,16 +28,13 @@ NOTE: \*========================================================================*/ #include <errno.h> -#include <signal.h> +#include <stdlib.h> /* free(), atoi() */ -#include <X11/Xos.h> - -#include "events.h" /* read_events(), ... */ -#include "font.h" +#include "events.h" /* ev_flags */ +#include "font.h" /* struct avl_t1 */ #include "filf-app.h" /* application-related defs, etc. */ #include "filefind.h" -#include "popups.h" /* WARN1 */ -#include "util.h" /* prep_fd(), xfopen(), xpipe(), xputenv(), ... */ +#include "util.h" /* xmalloc(), xmemdup(), avladd(), ... */ /* @@ -72,10 +69,6 @@ NOTE: #define DEFAULT_FONT_SIZES "m0:m0.5:m1:m2:m3:m4:m5" #endif -#ifdef MKTEXPK -static const char *makepkcmd = NULL; -#endif - /* * Information on how to search for pk and gf files. */ @@ -1593,485 +1586,13 @@ try_size(font, dpi, ret_path) } -#ifdef MKTEXPK - -#ifndef MKTEXPK_PATH -#ifdef MAKETEXPK -#define MKTEXPK_PATH "MakeTeXPK" -#else -#define MKTEXPK_PATH "mktexpk" -#endif -#endif - -#ifdef MAKETEXPK -#define MKPK_DEFAULT_MODE "default" -#else -#define MKPK_DEFAULT_MODE "/" -#endif - -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif - -#include <sys/wait.h> - -#include <poll.h> -#define XIO_IN POLLIN -#define XIO_OUT POLLOUT - -#ifdef EWOULDBLOCK -#ifdef EAGAIN -#define AGAIN_CONDITION (errno == EWOULDBLOCK || errno == EAGAIN) -#else /* EAGAIN */ -#define AGAIN_CONDITION (errno == EWOULDBLOCK) -#endif /* EAGAIN */ -#else /* EWOULDBLOCK */ -#ifdef EAGAIN -#define AGAIN_CONDITION (errno == EAGAIN) -#endif /* EAGAIN */ -#endif /* EWOULDBLOCK */ - -#define NOBUILD 29999 - -/* - * ffmemcpy - Copy the given number of bytes to the given position - */ - -static unsigned int -ffmemcpy(pos, src, len) - unsigned int pos; - const char *src; - unsigned int len; -{ - if (pos + len >= ffline_len) - expandline(pos + len); - memcpy(ffline + pos, src, len); - return pos + len; -} - -/* - * ffstrcpy - Copy string to ffline at the given position - */ - -static unsigned int -ffstrcpy(pos, str) - unsigned int pos; - const char *str; -{ - return ffmemcpy(pos, str, strlen(str)); -} - -/* - * ff2memcpy - Copy the given number of bytes to the given position - * *within* ffline. - */ - -static unsigned int -ff2memcpy(pos, src, len) - unsigned int pos; - unsigned int src; - unsigned int len; -{ - if (pos + len >= ffline_len) - expandline(pos + len); - memcpy(ffline + pos, ffline + src, len); - return pos + len; -} - -/* - * Stuff to handle child process termination - */ - -static Boolean mkpk_done; -static int mkpk_status; - -static void -mkpk_term(status) - int status; -{ - mkpk_done = True; - mkpk_status = status; - ev_flags |= EV_ACK; -} - -static struct xchild mkpk_child = {NULL, 0, False, mkpk_term}; - -/* - * Stuff to handle child process output - */ - -static void mkpk_get_result(void); - -static unsigned int mkpk_pos; - -static struct xio mkpk_result = {NULL, 0, XIO_IN, NULL, - mkpk_get_result, NULL}; - -static void -mkpk_get_result() -{ - int bytes; - - for (;;) { - bytes = read(mkpk_result.fd, ffline + mkpk_pos, - - ffline_len - mkpk_pos); - if (bytes < 0) { - if (AGAIN_CONDITION) - break; - perror("xdvi: mkpk_result read"); - break; - } - if (bytes == 0) break; - - mkpk_pos += bytes; - if (mkpk_pos >= ffline_len) - expandline(ffline_len); - } -} - - -/* - * makefont - call system() to make the font. - */ - -static FILE * -makefont(font, dpi, name, magstepval) - const char *font; - int dpi; - const char **name; - int magstepval; -{ - int pipefds[2]; - Boolean used_fontname = False; - Boolean used_mfmode = False; - int redirect_to = 1; - const char *p; - unsigned int argc; - unsigned int pos_end, pos1, destpos; - const char *actual_command; - char **argv; - unsigned int pos; - static Boolean did_putenv = False; - FILE *f; - char *q; - unsigned int i; - - if (xpipe(pipefds) != 0) { /* create the pipe */ - perror("[xdvi] pipe"); - return NULL; - } - - /* - * Generate the mktexpk command line. - */ - - if (makepkcmd == NULL) { - makepkcmd = getenv("XDVIMAKEPK"); - if (makepkcmd == NULL) makepkcmd = MKTEXPK_PATH; - } - p = makepkcmd; - pos = 1; - if (pos >= ffline_len) - expandline(ffline_len); - ffline[0] = '\0'; - argc = 0; - - for (;;) { - if (*p == '%') { - char buf[32]; - - switch (*++p) { - case 'n': - pos = ffstrcpy(pos, font); - used_fontname = True; - break; - case 'd': - Sprintf(buf, "%d", dpi); - pos = ffstrcpy(pos, buf); - break; - case 'b': - Sprintf(buf, "%d", pixels_per_inch); - pos = ffstrcpy(pos, buf); - break; - case 'm': - if (magstepval == NOMAGSTP) - Sprintf(buf, "%d+%d/%d", dpi / pixels_per_inch, - dpi % pixels_per_inch, pixels_per_inch); - else if (magstepval >= 0) - Sprintf(buf, "magstep(%d%s)", magstepval / 2, - magstepval % 2 ? ".5" :""); - else - Sprintf(buf, "magstep(-%d%s)", -magstepval / 2, - magstepval % 2 ? ".5" :""); - pos = ffstrcpy(pos, buf); - break; - case 'o': - pos = ffstrcpy(pos, resource.mfmode != NULL - ? resource.mfmode : MKPK_DEFAULT_MODE); - used_mfmode = True; - break; - case 'r': - pos = ffmemcpy(pos, ">&3", 3); - redirect_to = 3; - break; - case '%': - if (pos + 1 >= ffline_len) - expandline(pos + 1); - ffline[pos++] = '%'; - break; - case '\0': - --p; - break; - default: - if (pos + 2 >= ffline_len) - expandline(pos + 1); - ffline[pos++] = '%'; - ffline[pos++] = *p; - break; - } - } - else if (*p == '\0') - if (used_fontname) break; - else { -#ifndef MAKETEXPK - p = " --mfmode %o --bdpi %b --mag %m --dpi %d %n %r"; -#else -#ifdef MKPK_REDIRECT - p = " %n %d %b %m %o '' %r"; -#else - p = " %n %d %b %m"; -#endif -#endif - continue; - } - else if (*p == ' ' || *p == '\t') { - if (ffline[pos - 1] != '\0') { - ++argc; - ffline[pos++] = '\0'; - } - } - else { - if (pos + 1 >= ffline_len) - expandline(pos + 1); - ffline[pos++] = *p; - } - ++p; - } - - if (resource.mfmode != NULL && !used_mfmode) - pos = ffstrcpy(pos, resource.mfmode); - - if (ffline[pos - 1] != '\0') { - ++argc; - ffline[pos++] = '\0'; - } - - /* Form command line string */ - pos1 = 1; - destpos = pos; - if (destpos >= ffline_len) - expandline(ffline_len); - ffline[destpos++] = '-'; - for (;;) { /* loop over args */ - if (pos1 >= pos) break; /* if end of args */ - ffline[destpos++] = ' '; /* Convert \0 to space */ - pos_end = pos1 + strlen(ffline + pos1); - for (;;) { - unsigned int pos2, pos3; - - p = memchr(ffline + pos1, '\'', pos_end - pos1); - pos2 = (p == NULL ? pos_end : p - ffline); - for (pos3 = pos1;; ++pos3) - if (pos3 >= pos2) { - destpos = ff2memcpy(destpos, pos1, pos2 - pos1); - break; - } - else if (index(" \t`\"()$&<>~*?\\", ffline[pos3]) != NULL) { - if (destpos >= ffline_len) - expandline(ffline_len); - ffline[destpos++] = '\''; - destpos = ff2memcpy(destpos, pos1, pos2 - pos1); - if (destpos >= ffline_len) - expandline(ffline_len); - ffline[destpos++] = '\''; - break; - } - pos1 = pos2 + 1; - if (p == NULL) break; - destpos = ffmemcpy(destpos, "\\'", 2); - } - } - - ffline[destpos++] = '\0'; - actual_command = xmemdup(ffline + pos, destpos - pos); - Puts(actual_command); - - argv = xmalloc((argc + 1) * sizeof(*argv)); - q = ffline + 1; - for (i = 0; i < argc; ++i) { - argv[i] = q; - q += strlen(q) + 1; - } - argv[argc] = NULL; - - /* - * Put the metafont mode into the environment, if available. - */ - - if (!did_putenv) { - if (resource.mfmode != NULL) - xputenv("MAKETEX_MODE", resource.mfmode); - did_putenv = True; - } - - /* - * Create a child process. - */ - - Fflush(stderr); /* avoid double buffering */ - mkpk_child.pid = vfork(); - if (mkpk_child.pid == 0) { /* if child */ - (void) close(pipefds[0]); - if (redirect_to != pipefds[1]) { - (void) dup2(pipefds[1], redirect_to); - (void) close(pipefds[1]); - } - if (setsid() == -1) { /* so we can kill the process group */ - perror("setsid"); - Fflush(stderr); - _exit(1); - } - (void) execvp(*argv, argv); - Fprintf(stderr, "Execvp of %s failed.\n", *argv); - Fflush(stderr); - _exit(1); - } - - (void) close(pipefds[1]); - ++n_files_left; - free(argv); - - if (mkpk_child.pid == -1) { - (void) close(pipefds[0]); - ++n_files_left; - perror("[xdvi] fork"); - free((void *) actual_command); - return NULL; - } - - /* - * Now wait until the process terminates, reading whatever it writes - * to the pipe. An eof on the pipe assumes that the child terminated. - */ - - set_chld(&mkpk_child); - - prep_fd(pipefds[0], True); /* set fd for non-blocking I/O */ - - mkpk_pos = 0; - mkpk_result.fd = pipefds[0]; - set_io(&mkpk_result); - - mkpk_done = False; - for (;;) { - (void) read_events(EV_GE_NEWDOC | EV_ACK); - ev_flags &= ~EV_ACK; - - if (ev_flags & EV_GE_NEWDOC) { /* if we're aborting */ - kill(-mkpk_child.pid, SIGINT); - for (;;) { - (void) read_events(EV_ACK); - ev_flags &= ~EV_ACK; - - if (mkpk_done) { - break; - } - kill(-mkpk_child.pid, SIGKILL); - clear_chld(&mkpk_child); - break; - } - if (ev_flags & EV_GE_TERM) - exit(0); - clear_io(&mkpk_result); - (void) close(pipefds[0]); - ++n_files_left; - free((void *) actual_command); - return NULL; - } - - if (mkpk_done) - break; - } - - clear_io(&mkpk_result); - (void) close(pipefds[0]); - ++n_files_left; - - if (!WIFEXITED(mkpk_status) || WEXITSTATUS(mkpk_status) != EXIT_SUCCESS) - { - WARN1(XmDIALOG_WARNING, - "The following command for building a font file has failed:\n%s", - actual_command + 2); - free((void *) actual_command); - return NULL; - } - - if (mkpk_pos != 0 && ffline[mkpk_pos - 1] == '\n') - --mkpk_pos; /* trim off last \n */ - - /* if no response, then it probably failed, but look anyway */ - if (mkpk_pos == 0) { - if (debug & DBG_OPEN) - Printf("No response from %s\n", actual_command + 2); - free((void *) actual_command); - return try_size(font, dpi, name); - } - - if (mkpk_pos >= ffline_len) - expandline(mkpk_pos); - ffline[mkpk_pos++] = '\0'; - - if (debug & DBG_OPEN) - Printf("%s ---> %s\n", actual_command + 2, ffline); - free((void *) actual_command); - - f = xfopen(ffline, "r"); - if (f == NULL) { - perror(ffline); - return NULL; - } - - if (debug & DBG_OPEN) - puts("--Success--\n"); - *name = xmemdup(ffline, mkpk_pos); - return f; -} - -#endif /* MKTEXPK */ - /* * Try a given font name */ -#if MKTEXPK -# define PRE_FONT_OPEN(fontp, fontname, fdpi, magstepval, name_ret, dpi_ret) \ - pre_font_open(fontp, fontname, fdpi, magstepval, name_ret, dpi_ret) -#else -# define PRE_FONT_OPEN(fontp, fontname, fdpi, magstepval, name_ret, dpi_ret) \ - pre_font_open(fontp, fontname, fdpi, name_ret, dpi_ret) -#endif - static Boolean -PRE_FONT_OPEN(fontp, fontname, fdpi, magstepval, name_ret, dpi_ret) - struct font *fontp; - const char *fontname; - double fdpi; -#if MKTEXPK - int magstepval; -#endif - const char **name_ret; - int *dpi_ret; +pre_font_open(struct font *fontp, const char *fontname, double fdpi, + const char **name_ret, int *dpi_ret) { FILE *f; int *p1, *p2; @@ -2129,17 +1650,6 @@ PRE_FONT_OPEN(fontp, fontname, fdpi, magstepval, name_ret, dpi_ret) return True; } -#ifdef MKTEXPK - /* Try to create the font. */ - if (magstepval != NOBUILD && resource.makepk) { - f = makefont(fontname, dpi, name_ret, magstepval); - if (f != NULL || ev_flags & EV_GE_NEWDOC) { - fontp->file = f; - return True; - } - } -#endif - /* Now try at all the sizes. */ for (p2 = sizes; p2 < sizend; ++p2) if (*p2 >= dpi) break; p1 = p2; @@ -2184,8 +1694,8 @@ font_open(fontp, font_ret, dpi_ret) int actual_pt, low_pt, high_pt, trial_pt; char *fn, *fnend; - val = PRE_FONT_OPEN(fontp, fontp->fontname, fontp->fsize, - fontp->magstepval, &fontp->filename, dpi_ret); + val = pre_font_open(fontp, fontp->fontname, fontp->fsize, + &fontp->filename, dpi_ret); if (val || ev_flags & EV_GE_NEWDOC) { *font_ret = NULL; return val; @@ -2207,9 +1717,9 @@ font_open(fontp, font_ret, dpi_ret) else if (high_pt > actual_pt + 5) break; else trial_pt = high_pt++; Sprintf(fnend, "%d", trial_pt); - if (PRE_FONT_OPEN(fontp, fn, + if (pre_font_open(fontp, fn, fontp->fsize * actual_pt / trial_pt, - NOBUILD, &fontp->filename, dpi_ret)) { + &fontp->filename, dpi_ret)) { *font_ret = fn; return True; } @@ -2218,7 +1728,7 @@ font_open(fontp, font_ret, dpi_ret) free(fn); if (alt_font != NULL) { - if (PRE_FONT_OPEN(fontp, alt_font, fontp->fsize, fontp->magstepval, + if (pre_font_open(fontp, alt_font, fontp->fsize, &fontp->filename, dpi_ret)) { *font_ret = xstrdup(alt_font); return True; diff --git a/xdvi-man.sed b/xdvi-man.sed @@ -40,9 +40,6 @@ xdvi \- DVI Previewer for the X Window System [\fB\-offsets\fP \fIdimen\fP] [\fB\-xoffset\fP \fIdimen\fP] [\fB\-yoffset\fP \fIdimen\fP] [\fB\-paper\fP \fIpapertype\fP] [\fB\-altfont\fP \fIfont\fP] -#ifmakepk -[\fB\-nomakepk\fP] -#endif [\fB\-mfmode\fP \fImode-def\fP[\fB:\fP\fIdpi\fP]] [\fB\-nofreetypefonts\fP] [\fB\-editor\fP \fIeditor\fP] @@ -362,11 +359,6 @@ This method overrides any value given by the resource or the .B \-p command-line argument. -#ifmakepk -The metafont mode is also passed to -.B metafont -during automatic creation of fonts. -#endif By default, it is .BR "cx:600" . .TP @@ -464,20 +456,6 @@ There is no option. See also .BR \-install , and the GREYSCALING AND COLORMAPS section. -#ifmakepk -.TP -.B \-nomakepk -.RB ( .makePk ) -Turns off automatic generation of font files that cannot be found by other -means. -(For this option, the logic of the corresponding resource is reversed: -.B \-nomakepk -corresponds to -.BR makePk:off ; -.B +nomakepk -to -.BR makePK:on .) -#endif .TP .B \-noscan .RB ( .prescan ) @@ -1585,18 +1563,6 @@ See the Ghostscript documentation for more details. Determines the path(s) searched for Ghostscript-style Fontmap files if .SB XDVI_GS_LIB is not set. -#ifmakepk -.TP -.SB XDVIMAKEPK -Address of the program (and, optionally, the order of its arguments) to -be called when -.B xdvi -attempts to create a -.I gf -or -.I pk -font file. See the section on CREATING FONT FILES for more details. -#endif .SH FILE SEARCHING In order to accommodate the wide variety of ways in which fonts are stored on various sites, @@ -1882,9 +1848,6 @@ replaces all the specifiers. If no virtual font is found, then .B xdvi will -#ifmakepk -invoke Metafont to create the font in the correct size. Failing that, it will -#endif try to find the nearest size. If the font cannot be found at all, then .B xdvi @@ -2055,96 +2018,6 @@ then it would be best to set to .RB `` /home/user/texmf/%s: '', instead. -#ifmakepk -.SH CREATING FONT FILES -.PP -When -.B xdvi -reaches a point where it cannot find a font in the correct size, it calls -a program to create such a font file. The name of this program (usually -a shell script) may be controlled by the environment variable -.SB XDVIMAKEPK. -Usually this variable would be set to the name of the script. -In that case the script is called with options giving the font name, -the requested resolution in dots per inch, the base resolution in dots -per inch, a (possibly more accurate) indication of the magnification -using magsteps (if possible), and the -.I mode-def -that Metafont is to use when creating the font file. -.PP -The -.I mode-def -used is the one given by the -.B \-mfmode -argument on the command line, the -.B mfMode -resource, or the compiled-in default (if any). If none of these are given, -the string -.RB `` @MKTEXPK_DEFAULT_MODE@ '' -is used. -.PP -Optionally, the -.SB XDVIMAKEPK -variable may include the following designators: -.TP -.B %n -Replaced by the font name. -.TP -.B %d -Replaced by the resolution (in dots per inch) of the desired pixel file. -.TP -.B %b -Replaced by the base resolution of the Metafont mode. -.TP -.B %m -Replaced by an indication of the magnification to be applied. -.TP -.B %o -Replaced by the Metafont -.IR mode-def. -.TP -.B %r -Replaced by a string of the form -.BI ``>& digit '', -enclosed in single quotes, where -.I digit -indicates a file number on which the program is to write the full path of the -font file that it has created. -.PP -If the -.SB XDVIMAKEPK -string uses designators, if a -.I mode-def -is known to -.BR xdvi , -but if no -.RB `` %o '' -designator was used, then the mode will be appended to the end of the string. -Also, if no -.RB `` %r '' -was used, then -.B xdvi -expects the program to write the full path of the font file on its standard -output. -.PP -By default, -.SB XDVIMAKEPK -equals -.BR @MKTEXPK_PATH@ . -If no designator -.RB `` %n '' -appears in the -.SB XDVIMAKEPK -string, then the string -.B @MKTEXPK_TAIL@ -will be appended. -.PP -This mechanism is compatible with the font creation mechanism used in -.BR dvips (1) -and the -.B Kpathsea -library. -#endif .SH FILES .PD 0 @DEFAULT_TEXMF_PATH@ \*(Te\& Directory Structure (TDS) directories. diff --git a/xdvi.c b/xdvi.c @@ -147,10 +147,6 @@ static XrmOptionDescRec options[] = { {"-yoffset", ".yOffset", XrmoptionSepArg, (XPointer) NULL}, {"-paper", ".paper", XrmoptionSepArg, (XPointer) NULL}, {"-altfont", ".altFont", XrmoptionSepArg, (XPointer) NULL}, -#ifdef MKTEXPK -{"-nomakepk", ".makePk", XrmoptionNoArg, (XPointer) "off"}, -{"+nomakepk", ".makePk", XrmoptionNoArg, (XPointer) "on"}, -#endif {"-mfmode", ".mfMode", XrmoptionSepArg, (XPointer) NULL}, {"-l", ".listFonts", XrmoptionNoArg, (XPointer) "on"}, {"+l", ".listFonts", XrmoptionNoArg, (XPointer) "off"}, @@ -287,10 +283,6 @@ static XtResource application_resources[] = { offset(paper), XtRString, (XtPointer) DEFAULT_PAPER}, {"altFont", "AltFont", XtRString, sizeof(char *), offset(_alt_font), XtRString, (XtPointer) ALTFONT}, -#ifdef MKTEXPK -{"makePk", "MakePk", XtRBoolean, sizeof(Boolean), - offset(makepk), XtRString, "true"}, -#endif {"mfMode", "MfMode", XtRString, sizeof(char *), offset(mfmode), XtRString, MFMODE}, {"listFonts", "ListFonts", XtRBoolean, sizeof(Boolean), diff --git a/xdvi.h b/xdvi.h @@ -47,7 +47,6 @@ NOTE: #define WORDS_BIGENDIAN 1 #endif -#define MKTEXPK 1 /* automatically create missing pixel files */ #define TEXXET 1 /* Define to enable right-to-left typesetting. */ #define NORETURN __attribute__((__noreturn__)) @@ -77,10 +76,6 @@ static const char addr_default[] = "www.0x30.net/resume.dvi"; typedef unsigned char ubyte; typedef ubyte wide_ubyte; -#if defined(MAKETEXPK) && !defined(MKTEXPK) -#define MKTEXPK 1 -#endif - /* * pixel_conv is currently used only for converting absolute positions * to pixel values; although normally it should be @@ -156,9 +151,6 @@ extern struct _resource { const char *yoffset; const char *paper; const char *_alt_font; -#ifdef MKTEXPK - Boolean makepk; -#endif const char *mfmode; Boolean _list_fonts; Boolean freetype;