diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-11-06 20:46:53 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-11-06 20:46:53 +0100 |
commit | d8b32263856c2f951bedec7f89adad3a412b7499 (patch) | |
tree | c95527f9a0d47bd44e498ae6b1c632fd956b6f07 /tex/context/base/mkiv/spac-chr.mkxl | |
parent | c8e4762108bce6354ba48c34fe0b4c6f2ff6dcee (diff) | |
download | context-d8b32263856c2f951bedec7f89adad3a412b7499.tar.gz |
2020-11-06 20:26:00
Diffstat (limited to 'tex/context/base/mkiv/spac-chr.mkxl')
-rw-r--r-- | tex/context/base/mkiv/spac-chr.mkxl | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/spac-chr.mkxl b/tex/context/base/mkiv/spac-chr.mkxl new file mode 100644 index 000000000..8d7bba42e --- /dev/null +++ b/tex/context/base/mkiv/spac-chr.mkxl @@ -0,0 +1,103 @@ +%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}{optimize} + +\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\c_attr_characters#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. + +\pushoverloadmode + +%immutable\edef\nobreakspace {\begingroup\setalignstateattribute\normalUchar"00A0\endgroup} % 1 = left +\immutable\edef\nobreakspace {\normalUchar"00A0} % space +\immutable\edef\softhyphen {\normalUchar"00AD} % softhyohen +\immutable\edef\enquad {\normalUchar"2000} % quad/2 +\immutable\edef\emquad {\normalUchar"2001} % quad +\immutable\edef\twoperemspace {\normalUchar"2002} % quad/2 +% % "2003 % quad == \quad == \hskip\emwidth +\immutable\edef\threeperemspace {\normalUchar"2004} % quad/3 +\immutable\edef\fourperemspace {\normalUchar"2005} % quad/4 +%immutable\edef\fiveperemspace {\normalUchar"001E} % quad/5 (bonus) +\immutable\edef\sixperemspace {\normalUchar"2006} % quad/6 +\immutable\edef\figurespace {\normalUchar"2007} % width of zero +\immutable\edef\punctuationspace {\normalUchar"2008} % width of period +\immutable\edef\breakablethinspace {\normalUchar"2009} % quad/8 +\immutable\edef\hairspace {\normalUchar"200A} % quad/8 +\immutable\edef\zerowidthspace {\normalUchar"200B} % 0 +\immutable\edef\zerowidthnonjoiner {\normalUchar"200C} % 0 +\immutable\edef\zerowidthjoiner {\normalUchar"200D} % 0 +\immutable\edef\narrownobreakspace {\normalUchar"202F} % quad/8 +%immutable\edef\mediummathspace {\normalUchar"205F} % space/8 (math) +%immutable\edef\zerowidthnobreakspace{\normalUchar"FEFF} +%immutable\edef\fiveperemspace {\normalUchar"001E} + +\immutable\protected\def\zerowidthnobreakspace{\penalty\plustenthousand\kern\zeropoint} +\immutable\protected\def\fiveperemspace {\hskip\dimexpr\emwidth/5\relax} + +\aliased\let\ideographicspace \enquad +\aliased\let\ideographichalffillspace \emquad + +\immutable\let\zwnj \zerowidthnonjoiner +\immutable\let\zwj \zerowidthjoiner +\immutable\let\nbsp \nobreakspace + +\popoverloadmode + +\immutable\chardef\optionalspace"1F % will be space unless before punctuation + +% Shortcuts: + +% unexpanded as otherwise we need to intercept / cleanup a lot + +\protected\def~{\nobreakspace} + +\protect \endinput + |