summaryrefslogtreecommitdiff
path: root/t-letterspace.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 't-letterspace.mkiv')
-rw-r--r--t-letterspace.mkiv138
1 files changed, 81 insertions, 57 deletions
diff --git a/t-letterspace.mkiv b/t-letterspace.mkiv
index 1a9b862..4811ee5 100644
--- a/t-letterspace.mkiv
+++ b/t-letterspace.mkiv
@@ -17,84 +17,69 @@
\setinterfacevariable {letterspace} {letterspace}
\stopinterface
-\definenamespace [letterspace] [
+\unprotect
+
+\definenamespace [\v!letterspace] [
command=yes,
- comment=Letterspacing module,
- name=letterspace,
- parent=letterspace,
+ comment=Letterspace module,
+ name=\v!letterspace,
+ \s!parent=\v!letterspace,
setup=list,
style=no,
type=module,
version=hg,
]
-\unprotect
-
%D \macros
-%D {setupletterspace}
+%D {letterspace}
%D
-%D Initial setup.
-%D Setting the normal inline letterspacing factor
-%D \type{textfactor} and a separate factor for capital spacing
-%D \type{capfactor}.
-
-\setupletterspace [%
- capfactor=.05,
- capskip=.33em,
- textfactor=.125,
- textskip=.33em,
- shortcommands=false, % “true” | “yes” | “yep” -- defaults to “false”
-]
-
-%D Defining two letterspace settings.
-
-\definecharacterkerning [textspace]
-\definecharacterkerning [capspace]
-
-\setupcharacterkerning [textspace] [factor=\letterspaceparameter{textfactor}]
-\setupcharacterkerning [capspace] [factor=\letterspaceparameter{capfactor}]
-
-\unexpanded\def\letterspace_letterspace#1{%
- \letterspace_do_letterspace{l}{#1}%
+%D \useURL [wschuster] [https://bitbucket.org/wolfs/] [] [Wolfgang Schuster]
+%D \from[wschuster]’s {\em fancybreak} and {\em annotation}
+%D modules served as the primary source for the following code.
+%D You’ll have to thank him if it works and blame me if it doesn’t.
+
+\appendtoks
+ \setuevalue{\currentletterspace}{\doletterspace [\currentletterspace]}%
+ \setuevalue{\e!start\currentletterspace}{\dostartletterspace[\currentletterspace]}%
+ \setuevalue{\e!stop \currentletterspace}{\dostopletterspace}%
+\to \everydefineletterspace
+
+\definecharacterkerning [letterspace:current]
+
+\unexpanded\def\doletterspace[#1]{%
+ \edef\currentletterspace{#1}%
+ \dosingleempty\dodoletterspace%
}
-\unexpanded\def\letterspace_capitalspace#1{%
- \letterspace_do_letterspace{c}{#1}%
+\def\dodoletterspace[#1]{%
+ \iffirstargument
+ \doifassignment{#1}{%
+ \setupletterspace[\currentletterspace][#1]%
+ }%
+ \fi
+ \dododoletterspace%
}
-\let \letterspace\letterspace_letterspace
-\let\capitalspace\letterspace_capitalspace
-
-\def\letterspace_do_letterspace#1#2{%
- \doif{#1}{l}{%
- \let\currentletterspacecmd\letterspace_dodo_letterspace%
- }%
- \doif{#1}{c}{%
- \let\currentletterspacecmd\letterspace_dodo_capitalspace%
+\def\dododoletterspace#1{%
+ \def\currentobject{#1}%
+ \dontleavehmode
+ \setupcharacterkerning[letterspace:current][factor=\letterspaceparameter{spacefactor}]%
+ \def\letterspace_setstuff{%
+ \setcharacterkerning[letterspace:current]%
+ \advance \spaceskip \letterspaceparameter{textskip}%
+ \advance \xspaceskip \letterspaceparameter{textskip}%
}%
\ifhmode\ifnum\lastnodetype=\@@gluenode
- \unskip{\currentletterspacecmd\ }%
+ \unskip{\letterspace_setstuff\ }%
\fi
\fi%
- {\currentletterspacecmd#2}%
+ {\letterspace_setstuff\currentobject}%
\doifnextspace{%
- {\currentletterspacecmd\ }%
+ {\letterspace_setstuff\ }%
\gobblespacetokens%
}%
}
-\def\letterspace_dodo_letterspace{%
- \dontleavehmode \setcharacterkerning[textspace]%
- \advance \spaceskip \letterspaceparameter{textskip}%
- \advance \xspaceskip \letterspaceparameter{textskip}%
-}%
-
-\def\letterspace_dodo_capitalspace{%
- \dontleavehmode \setcharacterkerning[capspace]%
- \advance \spaceskip \letterspaceparameter{capskip}%
- \advance \xspaceskip \letterspaceparameter{capskip}%
-}%
-
%D This is a partial ripoff of a couple of macros from
%D \type{syst-aux.mkiv}.
%D \useURL [flet] [http://www.tug.org/TUGboat/Articles/tb09-3/tb22bechtolsheim.pdf] [] [\type{futurelet}]
@@ -112,12 +97,51 @@
\fi%
}
+%D \macros
+%D {startletterspace,stopletterspace}
+%D
+%D These rely even more shamelessly on \from[wschuster]’s code
+%D from the {\em fancybreak} module.
+
+\unexpanded\def\dostartletterspace[#1]{%
+ \edef\currentletterspace{#1}%
+ \dosingleempty\dodostartletterspace%
+}
+
+\def\dodostartletterspace[#1]{%
+ \iffirstargument
+ \setupletterspace[\currentletterspace][#1]%
+ \fi
+ \dododoletterspace\bgroup%
+}
+
+\let\dostopletterspace\egroup
+
+%D \macros
+%D {setupletterspace}
+%D
+%D Initial setup.
+%D Setting the normal inline letterspacing factor
+%D \type{textfactor} and a separate factor for capital spacing
+%D \type{capfactor}.
+
+
+\setupletterspace [%
+ capfactor=.05,
+ capskip=.33em,
+ textfactor=.125,
+ textskip=.33em,
+ shortcommands=false, % “true” | “yes” | “yep” -- defaults to “false”
+]
+
+\defineletterspace[\v!letterspace]
+
\def\letterspace_truestrings{true,yep,yes}
\def\letterspace_define_shortcommands{%
\doifinset{\letterspaceparameter{shortcommands}}{\letterspace_truestrings}{%
\writestatus{letterspace}{enabling short commands}%
- \global\let\CS\capitalspace%
+ %\global\let\CS\capitalspace%
\global\let\LS\letterspace%
}%
}