summaryrefslogtreecommitdiff
path: root/tex/context/third
diff options
context:
space:
mode:
authorPhilipp Gesang <megas.kapaneus@gmail.com>2011-03-17 19:50:13 +0100
committerPhilipp Gesang <megas.kapaneus@gmail.com>2011-03-17 19:50:13 +0100
commit3ca8a706788766ede25f694caed679a812270eca (patch)
tree1f071f5d1a2b1157d0d644d6b0ad5e5bff5c3ea9 /tex/context/third
parentb5920b2493c964f0aef2ebac0b37a42122b10207 (diff)
downloadt-letterspace-3ca8a706788766ede25f694caed679a812270eca.tar.gz
moved files to subdirs; example images; finished man
Diffstat (limited to 'tex/context/third')
-rw-r--r--tex/context/third/letterspace/t-letterspace.mkiv167
1 files changed, 167 insertions, 0 deletions
diff --git a/tex/context/third/letterspace/t-letterspace.mkiv b/tex/context/third/letterspace/t-letterspace.mkiv
new file mode 100644
index 0000000..ce3f026
--- /dev/null
+++ b/tex/context/third/letterspace/t-letterspace.mkiv
@@ -0,0 +1,167 @@
+%D \module [
+%D file=t-letterspace,
+%D version=2011-03-15T12:59:48+0100 or later,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Letterspacing commands,
+%D author=Philipp Gesang,
+%D date=\currentdate,
+%D copyright=Philipp Gesang,
+%D license=2-clause BSD,
+%D ]
+
+%C Read the license conditions in the file \type{COPYING}.
+
+
+
+\writestatus{loading}{ConTeXt User Module / Letterspace}
+
+\startmodule [letterspace]
+
+\startinterface all
+ \setinterfacevariable {letterspace} {letterspace}
+ \setinterfacevariable {factor} {factor}
+ \setinterfacevariable {spaceskip} {spaceskip}
+ \setinterfacevariable {suppresskern}{suppresskern}
+\stopinterface
+
+\unprotect
+
+\definenamespace [\v!letterspace] [
+ command=yes,
+ comment=Letterspace module,
+ name=\v!letterspace,
+ \s!parent=\v!letterspace,
+ setup=list,
+ style=no,
+ type=module,
+ version=hg-rev:3+,
+]
+
+%D \macros
+%D {letterspace}
+%D
+%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%
+}
+
+\def\dodoletterspace[#1]{%
+ \iffirstargument
+ \doifassignment{#1}{%
+ \setupletterspace[\currentletterspace][#1]%
+ }%
+ \fi
+ \dododoletterspace%
+}
+
+\definefontfeature [letterspace:kerning] [kern=yes]
+\def\letterspace_truevalues{true,yep,yes}
+
+\def\dododoletterspace#1{%
+ \def\currentobject{#1}%
+ \dontleavehmode
+ \setupcharacterkerning[letterspace:current][factor=\letterspaceparameter{factor}]%
+ \def\letterspace_setstuff{%
+ \setcharacterkerning[letterspace:current]%
+ \advance \spaceskip \letterspaceparameter{spaceskip}%
+ \advance \xspaceskip \letterspaceparameter{spaceskip}%
+ \doifinset{\letterspaceparameter{suppresskern}}{\letterspace_truevalues}{%
+ \subtractfontfeaturefromfont{letterspace:kerning}%
+ }%
+ }%
+ \ifhmode\ifnum\lastnodetype=\@@gluenode
+ \unskip{\letterspace_setstuff\ }%
+ \fi
+ \fi%
+ {\letterspace_setstuff\currentobject}%
+ \doifnextspace{%
+ {\letterspace_setstuff\ }%
+ \gobblespacetokens%
+ }%
+}
+
+%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}]
+%D Very helpful for further understanding of what’s exactly going
+%D on: Stephan von Bechtolsheim’s tutorial on \from[flet].
+%D
+%D In short: the trick is checking whether the token following
+%D the command is a space, that is: whether it expands to
+%D \type{\blankspace}. If the test succeeds, a space will be
+%D added that has the correct parameters and all space tokens
+%D following the command will be gobbled. Otherwise -- the next
+%D token being anything else -- \type{\letterspace} will proceed
+%D without changing anything.
+
+\def\doifnextspace#1{%
+ \def\!!string{#1}%
+ \futurelet\nexttoken\inspectnexttoken%
+}
+
+\def\inspectnexttoken{%
+ \ifx\nexttoken\blankspace
+ \@EA\!!string
+ \fi%
+}
+
+%D \macros
+%D {startletterspace,stopletterspace}
+%D
+%D These rely even more shamelessly on \from[wschuster]’s code
+%D from the {\em fancybreak} module.
+%D
+%D The \type{\[start|stop]letterspace} environment is provided
+%D for sake of completeness.
+
+\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 The factor by which the {\em letter space} (i.e. space between
+%D glyphs) will be increased is specified via the
+%D \type{factor} key.
+%D Additionally, it is wise with respect to legibility to enlarge
+%D the {\em interword space} as well. That is what the
+%D \type{spaceskip} key is for. The {\em spaceskip} should be an
+%D ordinary dimension.
+
+\setupletterspace [
+ \v!factor=.125,
+ \v!spaceskip=.5em,
+ \v!suppresskern=false,
+]
+
+\defineletterspace[\v!letterspace]
+
+\protect \stopmodule \endinput
+
+% vim:ft=context:sw=2:ts=2
+