summaryrefslogtreecommitdiff
path: root/tex/context/base/spac-chr.mkiv
blob: e2ed1252280c6d7c953307bb8e0511f29df003b5 (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
%D \module
%D   [       file=spac-chr,
%D        version=2011.05.24, % code moved from core-spa.mkiv
%D          title=\CONTEXT\ Spacing Macros,
%D       subtitle=Characters,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Spacing Macros / Characters}

\unprotect

\registerctxluafile{spac-chr}{1.001}

\definesystemattribute[characters][public]

%D The nobreakspace is special as it needs to keep track of the space being
%D flexible. Another option is to use space (glue) nodes and tag them as characters
%D instead. No big deal but takes a moment of coding. So, as a prelude we
%D tag the nobreakspace only. Interesting is that it also fits better in the
%D tagging mechanism.
%D
%D But we need to do some checking as from then on we no longer can compare
%D them in a string. So this needs thinking. Not that we can compare the
%D nobreakspace now anyway.

% \unexpanded\def\specialspacecharacter#1{\begingroup\attribute\charactersattribute#1\ \endgroup}
%
% \unexpanded\edef\nobreakspace            {\specialspacecharacter{"00A0}} % 1 = left
% \unexpanded\edef\ideographicspace        {\specialspacecharacter{"2000}}
% \unexpanded\edef\ideographichalffillspace{\specialspacecharacter{"2001}}
% \unexpanded\edef\twoperemspace           {\specialspacecharacter{"2002}}
% \unexpanded\edef\threeperemspace         {\specialspacecharacter{"2004}}
% \unexpanded\edef\fourperemspace          {\specialspacecharacter{"2005}}
% \unexpanded\edef\sixperemspace           {\specialspacecharacter{"2006}}
% \unexpanded\edef\figurespace             {\specialspacecharacter{"2007}}
% \unexpanded\edef\punctuationspace        {\specialspacecharacter{"2008}}
% \unexpanded\edef\breakablethinspace      {\specialspacecharacter{"2009}}
% \unexpanded\edef\hairspace               {\specialspacecharacter{"200A}}
% \unexpanded\edef\zerowidthspace          {\specialspacecharacter{"200B}}
% \unexpanded\edef\zwnj                    {\specialspacecharacter{"200C}}
% \unexpanded\edef\zwj                     {\specialspacecharacter{"200D}}
% \unexpanded\edef\narrownobreakspace      {\specialspacecharacter{"202F}}

% This does not work as spaceskip is only inserted in the case of raggedleft
% and we need to be able to figure out all of them. Which makes me wonder ...
% can't we just always set spaceskip to some value?

% Making them active is also not an option unless we do that in every
% catcode vector.

%    \nobreakspace            {\begingroup\setalignstateattribute\utfchar{"00A0}\endgroup} % 1 = left

\edef\nobreakspace            {\utfchar{"00A0}}
\edef\ideographicspace        {\utfchar{"2000}}
\edef\ideographichalffillspace{\utfchar{"2001}}
\edef\twoperemspace           {\utfchar{"2002}}
\edef\threeperemspace         {\utfchar{"2004}}
\edef\fourperemspace          {\utfchar{"2005}}
\edef\sixperemspace           {\utfchar{"2006}}
\edef\figurespace             {\utfchar{"2007}}
\edef\punctuationspace        {\utfchar{"2008}}
\edef\breakablethinspace      {\utfchar{"2009}}
\edef\hairspace               {\utfchar{"200A}}
\edef\zerowidthspace          {\utfchar{"200B}}
\edef\zwnj                    {\utfchar{"200C}}
\edef\zwj                     {\utfchar{"200D}}
\edef\narrownobreakspace      {\utfchar{"202F}}

%edef\zerowidthnobreakspace   {\utfchar{"FEFF}}

\unexpanded\def\zerowidthnobreakspace{\penalty\plustenthousand\kern\zeropoint}

% Shortcuts:

% unexpanded as otherwise we need to intercept / cleanup a lot

\unexpanded\def~{\nobreakspace}

% Goodies:

\unexpanded\def\fiveperemspace{\hskip\dimexpr\emwidth/5\relax}

\protect \endinput