summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-space-code.sty
blob: c47da0e73d4f3ebd7874cbd5ce907248ae5b5ee5 (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
\ProvidesExplPackage {tagpdf-space-code} {2019/07/02} {0.61}
 {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 { uftag / setup }
  {
    interwordspace .choices:nn = { true, on }  { \pdfinterwordspaceon },
    interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
    show-spaces .bool_set:N = \l__uftag_showspaces_bool
  }

}


\sys_if_engine_luatex:T
{
 \keys_define:nn { uftag / setup }
  {
    interwordspace .choices:nn = { true, on }
                                 { \directlua{uftag.func.markspaceon()} },

    interwordspace .choices:nn = { false, off }
                                 {\directlua{uftag.func.markspaceoff()} },
    show-spaces      .choice:,
    show-spaces  / true  .code:n = {\directlua{uftag.trace.showspaces=true}},
    show-spaces  / false .code:n = {\directlua{uftag.trace.showspaces=nil}},
    show-spaces .default:n = true
  }
 \cs_new_protected:Nn \__uftag_fakespace:
  {
   \group_begin:
    \setattribute\g__uftag_interwordspace_attr{1}
    \setattribute\g__uftag_interwordfont_attr{\directlua{tex.print(\the\catcodetable@latex, font.current())}}
    \skip_horizontal:n{\c_zero_skip}
   \group_end:
  }
}



\endinput