spac-chr.mkiv /size: 4552 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=spac-chr,
3
%D version=2011.05.24, % code moved from core-spa.mkiv
4
%D title=\CONTEXT\ Spacing Macros,
5
%D subtitle=Characters,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}{
ConTeXt
Spacing
Macros
/
Characters
}
15 16
\unprotect
17 18
\registerctxluafile
{
spac
-
chr
}{
optimize
}
19 20
\definesystemattribute
[
characters
][
public
]
21 22
%D The nobreakspace is special as it needs to keep track of the space being
23
%D flexible. Another option is to use space (glue) nodes and tag them as characters
24
%D instead. No big deal but takes a moment of coding. So, as a prelude we
25
%D tag the nobreakspace only. Interesting is that it also fits better in the
26
%D tagging mechanism.
27
%D
28
%D But we need to do some checking as from then on we no longer can compare
29
%D them in a string. So this needs thinking. Not that we can compare the
30
%D nobreakspace now anyway.
31 32
% \unexpanded\def\specialspacecharacter#1{\begingroup\c_attr_characters#1\ \endgroup}
33
%
34
% \unexpanded\edef\nobreakspace {\specialspacecharacter{"00A0}} % 1 = left
35
% \unexpanded\edef\ideographicspace {\specialspacecharacter{"2000}}
36
% \unexpanded\edef\ideographichalffillspace{\specialspacecharacter{"2001}}
37
% \unexpanded\edef\twoperemspace {\specialspacecharacter{"2002}}
38
% \unexpanded\edef\threeperemspace {\specialspacecharacter{"2004}}
39
% \unexpanded\edef\fourperemspace {\specialspacecharacter{"2005}}
40
% \unexpanded\edef\sixperemspace {\specialspacecharacter{"2006}}
41
% \unexpanded\edef\figurespace {\specialspacecharacter{"2007}}
42
% \unexpanded\edef\punctuationspace {\specialspacecharacter{"2008}}
43
% \unexpanded\edef\breakablethinspace {\specialspacecharacter{"2009}}
44
% \unexpanded\edef\hairspace {\specialspacecharacter{"200A}}
45
% \unexpanded\edef\zerowidthspace {\specialspacecharacter{"200B}}
46
% \unexpanded\edef\zwnj {\specialspacecharacter{"200C}}
47
% \unexpanded\edef\zwj {\specialspacecharacter{"200D}}
48
% \unexpanded\edef\narrownobreakspace {\specialspacecharacter{"202F}}
49 50
% This does not work as spaceskip is only inserted in the case of raggedleft
51
% and we need to be able to figure out all of them. Which makes me wonder ...
52
% can't we just always set spaceskip to some value?
53 54
% Making them active is also not an option unless we do that in every
55
% catcode vector.
56 57
% \nobreakspace {\begingroup\setalignstateattribute\normalUchar"00A0\endgroup} % 1 = left
58
\edef
\nobreakspace
{
\normalUchar
"
0
0
A
0
}
% space
59
\edef
\softhyphen
{
\normalUchar
"
0
0
AD
}
% softhyohen
60
\edef
\enquad
{
\normalUchar
"
2
0
0
0
}
% quad/2
61
\edef
\emquad
{
\normalUchar
"
2
0
0
1
}
% quad
62 63
\let
\ideographicspace
\enquad
64
\let
\ideographichalffillspace
\emquad
65 66
\edef
\twoperemspace
{
\normalUchar
"
2
0
0
2
}
% quad/2
67
% % "2003 % quad == \quad == \hskip\emwidth
68
\edef
\threeperemspace
{
\normalUchar
"
2
0
0
4
}
% quad/3
69
\edef
\fourperemspace
{
\normalUchar
"
2
0
0
5
}
% quad/4
70
%edef\fiveperemspace {\normalUchar"001E} % quad/5 (bonus)
71
\edef
\sixperemspace
{
\normalUchar
"
2
0
0
6
}
% quad/6
72
\edef
\figurespace
{
\normalUchar
"
2
0
0
7
}
% width of zero
73
\edef
\punctuationspace
{
\normalUchar
"
2
0
0
8
}
% width of period
74
\edef
\breakablethinspace
{
\normalUchar
"
2
0
0
9
}
% quad/8
75
\edef
\hairspace
{
\normalUchar
"
2
0
0
A
}
% quad/8
76
\edef
\zerowidthspace
{
\normalUchar
"
2
0
0
B
}
% 0
77
\edef
\zerowidthnonjoiner
{
\normalUchar
"
2
0
0
C
}
% 0
78
\edef
\zerowidthjoiner
{
\normalUchar
"
2
0
0
D
}
% 0
79
\edef
\narrownobreakspace
{
\normalUchar
"
2
0
2
F
}
% quad/8
80
%edef\mediummathspace {\normalUchar"205F} % space/8 (math)
81
%edef\zerowidthnobreakspace {\normalUchar"FEFF}
82
%edef\fiveperemspace {\normalUchar"001E}
83 84
\udef
\zerowidthnobreakspace
{
\penalty
\plustenthousand
\kern
\zeropoint
}
85
\udef
\fiveperemspace
{
\hskip\dimexpr
\emwidth
/
5
\relax
}
86 87
\let
\zwnj
\zerowidthnonjoiner
88
\let
\zwj
\zerowidthjoiner
89
\let
\nbsp
\nobreakspace
90 91
\chardef
\optionalspace
"
1
F
% will be space unless before punctuation
92 93
% Shortcuts:
94 95
% unexpanded as otherwise we need to intercept / cleanup a lot
96 97
\unexpanded
\def
~
{
\nobreakspace
}
98 99
\protect
\endinput
100 101