While trying to combine some Lua code with plots written in pgfplots
something went completely wrong. I have no idea what causes the problem, as the error message is a bit opaque to me. Here is the example which compiles nicely in luatex
without the fontspec
package:
\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{fontspec}
\usepackage{luacode}
\usepackage{filecontents}
\begin{filecontents*}{test.txt}
some text
\end{filecontents*}
\begin{luacode*}
function readtxt()
file = io.open("test.txt", "r")
text = file:read("*all")
return tex.print(text)
end
\end{luacode*}
\begin{document}
\directlua{readtxt()}
\begin{tikzpicture}
\begin{axis}
\addplot[] coordinates {(0.0, 0.0) (1,1)};
\end{axis}
\end{tikzpicture}
\end{document}
With fontspec
enabled the first error messages of a total of 58 are:
! LuaTeX error ...)/MiKTeX 2.9/tex/luatex/luaotfload/otfl-font-def.lua:239: att
empt to call field 'suffix' (a nil value).
<to be read again>
relax
l.26 \end{axis}
The lua interpreter ran into a problem, so the
remainder of this lua chunk will be ignored.
! Font \EU2/lmr/m/n/8=file:lmroman8-regular:script=latn;+trep;+tlig; at 8pt not
loadable: metric data not found or bad.
<to be read again>
relax
l.26 \end{axis}
I wasn't able to read the size data for this font,
so I will ignore the font specification.
Somehow there is some negative interaction between the three components, Lua, pgfplots
and fontspec
. Individually they all work nicely. Some interaction was reported in this question: Bad interaction between fontspec and some lua code that performs string-related search and replace operations but this seems unrelated.
Any ideas what is going on here?