summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-space.dtx
blob: c2a999cc1bd161439888042bb95f5b52e7534814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
% \iffalse meta-comment
%
%% File: tagpdf-space.dtx
%
% 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
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
% This file is part of the "tagpdf bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    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.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
%    \begin{macrocode}
%<@@=tag>
%<*header>
\ProvidesExplPackage {tagpdf-space-code} {2021-08-27} {0.92}
 {part of tagpdf - code related to real space chars}
%</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
  {
    \sys_if_output_pdf:TF
      {
        \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
          }
      }
  }


\sys_if_engine_luatex:T
  {
    \keys_define:nn { @@ / setup }
      {
        interwordspace .choices:nn =
                                 { true, on }
                                 {
                                   \bool_gset_true:N \g_@@_active_space_bool
                                   \lua_now:e{ltx.@@.func.markspaceon()}
                                 },
        interwordspace .choices:nn =
                                 { false, off }
                                 {
                                  \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 =
                                 {\lua_now:e{ltx.@@.trace.showspaces=true}},
        show-spaces  / false .code:n =
                                 {\lua_now:e{ltx.@@.trace.showspaces=nil}},
        show-spaces .default:n = true
      }
  }

\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 .default:n = true,
        show-spaces .bool_set:N = \l_@@_showspaces_bool
      }
  }
%    \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