[tex-k] dvips: inconsistent search of PK and TFM files
Karl Berry
karl at freefriends.org
Thu Mar 10 16:58:16 CET 2022
This bug manifests itself with fonts loaded as
`\font\x=/path/to/myfont \x'
(i.e., when area is not empty).
I installed the change below (r62589). Because I removed all the
#ifdefs, the change is rather unreadable, so I'll also include the new
function as it stands. Let me know if you (anyone) see problems.
When reporting bugs, it is always helpful to show a complete example
that can be run, and the erroneous output, and the expected output.
It took me a while to delve into the different cases.
Thanks for the report,
Karl
/*
* Tries to open a tfm file in FD. Uses cmr10.tfm if unsuccessful,
* and complains loudly about it. No return, sets tfmfile global.
*/
void
tfmopen(register fontdesctype *fd)
{
char *full_name;
kpse_file_format_type d;
char *stem_name = concat(fd->area, fd->name);
if (!noomega) { /* search for .ofm first */
full_name = concat(stem_name, ".ofm");
d = ofmpath;
if ((tfmfile = search(d, full_name, READBIN)) != NULL) {
free(stem_name);
free(full_name);
return;
}
free(full_name);
}
/* try tfm */
d = tfmpath;
full_name = concat(stem_name, ".tfm");
if ((tfmfile = search(d, full_name, READBIN)) != NULL) {
free(stem_name);
free(full_name);
return;
}
sprintf(errbuf, "Can't open font metric file %.999s", full_name);
error(errbuf);
error("I will use cmr10.tfm instead, so expect bad output.");
if ((tfmfile=search(d, "cmr10.tfm", READBIN)) != NULL) {
free(stem_name);
free(full_name);
return;
}
error("! I can't find cmr10.tfm; please reinstall me with proper paths");
free(stem_name);
}
--- tfmload.c (revision 62580)
+++ tfmload.c (working copy)
@@ -26,64 +26,47 @@ badtfm(const char *s)
}
/*
- * Tries to open a tfm file. Uses cmr10.tfm if unsuccessful,
- * and complains loudly about it.
+ * Tries to open a tfm file in FD. Uses cmr10.tfm if unsuccessful,
+ * and complains loudly about it. No return, sets tfmfile global.
*/
void
tfmopen(register fontdesctype *fd)
{
- register char *n;
-#ifdef KPATHSEA
+ char *full_name;
kpse_file_format_type d;
-#else
- register char *d;
-#endif
- n = fd->name;
- if (strlen(n) + 6 >= sizeof (name)) {
- /* 6 for tfm() + null */
- error("! TFM file name too long in tfmopen") ;
- }
- if (!noomega) {
-#ifdef KPATHSEA
+ char *stem_name = concat(fd->area, fd->name);
+
+ if (!noomega) { /* search for .ofm first */
+ full_name = concat(stem_name, ".ofm");
d = ofmpath;
-#else
- d = fd->area;
- if (*d==0)
- d = ofmpath;
-#endif
-#ifdef MVSXA /* IBM: MVS/XA */
- sprintf(name, "ofm(%s)", n);
-#else
- sprintf(name, "%s.ofm", n);
-#endif
- if ((tfmfile=search(d, name, READBIN))!=NULL)
+ if ((tfmfile = search(d, full_name, READBIN)) != NULL) {
+ free(stem_name);
+ free(full_name);
return;
+ }
+ free(full_name);
}
-#ifdef KPATHSEA
+
+ /* try tfm */
d = tfmpath;
-#else
- d = fd->area;
- if (*d==0)
- d = tfmpath;
-#endif
-#ifdef MVSXA /* IBM: MVS/XA */
- sprintf(name, "tfm(%s)", n);
-#else
- sprintf(name, "%s.tfm", n);
-#endif
- if ((tfmfile=search(d, name, READBIN))!=NULL)
+ full_name = concat(stem_name, ".tfm");
+ if ((tfmfile = search(d, full_name, READBIN)) != NULL) {
+ free(stem_name);
+ free(full_name);
return;
- sprintf(errbuf, "Can't open font metric file %.500s%.500s",
- fd->area, name);
+ }
+ sprintf(errbuf, "Can't open font metric file %.999s", full_name);
error(errbuf);
+
error("I will use cmr10.tfm instead, so expect bad output.");
-#ifdef MVSXA /* IBM: MVS/XA */
- if ((tfmfile=search(d, "tfm(cmr10)", READBIN))!=NULL)
-#else
- if ((tfmfile=search(d, "cmr10.tfm", READBIN))!=NULL)
-#endif
+ if ((tfmfile=search(d, "cmr10.tfm", READBIN)) != NULL) {
+ free(stem_name);
+ free(full_name);
return;
+ }
+
error("! I can't find cmr10.tfm; please reinstall me with proper paths");
+ free(stem_name);
}
static shalfword
More information about the tex-k
mailing list.