typo-spa.mkxl /size: 2805 b    last modification: 2021-10-28 13:51
1%D \module
2%D   [       file=typo-spa,
3%D        version=2009.03.27, % code moved from cors-spa.mkiv
4%D          title=\CONTEXT\ Typesetting Macros,
5%D       subtitle=Spacing,
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 Typesetting Macros / Spacing}
15
16\unprotect
17
18\registerctxluafile{typo-spa}{autosuffix}
19
20\definesystemattribute[spacing][public]
21
22% experimental spacing
23%
24% test: oeps {\setcharacterspacing[frenchpunctuation]x: xx \bfd x: xx} oeps: test
25%
26% todo: page | text => pagebody or text only
27
28\installcorenamespace{characterspacing}
29
30\installsetuponlycommandhandler \??characterspacing {_p_characterspacing} % private
31
32\setup_p_characterspacing
33  [\c!left=0,
34   \c!right=0,
35   \c!alternative=0]
36
37\permanent\protected\def\definecharacterspacing[#1]%
38  {\clf_definecharacterspacing{#1}}
39
40\permanent\tolerant\protected\def\setupcharacterspacing[#1]#*[#2]#*[#3]% todo: #2 list
41  {\begingroup
42   \setupcurrent_p_characterspacing[#3]%
43   \clf_setupcharacterspacing
44      {#1}%
45      \numexpr#2\relax
46      {%
47        left        \direct_p_characterspacingparameter\c!left\space
48        right       \direct_p_characterspacingparameter\c!right\space
49        alternative \direct_p_characterspacingparameter\c!alternative
50      }%
51   \relax
52   \endgroup}
53
54\permanent\protected\def\setcharacterspacing[#1]% we can store the attribute if we want speed
55  {\clf_setcharacterspacing{#1}}
56
57\permanent\protected\def\resetcharacterspacing % fast one
58  {\c_attr_spacing\attributeunsetvalue}
59
60\appendtoks
61    \resetcharacterspacing
62\to \everyresettypesetting
63
64% \setcharacterspacing[frenchpunctuation]
65% «\type{bla}»\crlf « \type{bla}»\crlf
66% «bla »\crlf « bla»\crlf « bla »\crlf
67% bla: bla\crlf bla : bla
68
69\definecharacterspacing [frenchpunctuation] % name may change / unit is em
70
71\setupcharacterspacing [frenchpunctuation] ["003A] [\c!left =.25,\c!alternative=1] % : % strip preceding space(char)
72\setupcharacterspacing [frenchpunctuation] ["003B] [\c!left =.25,\c!alternative=1] % ; % strip preceding space(char)
73\setupcharacterspacing [frenchpunctuation] ["003F] [\c!left =.25,\c!alternative=1] % ? % strip preceding space(char)
74\setupcharacterspacing [frenchpunctuation] ["0021] [\c!left =.25,\c!alternative=1] % ! % strip preceding space(char)
75\setupcharacterspacing [frenchpunctuation] ["00AB] [\c!right=.25,\c!alternative=1] % guillemotleft/leftguillemot   % strip following space(char)
76\setupcharacterspacing [frenchpunctuation] ["00BB] [\c!left =.25,\c!alternative=1] % guillemotright/rightguillemot % strip preceding space(char)
77
78\protect \endinput
79