summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx92
1 files changed, 88 insertions, 4 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
index 28a4eba5fa2..48d7446d71e 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% File: l3luatex.dtx Copyright (C) 2010-2015 The LaTeX3 Project
+%% File: l3luatex.dtx Copyright (C) 2010-2016 The LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -37,7 +37,7 @@
\documentclass[full]{l3doc}
%</driver>
%<*driver|package&tex>
-\GetIdInfo$Id: l3luatex.dtx 6250 2015-11-11 13:45:38Z joseph $
+\GetIdInfo$Id: l3luatex.dtx 6465 2016-03-26 16:15:09Z joseph $
{L3 Experimental LuaTeX-specific functions}
%</driver|package&tex>
%<*driver>
@@ -262,7 +262,7 @@ local unicode_utf8_char = unicode.utf8.char
% String comparison which gives the same results as \pdfTeX{}'s
% \tn{pdfstrcmp}, although the ordering should likely not be relied upon!
% \begin{macrocode}
-local function strcmp(A, B)
+local function strcmp (A, B)
if A == B then
tex_write("0")
elseif A < B then
@@ -282,7 +282,7 @@ l3kernel.strcmp = strcmp
% to match an eventual allocator.
% \begin{macrocode}
local charcat_table = l3kernel.charcat_table or 1
-local function charcat(charcode, catcode)
+local function charcat (charcode, catcode)
tex_setcatcode(charcat_table, charcode, catcode)
tex_sprint(charcat_table, unicode_utf8_char(charcode))
end
@@ -298,6 +298,90 @@ l3kernel.charcat = charcat
%</initex|package>
% \end{macrocode}
%
+% \subsection{Format mode code: font loader}
+%
+% \begin{macrocode}
+%<*fontloader>
+% \end{macrocode}
+%
+% In format mode, there needs to be a font loader available to let us
+% use OpenType fonts. For testing, this is provided by
+% \texttt{fontloader.lua} from the Speedata Publisher system
+% (\url{https://github.com/speedata/publisher}). The code there is designed
+% to be self-contained and has a certain number of build-in assumptions,
+% so there is a small amount of compatibility required.
+%
+% The code we load looks up \texttt{texmf} tree files using
+% \texttt{kpse.filelist}, which isn't part of the standard \texttt{kpse}
+% library. The interface is emulated using metatable.
+% \begin{macrocode}
+kpse.filelist = setmetatable({}, {
+ __index = function (t, key)
+ return kpse.lookup(key)
+ end
+})
+% \end{macrocode}
+% There is a built-in assumption in \texttt{fontloader.lua} that various
+% environmental variables are set. We deal with that by intercepting the
+% relevant names and returning something sane.
+% \begin{macrocode}
+local os_getenv = os.getenv
+function os.getenv (var)
+ if var == "SP_FONT_PATH" then return "" end
+ return os_getenv(var)
+end
+% \end{macrocode}
+% As detailed in
+% \url{https://github.com/speedata/publisher/blob/develop/COPYING}, the current
+% license for Speedata Publisher is \textsc{AGPLv3}. We therefore only
+% load the file and use its public interfaces rather than copying/modifying
+% the code itself. Note though that we do have permission to use
+% \texttt{fontloader.lua} as a public domain work
+% (\url{http://chat.stackexchange.com/transcript/message/27273687#27273687}):
+% if we want to develop a richer loader we may want to take advantage of that
+% (which also applies to the simple shaper in the related \texttt{fonts.lua}
+% file).
+% \begin{macrocode}
+local fontloader = require("fontloader.lua")
+% \end{macrocode}
+% That done, register a callback which at present simply passes everything
+% through. There's no attempt to pick up font settings (which presumably
+% will be needed). Syntax is coerced to the same as for \XeTeX{}.
+% \begin{macrocode}
+callback.register("define_font",
+ function (name, size, id)
+ local opts, opttab, otfeatures = "", { }, { }
+ if string.match(name, "^%[") then
+ name, opts = string.match(name, "^%[([^%]]*)%][^:]*:?(.*)")
+ end
+ if opts ~= "" then
+ for _,kv in ipairs(string.explode(opts,";")) do
+ if string.match(kv, "=") then
+ local k, v = string.match(kv, "([^=]*)=?(.*)")
+ opttab[k] = v
+ else
+ if string.match(kv, "^+") then
+ otfeatures[string.sub(kv,2,-1)] = "true"
+ elseif string.match(kv, "^-") then
+ otfeatures[string.sub(kv,2,-1)] = "false"
+ else
+ otfeatures[kv] = "true"
+ end
+ end
+ end
+ end
+ if next(otfeatures) then
+ opttab["otfeatures"] = otfeatures
+ end
+ return select(2, fontloader.define_font(name, size, opttab))
+ end
+)
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</fontloader>
+% \end{macrocode}
+%
%\end{implementation}
%
%\PrintIndex