summaryrefslogtreecommitdiff
path: root/macros/unicodetex/latex/fontspec/fontspec-lua.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/unicodetex/latex/fontspec/fontspec-lua.dtx')
-rw-r--r--macros/unicodetex/latex/fontspec/fontspec-lua.dtx101
1 files changed, 101 insertions, 0 deletions
diff --git a/macros/unicodetex/latex/fontspec/fontspec-lua.dtx b/macros/unicodetex/latex/fontspec/fontspec-lua.dtx
new file mode 100644
index 0000000000..fdbe11e9d1
--- /dev/null
+++ b/macros/unicodetex/latex/fontspec/fontspec-lua.dtx
@@ -0,0 +1,101 @@
+%%^^A%% fontspec-lua.dtx -- part of FONTSPEC <wspr.io/fontspec>
+%
+% \section{Lua module}
+%
+% \begin{macrocode}
+%<*lua>
+% \end{macrocode}
+% \begin{macrocode}
+local err, warn, info, log = luatexbase.provides_module(fontspec.module)
+% \end{macrocode}
+% Some utility functions
+% \begin{macrocode}
+fontspec.log = log or (function (s) luatexbase.module_info("fontspec", s) end)
+fontspec.warning = warn or (function (s) luatexbase.module_warning("fontspec", s) end)
+fontspec.error = err or (function (s) luatexbase.module_error("fontspec", s) end)
+% \end{macrocode}
+%
+% We need a catcode table for tex.sprint(). See issue \#230.
+% TODO: probably time to get rid of the backwards compatibility here:
+% \begin{macrocode}
+local latex
+if luatexbase.registernumber then
+ latex = luatexbase.registernumber("catcodetable@latex")
+else
+ latex = luatexbase.catcodetables.CatcodeTableLaTeX
+end
+% \end{macrocode}
+%
+% The following are the function that get called from \TeX\ end.
+% \begin{macrocode}
+local function tempswatrue() tex.sprint(latex,[[\FontspecSetCheckBoolTrue ]]) end
+local function tempswafalse() tex.sprint(latex,[[\FontspecSetCheckBoolFalse]]) end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.check_ot_script(fnt, script)
+ if luaotfload.aux.provides_script(font.id(fnt), script) then
+ tempswatrue()
+ else
+ tempswafalse()
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.check_ot_lang(fnt, lang, script)
+ if luaotfload.aux.provides_language(font.id(fnt), script, lang) then
+ tempswatrue()
+ else
+ tempswafalse()
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.check_ot_feat(fnt, feat, lang, script)
+ for _, f in ipairs { "+trep", "+tlig", "+anum" } do
+ if feat == f then
+ tempswatrue()
+ return
+ end
+ end
+ if luaotfload.aux.provides_feature(font.id(fnt), script, lang, feat) then
+ tempswatrue()
+ else
+ tempswafalse()
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+function fontspec.mathfontdimen(fnt, str)
+ local mathdimens = luaotfload.aux.get_math_dimension(fnt, str)
+ if mathdimens then
+ tex.sprint(-2,mathdimens)
+ tex.sprint(-2,"sp")
+ else
+ tex.sprint(-2,"0pt")
+ end
+end
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</lua>
+% \end{macrocode}
+
+
+% /©
+% ------------------------------------------------
+% The FONTSPEC package <wspr.io/fontspec>
+% ------------------------------------------------
+% Copyright 2004-2020 Will Robertson, LPPL "maintainer"
+% Copyright 2009-2015 Khaled Hosny
+% Copyright 2013 Philipp Gesang
+% Copyright 2013-2016 Joseph Wright
+% ------------------------------------------------
+% This package is free software and may be redistributed and/or modified under
+% the conditions of the LaTeX Project Public License, version 1.3c or higher
+% (your choice): <http://www.latex-project.org/lppl/>.
+% ------------------------------------------------
+% ©/