lualatex / luaotfload

OpenType font loader for LuaTeX
Other
26 stars 8 forks source link

Loading non-system font fails #162

Closed Evpok closed 10 years ago

Evpok commented 10 years ago

Since the last update, I am unable to load non-system fonts. Here is an example with fontspec, I have the following paper.tex and a ebg.orf file in the same directory, the font file worked with the older versions of luaotfload

\documentclass{article}
\usepackage{fontspec}
\setmainfont{ebg.otf}
\begin{document}
    hello
\end{document}

It fails with

(/usr/local/texlive/2013/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
! LuaTeX error ...xmf-dist/tex/luatex/luaotfload/luaotfload-fontloader.lua:3138:
 bad argument #1 to 'gsub' (string expected, got nil).
<to be read again> 
\scan_stop: 
l.3     \setmainfont{ebg.otf}

I have been able to reproduce this behaviour (including the bad argument error) with pure luaotfload code, using \font\ebgar="[./ebg.otf]" instead of \setmainfont.

phi-gamma commented 10 years ago

This is weird. It works flawlessly in Plain like so:

\ifdefined \directlua
  \input luaotfload.sty
\fi

\font \mainfont = "file:FreeSans-DifferentName.otf" at 42pt
\mainfont

foo bar baz

\bye

But the equivalent fontspec code fails. I’ll investigate this, thanks for the report!

phi-gamma commented 10 years ago

OK, I got it. Fontspec uses Xetex-style syntax when defining fonts, so the error escaped my tests … New test files:

If you want to fix your luaotfload.lua manually, use this patch

--- /tmp/luaotfload.lua 2014-01-02 17:25:00.540952669 +0100
+++ luaotfload.lua  2014-01-02 17:26:57.327614277 +0100
@@ -340,13 +340,14 @@
           name)
         file_resolver (specification)
     else
-      local suffix = filesuffix (name)
-      if formats[suffix] then
-        specification.forced  = suffix
-        specification.name    = file.removesuffix(name)
-      else
-        specification.name = name
-      end
+        local suffix = filesuffix (name)
+        if formats[suffix] then
+            specification.forced      = suffix
+            specification.name        = file.removesuffix(name)
+            specification.forcedname  = name
+        else
+            specification.name = name
+        end
     end
 end

otherwise you’re going to have to wait for the next release to reach CTAN.

Evpok commented 10 years ago

Thanks for your reactivity :)