[latex3-commits] [l3svn] 03/04: Add support for LuaTeX \Ucharcat emulation to l3bootstrap
noreply at latex-project.org
noreply at latex-project.org
Wed Sep 9 23:10:00 CEST 2015
This is an automated email from the git hooks/post-receive script.
joseph pushed a commit to branch master
in repository l3svn.
commit cc79920047e4926558749400bf4f1a9f4906fa06
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed Sep 9 20:51:09 2015 +0100
Add support for LuaTeX \Ucharcat emulation to l3bootstrap
---
l3kernel/l3bootstrap.dtx | 65 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/l3kernel/l3bootstrap.dtx b/l3kernel/l3bootstrap.dtx
index d86d0f9..7ad37d3 100644
--- a/l3kernel/l3bootstrap.dtx
+++ b/l3kernel/l3bootstrap.dtx
@@ -395,6 +395,71 @@
\endgroup
% \end{macrocode}
%
+% \subsection{Emulating \tn{Ucharchar} in \LuaTeX{}}
+%
+% Expandably creating character tokens can be done in macros but for the
+% full Unicode range requires engine support in practical terms. That is
+% available in \XeTeX{} as \tn{Ucharcat} but in \LuaTeX{} some Lua code
+% is required. That is set up here, following the model above. Note that
+% we do not try to emulate the syntax of the primitive (doable with \LuaTeX{}
+% 0.80 or later, but not required by our use case).
+%
+% One minor wrinkle is that a catcode table is needed to return values.
+% For format mode, long-term we can simply take an arbitrary one and make
+% sure this is never allocated. In package mode use the same approach
+% (and table) as \pkg{ucharcat}: look for an allocator and use it if available,
+% or use a table unlikely to clash with any other use. We use the same table
+% as \pkg{ucharcat} but as this is \enquote{disposable} we are safe.
+% \begin{macrocode}
+\begingroup
+ \expandafter\ifx\csname directlua\endcsname\relax
+ \else
+ \ifnum\luatexversion<70 %
+ \else
+%<*initex>
+ % TEMP
+ \catcode`\@=11 %
+ \chardef\ucharcat at table="8000 %
+%</initex>
+%<*package>
+ \ifdefined\newcatcodetable
+ \newcatcodetable\ucharcat at table
+ \else
+ \directlua{tex.enableprimitives("",{"initcatcodetable"})}
+ \chardef\ucharcat at table"7000 %
+ \initcatcodetable\ucharcat at table
+ \fi
+%</package>
+ \catcode`\_=11 %
+ \catcode`\:=11 %
+ \def\tempa
+ {%
+ l3kernel = l3kernel or { }
+ local utf8_char = unicode.utf8.char
+ function l3kernel.charcat(charcode, catcode)
+ tex.setcatcode(\number\ucharcat at table, charcode, catcode)
+ tex.sprint(\number\ucharcat at table, utf8_char(charcode))
+ end
+ }
+ \directlua{\tempa}
+ \ifnum 0%
+ \directlua
+ {%
+ if status.ini_version then
+ tex.write("1")
+ end
+ }>0 %
+ \global\everyjob\expandafter
+ {%
+ \the\expandafter\everyjob
+ \expandafter\lua_now_x:n\expandafter{\tempa}%
+ }
+ \fi
+ \fi
+ \fi
+\endgroup
+% \end{macrocode}
+%
% \subsection{Engine requirements}
%
% The code currently requires functionality equivalent to \tn{pdfstrcmp}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the latex3-commits
mailing list