[latex3-commits] [git/LaTeX3-latex3-fontspec] main: Implement OnlyKpse for LuaTeX (#463) (d0ebbc7)

GitHub noreply at github.com
Mon May 30 00:38:42 CEST 2022


Repository : https://github.com/latex3/fontspec
On branch  : main
Link       : https://github.com/latex3/fontspec/commit/d0ebbc73d9adf17bc3820ce28d3793331f8e17f9

>---------------------------------------------------------------

commit d0ebbc73d9adf17bc3820ce28d3793331f8e17f9
Author: Marcel Krüger <tex at 2krueger.de>
Date:   Mon May 30 00:38:42 2022 +0200

    Implement OnlyKpse for LuaTeX (#463)
    
    * Implement KpseOnly
    
    * Add documentation


>---------------------------------------------------------------

d0ebbc73d9adf17bc3820ce28d3793331f8e17f9
 fontspec-code-internal.dtx | 14 ++++++++++++--
 fontspec-code-keyval.dtx   | 24 +++++++++++++++++++++++-
 fontspec-code-vars.dtx     |  1 +
 fontspec-doc-fontsel.tex   |  1 +
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/fontspec-code-internal.dtx b/fontspec-code-internal.dtx
index ee7e36c..86997a0 100644
--- a/fontspec-code-internal.dtx
+++ b/fontspec-code-internal.dtx
@@ -282,9 +282,9 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_font_is_file:,\@@_font_is_name:}
+% \begin{macro}{\@@_font_is_file:,\@@_font_is_name:,\@@_font_is_kpse:}
 % The \cs{@@_fontname_wrap:n} command takes the font name and either passes it through unchanged or wraps it in the syntax for loading a font `by filename'.
-% \XeTeX's syntax is followed since \pkg{luaotfload} provides compatibility.
+% For Lua\TeX\ there are two kinds kinds of filename based loading supported: Regular filename lookups which include system fonts and lookups restricted to kpse.
 %    \begin{macrocode}
 \cs_new:Nn \@@_font_is_name:
   {
@@ -298,6 +298,16 @@
     \cs_set:Npn \@@_fontname_wrap:n ##1 { [ \l_@@_font_path_tl ##1 ] }
   }
 %    \end{macrocode}
+%
+%    \begin{macrocode}
+%<*LU>
+\cs_new:Nn \@@_font_is_kpse:
+  {
+    \cs_set:Npn \@@_fontname_wrap:n ##1 { kpse: ##1 }
+  }
+%</LU>
+%<XE>\cs_new_eq:NN \@@_font_is_kpse: \@@_font_is_file:
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\@@_set_scriptlang:}
diff --git a/fontspec-code-keyval.dtx b/fontspec-code-keyval.dtx
index bb18912..91a48f0 100644
--- a/fontspec-code-keyval.dtx
+++ b/fontspec-code-keyval.dtx
@@ -63,7 +63,13 @@
     \bool_set_true:N \l_@@_noit_bool
     \bool_set_true:N \l_@@_external_bool
     \tl_set:Nn \l_@@_font_path_tl {#1}
-    \@@_font_is_file:
+    \bool_lazy_and:nnTF { \l_@@_external_kpse_bool } { \tl_if_empty_p:N \l_@@_font_path_tl }
+      {
+        \@@_font_is_kpse:
+      }
+      {
+        \@@_font_is_file:
+      }
 %<*XE>
     \keys_set:nn {fontspec-renderer} {Renderer=OpenType}
 %</XE>
@@ -89,6 +95,22 @@
 \@@_keys_define_code:nnn {fontspec} {Extension} {}
 %    \end{macrocode}
 %
+% \paragraph{\feat{KpseOnly}}
+% If the font is specified by filename, only search for it through kpse.
+% \XeTeX\ does not support finding system fonts by filename so this is always implicitly set
+% there.
+%    \begin{macrocode}
+\@@_keys_define_code:nnn {fontspec-preparse-external} {KpseOnly}
+  {
+    \bool_set_true:N \l_@@_external_kpse_bool
+    \bool_if:NT \l_@@_external_bool
+      {
+        \@@_font_is_kpse:
+      }
+  }
+\@@_keys_define_code:nnn {fontspec} {KpseOnly} {}
+%    \end{macrocode}
+%
 %
 % \paragraph{\feat{Renderer}}
 % This feature must be processed before all others (the other font shape and features
diff --git a/fontspec-code-vars.dtx b/fontspec-code-vars.dtx
index d247762..d2841b7 100644
--- a/fontspec-code-vars.dtx
+++ b/fontspec-code-vars.dtx
@@ -63,6 +63,7 @@
 \bool_new:N \l_@@_defining_encoding_bool
 \bool_new:N \l_@@_scriptlang_exist_bool
 \bool_new:N \g_@@_em_normalise_slant_bool
+\bool_new:N \l_@@_external_kpse_bool
 \bool_new:N \l_@@_proceed_bool
 %    \end{macrocode}
 %
diff --git a/fontspec-doc-fontsel.tex b/fontspec-doc-fontsel.tex
index d6ac139..4940651 100644
--- a/fontspec-doc-fontsel.tex
+++ b/fontspec-doc-fontsel.tex
@@ -129,6 +129,7 @@ wish to have them all installed in your system's font directories.
 In this case, it is more convenient to load them from a different location on your disk.
 This technique is also necessary in \XeTeX\ when loading OpenType fonts that are present within your \TeX\ distribution, such as \path{/usr/local/texlive/2013/texmf-dist/fonts/opentype/public}.
 Fonts in such locations are visible to \XeTeX\ but cannot be loaded by font name, only file name; \LuaTeX\ does not have this restriction.
+(If you for some reason want to restrict the fonts to the ones provided by your \TeX\ distribution even though you are using \LuaTeX\ you can use the \texttt{KpseOnly} option)
 
 When selecting fonts by file name, any font that can be found in the default
 search paths may be used directly (including in the current directory)





More information about the latex3-commits mailing list.