summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-space.dtx
blob: edc5e445c70e722b89fd81ef0112a449fd064e64 (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
% \iffalse meta-comment
%
%% File: tagpdf-space.dtx
%
% Copyright (C) 2019 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.
%
% \fi
%
%    \begin{macrocode}
%<@@=tag>
%<*space>
\ProvidesExplPackage {tagpdf-space-code} {2021/02/23} {0.80}
 {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

\sys_if_engine_pdftex:T
  {
    \pdfglyphtounicode{space}{0020}
    \keys_define:nn { @@ / setup }
      {
        interwordspace .choices:nn = { true, on }  { \pdfinterwordspaceon },
        interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
        show-spaces .bool_set:N = \l_@@_showspaces_bool
      }
  }


\sys_if_engine_luatex:T
  {
    \keys_define:nn { @@ / setup }
      {
        interwordspace .choices:nn =
                                 { true, on }
                                 { \directlua{ltx.@@.func.markspaceon()} },
        interwordspace .choices:nn =
                                 { false, off }
                                 {\directlua{ltx.@@.func.markspaceoff()} },
        show-spaces      .choice:,
        show-spaces  / true  .code:n =
                                 {\directlua{ltx.@@.trace.showspaces=true}},
        show-spaces  / false .code:n =
                                 {\directlua{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}  },
        show-spaces .bool_set:N = \l_@@_showspaces_bool
      }
  }

%</space>
%    \end{macrocode}