Debian Codegraph @

texmf-dist/tex/latex/fontspec/fontspec.lua

raw
1 --
2 -- This is file `fontspec.lua',
3 -- generated with the docstrip utility.
4 --
5 -- The original source files were:
6 --
7 -- fontspec.dtx (with options: `lua')
8 -- fontspec-lua.dtx (with options: `lua')
9 -- ------------------------------------------------
10 -- The FONTSPEC package <latex3.github.io/fontspec>
11 -- ------------------------------------------------
12 -- Copyright 2022-2025 The LaTeX project, LPPL "maintainer"
13 -- Copyright 2004-2022 Will Robertson
14 -- Copyright 2009-2013 Khaled Hosny
15 -- ------------------------------------------------
16 -- This package is free software and may be redistributed and/or modified under
17 -- the conditions of the LaTeX Project Public License, version 1.3c or higher
18 -- (your choice): <http://www.latex-project.org/lppl/>.
19 -- ------------------------------------------------
20 -- ^^A%% fontspec.dtx -- part of FONTSPEC <latex3.github.io/fontspec>
21 -- ^^A%% Metadata for the package, including files and versioning
22
23 fontspec = fontspec or {}
24 local fontspec = fontspec
25 fontspec.module = {
26 name = "fontspec",
27 version = "2.9g",
28 date = "2025/09/29",
29 description = "Font selection for XeLaTeX and LuaLaTeX",
30 author = "Khaled Hosny, Philipp Gesang, Will Robertson",
31 copyright = "Khaled Hosny, Philipp Gesang, Will Robertson",
32 license = "LPPL v1.3c"
33 }
34
35 -- ^^A%% fontspec-lua.dtx -- part of FONTSPEC <latex3.github.io/fontspec>
36 local err, warn, info, log = luatexbase.provides_module(fontspec.module)
37 fontspec.log = log or (function (s) luatexbase.module_info("fontspec", s) end)
38 fontspec.warning = warn or (function (s) luatexbase.module_warning("fontspec", s) end)
39 fontspec.error = err or (function (s) luatexbase.module_error("fontspec", s) end)
40 local latex
41 if luatexbase.registernumber then
42 latex = luatexbase.registernumber("catcodetable@latex")
43 else
44 latex = luatexbase.catcodetables.CatcodeTableLaTeX
45 end
46 local function tempswatrue() tex.sprint(latex,[[\FontspecSetCheckBoolTrue ]]) end
47 local function tempswafalse() tex.sprint(latex,[[\FontspecSetCheckBoolFalse]]) end
48 function fontspec.check_ot_script(fnt, script)
49 if luaotfload.aux.provides_script(font.id(fnt), script) then
50 tempswatrue()
51 else
52 tempswafalse()
53 end
54 end
55 function fontspec.check_ot_lang(fnt, lang, script)
56 if luaotfload.aux.provides_language(font.id(fnt), script, lang) then
57 tempswatrue()
58 else
59 tempswafalse()
60 end
61 end
62 function fontspec.check_ot_feat(fnt, feat, lang, script)
63 for _, f in ipairs { "+trep", "+tlig", "+anum" } do
64 if feat == f then
65 tempswatrue()
66 return
67 end
68 end
69 if luaotfload.aux.provides_feature(font.id(fnt), script, lang, feat) then
70 tempswatrue()
71 else
72 tempswafalse()
73 end
74 end
75 function fontspec.mathfontdimen(fnt, str)
76 local mathdimens = luaotfload.aux.get_math_dimension(fnt, str)
77 if mathdimens then
78 tex.sprint(-2,mathdimens)
79 tex.sprint(-2,"sp")
80 else
81 tex.sprint(-2,"0pt")
82 end
83 end
84