| 1 |
%%^^A%% fontspec-lua.dtx -- part of FONTSPEC <latex3.github.io/fontspec> |
| 2 |
% |
| 3 |
% \section{Lua module} |
| 4 |
% |
| 5 |
% \begin{macrocode} |
| 6 |
%<*lua> |
| 7 |
% \end{macrocode} |
| 8 |
% \begin{macrocode} |
| 9 |
local err, warn, info, log = luatexbase.provides_module(fontspec.module) |
| 10 |
% \end{macrocode} |
| 11 |
% Some utility functions |
| 12 |
% \begin{macrocode} |
| 13 |
fontspec.log = log or (function (s) luatexbase.module_info("fontspec", s) end) |
| 14 |
fontspec.warning = warn or (function (s) luatexbase.module_warning("fontspec", s) end) |
| 15 |
fontspec.error = err or (function (s) luatexbase.module_error("fontspec", s) end) |
| 16 |
% \end{macrocode} |
| 17 |
% |
| 18 |
% We need a catcode table for tex.sprint(). See issue \#230. |
| 19 |
% TODO: probably time to get rid of the backwards compatibility here: |
| 20 |
% \begin{macrocode} |
| 21 |
local latex |
| 22 |
if luatexbase.registernumber then |
| 23 |
latex = luatexbase.registernumber("catcodetable@latex") |
| 24 |
else |
| 25 |
latex = luatexbase.catcodetables.CatcodeTableLaTeX |
| 26 |
end |
| 27 |
% \end{macrocode} |
| 28 |
% |
| 29 |
% The following are the function that get called from \TeX\ end. |
| 30 |
% \begin{macrocode} |
| 31 |
local function tempswatrue() tex.sprint(latex,[[\FontspecSetCheckBoolTrue ]]) end |
| 32 |
local function tempswafalse() tex.sprint(latex,[[\FontspecSetCheckBoolFalse]]) end |
| 33 |
% \end{macrocode} |
| 34 |
% |
| 35 |
% \begin{macrocode} |
| 36 |
function fontspec.check_ot_script(fnt, script) |
| 37 |
if luaotfload.aux.provides_script(font.id(fnt), script) then |
| 38 |
tempswatrue() |
| 39 |
else |
| 40 |
tempswafalse() |
| 41 |
end |
| 42 |
end |
| 43 |
% \end{macrocode} |
| 44 |
% |
| 45 |
% \begin{macrocode} |
| 46 |
function fontspec.check_ot_lang(fnt, lang, script) |
| 47 |
if luaotfload.aux.provides_language(font.id(fnt), script, lang) then |
| 48 |
tempswatrue() |
| 49 |
else |
| 50 |
tempswafalse() |
| 51 |
end |
| 52 |
end |
| 53 |
% \end{macrocode} |
| 54 |
% |
| 55 |
% \begin{macrocode} |
| 56 |
function fontspec.check_ot_feat(fnt, feat, lang, script) |
| 57 |
for _, f in ipairs { "+trep", "+tlig", "+anum" } do |
| 58 |
if feat == f then |
| 59 |
tempswatrue() |
| 60 |
return |
| 61 |
end |
| 62 |
end |
| 63 |
if luaotfload.aux.provides_feature(font.id(fnt), script, lang, feat) then |
| 64 |
tempswatrue() |
| 65 |
else |
| 66 |
tempswafalse() |
| 67 |
end |
| 68 |
end |
| 69 |
% \end{macrocode} |
| 70 |
% |
| 71 |
% \begin{macrocode} |
| 72 |
function fontspec.mathfontdimen(fnt, str) |
| 73 |
local mathdimens = luaotfload.aux.get_math_dimension(fnt, str) |
| 74 |
if mathdimens then |
| 75 |
tex.sprint(-2,mathdimens) |
| 76 |
tex.sprint(-2,"sp") |
| 77 |
else |
| 78 |
tex.sprint(-2,"0pt") |
| 79 |
end |
| 80 |
end |
| 81 |
% \end{macrocode} |
| 82 |
% |
| 83 |
% \begin{macrocode} |
| 84 |
%</lua> |
| 85 |
% \end{macrocode} |
| 86 |
|
| 87 |
|
| 88 |
% /© |
| 89 |
% ------------------------------------------------ |
| 90 |
% The FONTSPEC package <latex3.github.io/fontspec> |
| 91 |
% ------------------------------------------------ |
| 92 |
% Copyright 2022-2025 The LaTeX project, LPPL "maintainer" |
| 93 |
% Copyright 2004-2022 Will Robertson |
| 94 |
% Copyright 2009-2015 Khaled Hosny |
| 95 |
% Copyright 2013 Philipp Gesang |
| 96 |
% Copyright 2013-2016 Joseph Wright |
| 97 |
% ------------------------------------------------ |
| 98 |
% This package is free software and may be redistributed and/or modified under |
| 99 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 100 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 101 |
% ------------------------------------------------ |
| 102 |
% ©/ |