Create colophon file with font information in LuaTex

Is there a way to automatically generate a colophon information in LuaTex?

Ideally I would like to automatically generate a file (plain text) that will list the different font and font-families that actually appear in the tex (LuaTex) document incase latex substitutes missing fonts or if a particular fonts family isn't declared.

Thank you!

• That information is generated in the .log already. Do you mean you want this for diagnostic purposes or that you want to generate a colophon in the actual output? – jon May 23 '16 at 0:26
• Thank you. My primary goal is for diagnostic purposes. I tried 'grep font ' on the log and it wasn't as informative as I would like. I would prefer a more cleaner output -with the option for output- if it can be done easily. – DBS May 23 '16 at 0:30
• Well, you can do pdffonts myfile.pdf to get a the font info. But the .log tells you about the substitutions that were made so you can fix the problems (if any). – jon May 23 '16 at 0:38

You can put pdffonts in a script so that after you compile the document it automatically generates the text file you want, texfonts.sh:

#!/bin/sh
set -e

INFILE="$1" latexmk -pdf -lualatex "$INFILE"
pdffonts "${INFILE%.tex}.pdf" > "${INFILE%.tex}-fonts.txt"


Here's a sample file to demonstrate, test.tex:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}
\newfontfamily{\chinesefont}{FandolFang}
\newfontfamily{\greekfont}{EB Garamond}

\usepackage{sectsty}
\allsectionsfont{\sffamily}

\usepackage{lipsum}

\begin{document}

\section{Hello}
\lipsum[1]

\subsection{Unicode}

\begin{tabular}{ll}
Greek & {\greekfont λόγος} \\
Mandarin & {\chinesefont 我们爱狗。} \\
\end{tabular}

\subsection{World}
\textbf{\lipsum[2]}

\section{Code}
\verb|\relax\bye|

\end{document}


Run sh texfonts.sh test, and there will be two outputs: the text file test-fonts.txt and the PDF.

test-fonts.txt:

name                                     type              encoding         emb sub uni object ID
---------------------------------------- ----------------- ---------------- --- --- --- ---------
DETGWH+TeXGyreHeros-Bold-Identity-H      CID Type 0C       Identity-H       yes yes yes      5  0
FHSMPY+TeXGyrePagella-Regular-Identity-H CID Type 0C       Identity-H       yes yes yes      7  0
NRRIPR+EBGaramond12-Regular-Identity-H   CID Type 0C       Identity-H       yes yes yes      9  0
OAALEX+FandolFang-Regular-Identity-H     CID Type 0C       Identity-H       yes yes no      11  0
JRCOOU+TeXGyrePagella-Bold-Identity-H    CID Type 0C       Identity-H       yes yes yes     13  0
VTYOBX+TeXGyreCursor-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes     15  0


• Is that cross-platform, without needing to install other software? – user139954 Apr 8 '18 at 16:08
• If you install TeXLive from tug.org you'll have latexmk. For the script you need a Unix-like shell and the pdffonts program. Most Linux systems will have both already installed. Mac OSX provides a shell (Terminal app) but you have to install pdffonts separately: stackoverflow.com/questions/32420994/…. I don't know about Windows. – musarithmia Apr 9 '18 at 13:21