summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-space.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-space.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf-space.dtx130
1 files changed, 98 insertions, 32 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-space.dtx b/macros/latex/contrib/tagpdf/tagpdf-space.dtx
index 55021a74d2..9ccee62c6f 100644
--- a/macros/latex/contrib/tagpdf/tagpdf-space.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf-space.dtx
@@ -2,7 +2,7 @@
%
%% File: tagpdf-space.dtx
%
-% Copyright (C) 2019 Ulrike Fischer
+% Copyright (C) 2019-2021 Ulrike Fischer
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -21,25 +21,74 @@
% https://github.com/u-fischer/tagpdf
%
% for those people who are interested.
-%
+%<*driver>
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{}
+\makeatletter
+\declare@file@substitution{doc.sty}{doc-v3beta.sty}
+\makeatother
+\documentclass{l3doc}
+\usepackage{array,booktabs,caption}
+\hypersetup{pdfauthor=Ulrike Fischer,
+ pdftitle=tagpdf-space module (tagpdf)}
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
% \fi
+% \title{^^A
+% The \pkg{tagpdf-space} module\\ Code related to real space chars ^^A
+% \\ Part of the tagpdf package
+% }
+%
+% \author{^^A
+% Ulrike Fischer\thanks
+% {^^A
+% E-mail:
+% \href{mailto:fischer@troubleshooting-tex.de}
+% {fischer@troubleshooting-tex.de}^^A
+% }^^A
+% }
%
+% \date{Version 0.9, released 2021-06-29}
+% \maketitle
+% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
-%<*space>
-\ProvidesExplPackage {tagpdf-space-code} {2021-06-14} {0.82}
+%<*header>
+\ProvidesExplPackage {tagpdf-space-code} {2021-06-29} {0.9}
{part of tagpdf - code related to real space chars}
-% luatex uses an attribute (declared in the driver file) and some luacode in tagpdf.lua
-% perhaps I will split the code by engine in the future
-
+%</header>
+% \end{macrocode}
+% \section{Code for interword spaces}
+% The code is engine/backend dependant. Basically only pdftex and luatex
+% support real space chars. Most of the code for luatex which uses attributes
+% is in the lua code, here are only the keys.
+%
+% \begin{macro}{interwordspace,show-spaces}
+% \begin{macrocode}
+%<*package>
\sys_if_engine_pdftex:T
{
- \pdfglyphtounicode{space}{0020}
- \keys_define:nn { @@ / setup }
+ \sys_if_output_pdf:TF
{
- interwordspace .choices:nn = { true, on } { \pdfinterwordspaceon },
- interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
- show-spaces .bool_set:N = \l_@@_showspaces_bool
+ \pdfglyphtounicode{space}{0020}
+ \keys_define:nn { @@ / setup }
+ {
+ interwordspace .choices:nn = { true, on } { \pdfinterwordspaceon },
+ interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
+ interwordspace .default:n = true,
+ show-spaces .bool_set:N = \l_@@_showspaces_bool
+ }
+ }
+ {
+ \keys_define:nn { @@ / setup }
+ {
+ interwordspace .choices:nn = { true, on, false, off }
+ { \msg_warning:nnn {tag}{sys-no-interwordspace}{dvi} },
+ interwordspace .default:n = true,
+ show-spaces .bool_set:N = \l_@@_showspaces_bool
+ }
}
}
@@ -50,40 +99,57 @@
{
interwordspace .choices:nn =
{ true, on }
- { \directlua{ltx.@@.func.markspaceon()} },
+ {
+ \bool_gset_true:N \g_@@_active_space_bool
+ \lua_now:e{ltx.@@.func.markspaceon()}
+ },
interwordspace .choices:nn =
{ false, off }
- {\directlua{ltx.@@.func.markspaceoff()} },
+ {
+ \bool_gset_false:N \g_@@_active_space_bool
+ \lua_now:e{ltx.@@.func.markspaceoff()}
+ },
+ interwordspace .default:n = true,
show-spaces .choice:,
show-spaces / true .code:n =
- {\directlua{ltx.@@.trace.showspaces=true}},
+ {\lua_now:e{ltx.@@.trace.showspaces=true}},
show-spaces / false .code:n =
- {\directlua{ltx.@@.trace.showspaces=nil}},
+ {\lua_now:e{ltx.@@.trace.showspaces=nil}},
show-spaces .default:n = true
}
-
- \cs_new_protected:Nn \@@_fakespace:
- {
- \group_begin:
- \setattribute\g_@@_interwordspace_attr{1}
- \setattribute\g_@@_interwordfont_attr
- {
- \directlua{tex.print(\the\catcodetable@latex, font.current())}
- }
- \skip_horizontal:n{\c_zero_skip}
- \group_end:
- }
}
\sys_if_engine_xetex:T
{
\keys_define:nn { @@ / setup }
{
- interwordspace .choices:nn = { true, on } { \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex} },
- interwordspace .choices:nn = { false, off }{ \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex} },
+ interwordspace .choices:nn = { true, on }
+ { \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex} },
+ interwordspace .choices:nn = { false, off }
+ { \msg_warning:nnn {tag}{sys-no-interwordspace}{xetex} },
+ interwordspace .default:n = true,
show-spaces .bool_set:N = \l_@@_showspaces_bool
}
}
-
-%</space>
% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_fakespace:}
+% For luatex we need a command for the fake space as equivalent of the pdftex
+% primitive.
+% \begin{macrocode}
+\sys_if_engine_luatex:T
+ {
+ \cs_new_protected:Nn \@@_fakespace:
+ {
+ \group_begin:
+ \lua_now:e{ltx.@@.func.fakespace()}
+ \skip_horizontal:n{\c_zero_skip}
+ \group_end:
+ }
+ }
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{implementation}
+% \PrintIndex