khaledhosny / luaotfload

Moved to https://github.com/latex3/luaotfload
23 stars 15 forks source link

Rebuilding the database unnecessarily #8

Closed wspr closed 14 years ago

wspr commented 14 years ago

With the following document, everything works fine:

\documentclass{article}
\usepackage{luaotfload}
\begin{document}
\font\1="[texgyretermes-regular]" at 12pt\1 foo
\end{document}

When you add an .otf extension, however, the database is rebuilt:

\documentclass{article}
\usepackage{luaotfload}
\begin{document}
\font\1="[texgyretermes-regular.otf]" at 12pt\1 foo
\end{document}

But I think using the file: syntax doesn't cause the database to be rebuilt.

wspr commented 14 years ago

You can also trigger the same results by removing the brackets entirely. But shouldn't it check for a filename before querying the database? And even if it does need to go to the database, it should be found in there—the rebuilding is still unnecessary.

khaledhosny commented 14 years ago

If you don't have a file: keyword, the font selection will go through the resolver function which first trays to find font by name, then trays to rebuild the database and look again, then just returns the requested font name as is.

file: bypasses this altogether.

The square brackets syntax should be equivalent to using file:, it seems not to be robust enough. I'll try to see what is wrong (I don't fully understand the lpeg stuff that Hans is using).

To be in safe side, I suggest that fontspec always set keyword, either name: or file: and not depend on the square brackets, also using curly brackets for grouping is the native luatex syntax.

khaledhosny commented 14 years ago

Sorry, this lpeg stuff is beyond me, the code is in otfl-font-xtx.lua for any one interested.

khaledhosny commented 14 years ago

This is fixed now.