summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/typo-pnc.mkxl
blob: 686740c5c28dd7373e478f224aad515cbc991dd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%D \module
%D   [       file=typo-pnc,
%D        version=2017.06.23, % experiment in project
%D          title=\CONTEXT\ Typesetting Macros,
%D       subtitle=Punctuation,
%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 Typesetting Macros / Punctuation}

\unprotect

% In manuals we often have "foo e.g. bar" where we then have to compensate spaces
% with "foo e.g.\ bar" so let's see if we can automate that and at the same time
% inject spaces between the snippets. It gets boring writing this kind of code.

\registerctxluafile{typo-pnc}{autosuffix}

\definesystemattribute[periodkern][public,global]

\installcorenamespace{periodkerning}

\installcommandhandler \??periodkerning {periodkerning} \??periodkerning

\permanent\protected\def\setperiodkerning[#1]%
  {\cdef\currentperiodkerning{#1}%
   \ifx\currentperiodkerning\s!reset
     \resetperiodkerning
   \else
     \typo_periodkerning_set
   \fi}

\def\typo_periodkerning_set
  {\clf_setperiodkerning{\periodkerningparameter\c!factor}}

\permanent\protected\def\resetperiodkerning % fast one
  {\c_attr_periodkern\attributeunsetvalue}

\appendtoks
    \resetperiodkerning
\to \everyresettypesetting

\defineperiodkerning [zerospaceperiods]  [\c!factor=0]
\defineperiodkerning [smallspaceperiods] [\c!factor=.25]
\defineperiodkerning [halfspaceperiods]  [\c!factor=.5]

% If we ever need a command, see typo-krn.mkiv but it doesn't make much sense
% to have it.

\protect