pdfTeX loads texmf-var/fonts/map/pdftex/updmap/pdftex.map and
texmf-dist/ls-R at startup, which can take over 100 ms in a full TeX
Live install. You can replace the default font map file with
\pdfmapfile
// $ gcc -fPIC -shared -O2 preload.c -o preload.so
// $ LD_PRELOAD=./preload.so pdftex gentle.tex >/dev/null
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
static struct node {
struct node *next;
char *path;
FILE *fptr;
} *open_files;
static unsigned int time_ns(void) {
struct timespec t;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t);
return t.tv_nsec;
}
FILE *fopen(char const *path, char const *mode) {
static FILE *(*foo)(char const *, char const *);
if (!foo) foo = dlsym(RTLD_NEXT, "fopen");
if (!strcmp(path, "/.../texmf-dist/ls-R"))
path = "/.../custom/ls-R";
if (!strcmp(path, "/.../texmf-var/fonts/map/pdftex/updmap/pdftex.map"))
path = "/.../custom/pdftex.map";
fprintf(stderr, "%09u fopen %s, %s\n", time_ns(), path, mode);
FILE *ret = foo(path, mode);
struct node *head = malloc(sizeof(*head));
head->next = open_files;
head->path = strdup(path);
head->fptr = ret;
open_files = head;
return ret;
}
int fclose(FILE *stream) {
static int (*foo)(FILE *);
if (!foo) foo = dlsym(RTLD_NEXT, "fclose");
char *path = "unknown";
for (struct node *p = open_files; p; p = p->next) {
if (p->fptr == stream) {
path = p->path;
break;
}
}
fprintf(stderr, "%09u fclose %s\n", time_ns(), path);
return foo(stream);
}
This page is copyright © 2026 Vursc and licensed under CC BY-NC-ND 4.0.