spac-chr.mkxl /size: 3396 b    last modification: 2024-01-16 09:03
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}{autosuffix}
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\pushoverloadmode
33
34%immutable\edef\nobreakspace         {\begingroup\setalignstateattribute\tocharacter"00A0\endgroup} % 1 = left
35\immutable\edef\nobreakspace         {\tocharacter"00A0} % space
36\immutable\edef\softhyphen           {\tocharacter"00AD} % softhyohen
37\immutable\edef\enquad               {\tocharacter"2000} % quad/2
38\immutable\edef\emquad               {\tocharacter"2001} % quad
39\immutable\edef\twoperemspace        {\tocharacter"2002} % quad/2
40%                                    %            "2003  % quad == \quad == \hskip\emwidth
41\immutable\edef\threeperemspace      {\tocharacter"2004} % quad/3
42\immutable\edef\fourperemspace       {\tocharacter"2005} % quad/4
43%immutable\edef\fiveperemspace       {\tocharacter"001E} % quad/5 (bonus)
44\immutable\edef\sixperemspace        {\tocharacter"2006} % quad/6
45\immutable\edef\figurespace          {\tocharacter"2007} % width of zero
46\immutable\edef\punctuationspace     {\tocharacter"2008} % width of period
47\immutable\edef\breakablethinspace   {\tocharacter"2009} % quad/8
48\immutable\edef\hairspace            {\tocharacter"200A} % quad/8
49\immutable\edef\zerowidthspace       {\tocharacter"200B} % 0
50\immutable\edef\zerowidthnonjoiner   {\tocharacter"200C} % 0
51\immutable\edef\zerowidthjoiner      {\tocharacter"200D} % 0
52\immutable\edef\narrownobreakspace   {\tocharacter"202F} % quad/8
53%immutable\edef\mediummathspace      {\tocharacter"205F} % space/8 (math)
54%immutable\edef\zerowidthnobreakspace{\tocharacter"FEFF}
55%immutable\edef\fiveperemspace       {\tocharacter"001E}
56
57\immutable\protected\def\zerowidthnobreakspace{\penalty\plustenthousand\kern\zeropoint}
58\immutable\protected\def\fiveperemspace       {\hskip\dimexpr\emwidth/5\relax}
59
60\aliased\let\ideographicspace         \enquad
61\aliased\let\ideographichalffillspace \emquad
62
63\immutable\let\zwnj            \zerowidthnonjoiner
64\immutable\let\zwj             \zerowidthjoiner
65\immutable\let\nbsp            \nobreakspace
66
67\popoverloadmode
68
69\immutable\chardef\optionalspace    "1F % will be space unless before punctuation
70\immutable\chardef\autoinsertedspace"1E % a more clever \autoinsertspace
71
72% Shortcuts:
73
74% unexpanded as otherwise we need to intercept / cleanup a lot
75
76\pushoverloadmode
77
78\protected\def~{\nobreakspace}
79
80\popoverloadmode
81
82\protect \endinput
83
84