typo-spa.mkiv /size: 2830 b    last modification: 2020-07-01 14:35
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}{}
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\unexpanded\def\definecharacterspacing[#1]%
38  {\clf_definecharacterspacing{#1}}
39
40\unexpanded\def\setupcharacterspacing
41  {\dotripleargument\typo_characterspacing_setup}
42
43\def\typo_characterspacing_setup[#1][#2][#3]% todo: #2 list
44  {\begingroup
45   \setupcurrent_p_characterspacing[#3]%
46   \clf_setupcharacterspacing
47      {#1}%
48      \numexpr#2\relax
49      {%
50        left        \direct_p_characterspacingparameter\c!left\space
51        right       \direct_p_characterspacingparameter\c!right\space
52        alternative \direct_p_characterspacingparameter\c!alternative
53      }%
54   \relax
55   \endgroup}
56
57\unexpanded\def\setcharacterspacing[#1]% we can store the attribute if we want speed
58  {\clf_setcharacterspacing{#1}}
59
60\unexpanded\def\resetcharacterspacing % fast one
61  {\c_attr_spacing\attributeunsetvalue}
62
63\appendtoks
64    \resetcharacterspacing
65\to \everyresettypesetting
66
67% \setcharacterspacing[frenchpunctuation]
68% «\type{bla}»\crlf « \type{bla}»\crlf
69% «bla »\crlf « bla»\crlf « bla »\crlf
70% bla: bla\crlf bla : bla
71
72\definecharacterspacing [frenchpunctuation] % name may change / unit is em
73
74\setupcharacterspacing [frenchpunctuation] ["003A] [\c!left =.25,\c!alternative=1] % : % strip preceding space(char)
75\setupcharacterspacing [frenchpunctuation] ["003B] [\c!left =.25,\c!alternative=1] % ; % strip preceding space(char)
76\setupcharacterspacing [frenchpunctuation] ["003F] [\c!left =.25,\c!alternative=1] % ? % strip preceding space(char)
77\setupcharacterspacing [frenchpunctuation] ["0021] [\c!left =.25,\c!alternative=1] % ! % strip preceding space(char)
78\setupcharacterspacing [frenchpunctuation] ["00AB] [\c!right=.25,\c!alternative=1] % guillemotleft/leftguillemot   % strip following space(char)
79\setupcharacterspacing [frenchpunctuation] ["00BB] [\c!left =.25,\c!alternative=1] % guillemotright/rightguillemot % strip preceding space(char)
80
81\protect \endinput
82