diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/fontspec/fontspec-lua.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/fontspec/fontspec-lua.dtx | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/fontspec/fontspec-lua.dtx b/Master/texmf-dist/source/latex/fontspec/fontspec-lua.dtx new file mode 100644 index 00000000000..f3f537c5ebd --- /dev/null +++ b/Master/texmf-dist/source/latex/fontspec/fontspec-lua.dtx @@ -0,0 +1,94 @@ +% \section{Lua module} +% +% \begin{macrocode} +%<*lua> +% \end{macrocode} +% First we define some metadata. +% \begin{macrocode} +fontspec = fontspec or {} +local fontspec = fontspec +fontspec.module = { + name = "fontspec", + version = "2.5", + date = "2016/01/30", + description = "Advanced font selection for LuaLaTeX.", + author = "Khaled Hosny, Philipp Gesang, Will Robertson", + copyright = "Khaled Hosny, Philipp Gesang, Will Robertson", + license = "LPPL" +} + +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} +% +% The following lines check for existence of a certain script, language or +% feature in a given font. +% \begin{macrocode} +local check_script = luaotfload.aux.provides_script +local check_language = luaotfload.aux.provides_language +local check_feature = luaotfload.aux.provides_feature +% \end{macrocode} +% +% The following are the function that get called from \TeX\ end. +% \begin{macrocode} +local function tempswatrue() tex.sprint([[\FontspecSetCheckBoolTrue ]]) end +local function tempswafalse() tex.sprint([[\FontspecSetCheckBoolFalse]]) end +% \end{macrocode} +% +% \begin{macrocode} +function fontspec.check_ot_script(fnt, script) + if check_script(font.id(fnt), script) then + tempswatrue() + else + tempswafalse() + end +end +% \end{macrocode} +% +% \begin{macrocode} +function fontspec.check_ot_lang(fnt, lang, script) + if check_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 check_feature(font.id(fnt), script, lang, feat) then + tempswatrue() + else + tempswafalse() + end +end +% \end{macrocode} +% +% \begin{macrocode} +local get_math_dimension = luaotfload.aux.get_math_dimension +function fontspec.mathfontdimen(fnt, str) + local mathdimens = get_math_dimension(fnt, str) + if mathdimens then + fontspec.sprint(mathdimens) + fontspec.sprint("sp") + else + fontspec.sprint("0pt") + end +end +% \end{macrocode} +% +% \begin{macrocode} +%</lua> +% \end{macrocode} |