summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fontspec/fontspec-lua.dtx
blob: 74787a51ef91617431875e57a3f4069504d16cbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
% \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.5a",
    date          = "2016/02/01",
    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 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 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(mathdimens)
        tex.sprint("sp")
    else
        tex.sprint("0pt")
    end
end
%    \end{macrocode}
%
%    \begin{macrocode}
%</lua>
%    \end{macrocode}