# Error when using dvipng: “+tlig; source file could not be found”

I am trying to use dvipng to compile .tex files to .dvi and then to convert it to .png. Here is the test.tex file that I am using as a minimum reproducible example:

\documentclass[]{article}

\title{Test}
\begin{document}

\maketitle
Document text body.
\end{document}


Then I sucecssfully compile it with:

lualatex --output-format=dvi test.tex


When opening the .dvi file, I see that it has been generated correctly. Then, next, I try to convert the generated test.dvi file with:

dvipng test.dvi


But then I get 4 errors:

Sorry, but miktex-makemf did not succeed for the following reason: The [lmroman12-regular]:+tlig; source file could not be found.

Sorry, but miktex-makepk did not succeed for the following reason: PK font [lmroman12-regular]:+tlig; could not be created.

Sorry, but miktex-makemf did not succeed for the following reason: The [lmroman10-regular]:+tlig; source file could not be found.

Sorry, but miktex-makepk did not succeed for the following reason: PK font [lmroman10-regular]:+tlig; could not be created.

How could I solve that? Thanks!

• Welcome! Can you convert PDF to PNG instead? Or use another engine? – cfr Jul 17 '18 at 3:21
• LuaLaTeX is using opentype fonts and dvipng does not handle these fonts. (They are not in the list of supported font types for the binary in TeX Live, at least. I assume MikTeX is the same.) – cfr Jul 17 '18 at 3:29
• @cfr Thanks for your comment! But is there a way to get dvipng those fonts or is it not flexible enough? In my case, using LuaLaTeX is imperative due to memory restrictions with other engines. Still, the final result must be converted to PNG files. – S08 Jul 17 '18 at 7:28
• Why not using standalone with the convert option? – egreg Jul 17 '18 at 9:47
• Opentype fonts aren't supported by dvipng according to its man page. Can't you use PDF output? Or @egreg's suggestion? – cfr Jul 17 '18 at 17:13

The program dvipng only supports standard .tfm fonts and is not able to use OpenType/TrueType fonts loaded by LuaTeX’s fontloader (or other similar method); no other DVI driver (notably xdvi) is able to, as far as I know.

You can do a direct conversion using standalone (run with -shell-escape) or postprocess the PDF file with a PDF to PNG utility such as ImageMagick.

\documentclass[convert,varwidth]{standalone}

\usepackage{fontspec}

\begin{document}

\title{Test}
\maketitle

Document text body.

\end{document}