summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-run.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/font-run.mkiv')
-rw-r--r--tex/context/base/mkiv/font-run.mkiv369
1 files changed, 369 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/font-run.mkiv b/tex/context/base/mkiv/font-run.mkiv
new file mode 100644
index 000000000..1b8843b94
--- /dev/null
+++ b/tex/context/base/mkiv/font-run.mkiv
@@ -0,0 +1,369 @@
+%D \module
+%D [ file=font-run,
+%D version=1998.09.11, % (second)
+%D version=2001.02.20, % (third)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Runtime Macros,
+%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.
+
+%D [This code is hooked into the core macros and saves some format
+%D space. It needs a cleanup.]
+
+\unprotect
+
+\gdef\@@onlyenglish#1%
+ {\blank{\tttf \type {#1} is only available in the english interface}\blank}
+
+\gdef\dosetshowfonttitle#1%
+ {\tabskip\zeropoint
+ \parindent\zeropoint
+ \setlocalhsize
+ \doifelsenothing{#1}
+ {\def\title{[\the\bodyfontsize]}}
+ {\switchtobodyfont[#1]\def\title{[#1]}}
+ \doifsomething\fontclass
+ {\doifnot{[\fontclass]}\title
+ {\edef\title{[\fontclass]\space\title}}}}
+
+\unexpanded\gdef\showbodyfont
+ {\dosingleempty\doshowbodyfont}
+
+\gdef\doshowbodyfont[#1]%
+ {\ifinsidefloat\else\startbaselinecorrection\fi
+ \vbox
+ {\dosetshowfonttitle{#1}%
+ \def\bigstrut##1##2%
+ {\hbox{\vrule
+ \s!height##1\strutht
+ \s!depth ##2\strutdp
+ \s!width \zeropoint}}
+ \def\next##1##2##3%
+ {&&##1&&##2\tf##3&&##2\sc##3%
+ &&##2\sl##3&&##2\it##3&&##2\bf##3&&##2\bs##3&&##2\bi##3%
+ &&##2\tfx##3&&##2\tfxx##3%
+ &&##2\tfa##3&&##2\tfb##3&&##2\tfc##3&&##2\tfd##3&\cr}%
+ \halign to \localhsize
+ {\bigstrut{1.5}{2}##&\vrule##
+ \tabskip\zeropoint \s!plus 1\s!fill
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&##\vrule
+ \tabskip=\zeropoint\cr
+ \noalign{\hrule}
+ &\multispan{29}{\vrule\hfil\tttf\strut\title\hfil
+ \llap{\string\mr\hbox to 1em{\hss:\hss}$\mr \languageparameter\c!text$\quad}\vrule}\cr
+ \noalign{\hrule}\next{}{\tt\string}{}
+ \noalign{\hrule}\next{\tt\string\rm}\rm{\languageparameter\c!text}
+ \noalign{\hrule}\next{\tt\string\ss}\ss{\languageparameter\c!text}
+ \noalign{\hrule}\next{\tt\string\tt}\tt{\languageparameter\c!text}
+ \noalign{\hrule}}}
+ \ifinsidefloat\else\stopbaselinecorrection\fi}
+
+\unexpanded\gdef\showbodyfontenvironment
+ {\dosingleempty\doshowbodyfontenvironment}
+
+\gdef\doshowbodyfontenvironment[#1]%
+ {\ifinsidefloat\else\startbaselinecorrection\fi
+ \vbox
+ {\dosetshowfonttitle{#1}%
+ \def\next##1%
+ {&&\bodyfontsizevariable{##1}\s!text
+ &&\bodyfontsizevariable{##1}\s!script
+ &&\bodyfontsizevariable{##1}\s!scriptscript
+ &&\bodyfontsizevariable{##1}\s!x
+ &&\bodyfontsizevariable{##1}\s!xx
+ &&\bodyfontsizevariable{##1}\v!small
+ &&\bodyfontsizevariable{##1}\v!big
+ &&\bodyfontsizevariable{##1}\c!interlinespace
+ &\cr
+ \noalign{\hrule}}
+ \halign to \localhsize
+ {##&\vrule##\strut
+ \tabskip=\zeropoint \s!plus 1\s!fill
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##&\hfil##\hfil&\vrule##
+ &\hfil##\hfil&\vrule##&\hfil##\hfil&##\vrule
+ \tabskip\zeropoint\cr
+ \noalign{\hrule}
+ &\multispan{17}{\vrule\hfil\tttf\strut\title\hfil}\vrule\cr
+ \noalign{\hrule}
+ &&\tttf\tx\s!text&&\tttf\tx\s!script&&\tttf\tx\s!scriptscript
+ &&\tttf\tx\s!x&&\tttf\tx\s!xx&&\tttf\tx\v!small&&\tttf\tx\v!big
+ &&\tttf\tx\c!interlinespace&\cr
+ \noalign{\hrule}%
+ \processbodyfontenvironmentlist\next}}
+ \ifinsidefloat\else\stopbaselinecorrection\fi}
+
+\unexpanded\gdef\showfont
+ {\dodoubleempty\doshowfont}
+
+\gdef\doshowfont[#1][#2]%
+ {\bgroup
+ \iffirstargument
+ \definefont[\s!dummy][#1]\dummy
+ \fi
+ \doifelsenothing{#2}
+ {\dodoshowfont{#1}{0}}
+ {\doifelse{#2}\v!all
+ {\dostepwiserecurse{0}{255}{1}
+ {\donefalse
+ \let\charplane\recurselevel
+ \dostepwiserecurse{0}{255}{1}
+ {\iffontchar\font\numexpr\charplane*256+\recurselevel\relax
+ \donetrue
+ \exitloop
+ \fi}%
+ \ifdone
+ \dodoshowfont{#1}\charplane
+ \fi}}
+ {\processcommalist[#2]{\dodoshowfont{#1}}}}%
+ \egroup}
+
+\gdef\dodoshowfont#1#2%
+ {\bgroup
+ \edef\charplane{\number#2}%
+ \iffirstargument
+% \definefont[\s!dummy][#1]\dummy
+ \else\ifdim2.5em>.05\hsize \tx
+ \ifdim2.5em>.05\hsize \txx
+ \fi\fi\fi
+ \ifinsidefloat\else\startbaselinecorrection\fi
+ \vbox\bgroup
+ \forgetall
+ \startoverlay % easier in cld
+ {\vbox
+ {\tf \setstrut \dummy
+ \offinterlineskip
+ \dostepwiserecurse{0}{15}{1}
+ {\let\row\recurselevel
+ \hbox
+ {\red
+ \dostepwiserecurse{0}{15}{1}
+ {\let\col\recurselevel
+ \@EA\scratchcounter\string"\hexnumber\row\hexnumber\col\relax
+ \edef\rowcol{\the\scratchcounter}%
+ \iffontchar\font\scratchcounter
+ \setbox\scratchbox\ruledhbox{\black\char\numexpr\charplane*256+\scratchcounter\relax}%
+ \ifdim\wd\scratchbox>\zeropoint
+ \donetrue \else \donefalse
+ \fi
+ \else
+ \setbox\scratchbox\hbox{\gray\vrule\s!width1ex\s!height.5ex\s!depth.5ex}%
+ \fi
+ \startoverlay
+ {\tf\vbox to 2.5em
+ {\vss
+ \hbox to 2.5em
+ {\dummy\ifdim\interwordspace=\zeropoint
+ \setbox\scratchbox\hbox
+ {\raise.5\dp\scratchbox\hbox
+ {\lower.5\ht\scratchbox\copy\scratchbox}}%
+ \ht\scratchbox\zeropoint
+ \dp\scratchbox\zeropoint
+ \else
+ \ht\scratchbox\strutht
+ \dp\scratchbox\strutdp
+ \strut
+ \fi
+ \hss\copy\scratchbox\hss}
+ \vss}}
+ {\tf\vbox to 2.3em
+ {\ifdone
+ \hsize2.4em
+ \blue
+ \tinyfont
+ \hfill\number\rowcol
+ \vfill
+ \octnumber\rowcol\hfill\lchexnumbers\rowcol
+ \par
+ \fi}}
+ \stopoverlay}}}
+ \par}}
+ {\tf\basegrid[\c!nx=16,\c!ny=16,\c!dx=2.5,\c!dy=2.5,\c!unit=em]}
+ \stopoverlay
+ \nointerlineskip
+ \vskip2pt
+ % the \noexpand before \blank is needed for non etex
+ \edef\ascii{name: {\noexpand\black\fontname\font}}
+ \def\do##1##2{\ifx##1\undefined\else\ifx##1\empty\else##2\fi\fi}%
+ \edef\theshowfontspecs{name: {\noexpand\black\fontname\font}\quad plane: \charplane\enspace"\hexnumber\charplane}%
+ \tf % also sets em
+ \hbox to 40em{\blue\hfill\tinyfont\setstrut\strut\theshowfontspecs}
+ \egroup
+ \ifinsidefloat\else\stopbaselinecorrection\fi
+ \egroup}
+
+% \showfontstyle[modern][rm][tf][all] % #2, #3 and #4 can be 'all'
+
+\unexpanded\gdef\showfontstyle {\dodoubleempty \dodoshowfontstyle}
+\unexpanded\gdef\redoshowfontstyle {\dotripleempty \dododoshowfontstyle}
+\unexpanded\gdef\redodoshowfontstyle{\doquadrupleempty\dodododoshowfontstyle}
+
+% no lists any more, so no 'all' any longer
+
+\gdef\dodoshowfontstyle[#1][#2]%
+ {\doifelsenothing{#2}
+ {\redoshowfontstyle[#1][\s!rm,\s!ss,\s!tt,\s!mm]}
+ {\redoshowfontstyle[#1][#2]}}
+
+\gdef\dododoshowfontstyle[#1][#2][#3]%
+ {\doifelsenothing{#3}
+ {\redodoshowfontstyle[#1][#2][\s!tf,\s!bf,\s!it,\s!sl,\s!bs,\s!bi]}
+ {\redodoshowfontstyle[#1][#2][#3]}}
+
+\gdef\dodododoshowfontstyle[#1][#2][#3][#4]%
+ {\doshowfontstyleindeed[#1][#2][#3][#4]}
+
+% so far
+
+\gdef\doshowfontstyleindeed[#1][#2][#3][#4]%
+ {\bgroup
+ \raggedright
+ \switchtobodyfont[#1]
+ \def\dododocommand##1%
+ {\dostepwiserecurse{0}{255}{1}
+ {\scratchcounter\numexpr##1*256+\recurselevel\relax
+ \iffontchar\font\scratchcounter\relax
+ \char\scratchcounter
+ \space
+ \fi}}%
+ \def\dodocommand##1##2%
+ {\starttextrule{\tttf #1 ##1 ##2}
+ \nobreak\getvalue{##2}%
+ \doifelsenothing{#4}
+ {\dododocommand{0}}
+ {\doifelse{#4}\v!all
+ {\dostepwiserecurse{0}{255}{1}{\expanded{\dododocommand{\recurselevel}}}}
+ {\processcommalist[#4]{\dododocommand}}}%
+ \par \nobreak
+ \stoptextrule}
+ \def\docommand##1%
+ {\getvalue{##1}%
+ \processcommacommand[#3]{\dodocommand{##1}}}
+ \processcommalist[#2]\docommand
+ \egroup}
+
+\unexpanded\gdef\showligature#1%
+ {\hbox{\type{#1}\enspace\red\ruledhbox{\black#1}}}
+
+\unexpanded\gdef\showligatures[#1]%
+ {\ifx\starttabulate\undefined
+ \@@onlyenglish\showligatures
+ \else
+ \bgroup
+ \def\show##1{\hbox{\red\ruledhbox{\black##1}}}%
+ \definefont[\s!dummy][#1]\dummy
+ \starttabulate[|*{9}{c|}]
+ \NC\type{ff}\NC\type{fi}\NC\type{fl}\NC\type{ffi}\NC\type{ffl}\NC
+ \type{``}\NC\type{''}\NC\type{--}\NC\type{---}\NC\NR
+ \NC\show{ff}\NC\show{fi}\NC\show{fl}\NC\show{ffi}\NC\show{ffl}\NC
+ \show{``}\NC\show{''}\NC\show{--}\NC\show{---}\NC\NR
+ \stoptabulate
+ \egroup
+ \fi}
+
+\unexpanded\gdef\showfontstrip
+ {\dosingleempty\doshowfontstrip}
+
+\gdef\doshowfontstrip[#1]%
+ {\ifx\starttabulate\undefined
+ \@@onlyenglish\showfontstrip
+ \else
+ \bgroup
+ \def\dofontstripa##1##2%
+ {\tttf\string##1}
+ \def\dofontstripb##1##2%
+ {\ruledhbox{\switchtobodyfont[#1]##1{##2}}}
+ \def\dofontstripc##1##2%
+ {\setbox\scratchbox\hbox{\switchtobodyfont[#1]##1{##2}}%
+ \tt\tfx\the\ht\scratchbox}%
+ \def\dofontstripd##1##2%
+ {\setbox\scratchbox\hbox{\switchtobodyfont[#1]##1{##2}}%
+ \tt\tfx\the\wd\scratchbox}%
+ \def\fontstrip##1##2##3%
+ {\NC##2\rm{##3}\NC
+ ##2\ss{##3}\NC
+ ##2\tt{##3}\NC
+ ##2\mathematics{##3}\NC
+ \tttf##1\NR}
+ \starttabulate[|c|c|c|c|c|]
+ \fontstrip\relax\dofontstripa\empty
+ \TB
+ \fontstrip\relax\dofontstripb{xxxx}
+ \fontstrip\relax\dofontstripb{12345}
+ \fontstrip\relax\dofontstripb{(Agw)}
+ \TB
+ \fontstrip{(x height)}\dofontstripc{x}
+ \fontstrip{(m width)}\dofontstripd{m}
+ \stoptabulate
+ \egroup
+ \fi}
+
+\ifdefined\databox \else \newbox\databox \fi
+
+\unexpanded\gdef\testminimalbaseline#1% to be used in a tabulate
+ {\setbox\databox\ruledhbox{#1}%
+ \scratchdimen\ht\databox
+ \advance\scratchdimen\dp\databox
+ \scratchtoks{#1}%
+ \expanded
+ {\NC \ruledhbox{\the\scratchtoks}
+ \noexpand \NC ->
+ \noexpand \NC \the\scratchdimen
+ \noexpand \NC =
+ \noexpand \NC \the\ht\databox
+ \noexpand \NC +
+ \noexpand \NC \the\dp\databox
+ \noexpand \NC \ifdim\scratchdimen<\baselineskip <
+ \else\ifdim\scratchdimen=\baselineskip =
+ \else > \fi\fi
+ \noexpand \NC \the\baselineskip
+ \noexpand \NC (\ifdim\scratchdimen>\baselineskip not \fi ok)
+ \noexpand \NC \noexpand \NR }}
+
+\unexpanded\gdef\showminimalbaseline
+ {\ifx\starttabulate\undefined
+ \@@onlyenglish\showminimalbaseline
+ \else
+ \starttabulate[||T|T|T|T|T|T|T|T|T|]
+ \testminimalbaseline{\hbox to 1em{\hss\showstruts\strut\hss}}%
+ \testminimalbaseline{(/)}%
+ \testminimalbaseline{$\frac{1}{2}x\normalsuperscript2\normalsubscript3$}
+ \stoptabulate
+ \fi}
+
+\unexpanded\gdef\showkerning#1%
+ {\bgroup
+ \let\MPfshowcommand\ruledhbox
+ \setMPtext\s!dummy{#1}%
+ \startMPcode draw textext(\MPstring\s!dummy);\stopMPcode
+ \egroup}
+
+\unexpanded\gdef\showcharratio
+ {\dowithnextboxcontent
+ {\switchtobodyfont[10pt]}%
+ {(\withoutpt\the\nextboxht,\withoutpt\the\nextboxdp)}%
+ \hbox}
+
+\unexpanded\gdef\showfontparameters
+ {\starttabulate[|tl|l|]
+ \NC slantperpoint \NC \the\fontslantperpoint \font \NC\NR
+ \NC interwordspace \NC \the\fontinterwordspace \font \NC\NR
+ \NC interwordstretch\NC \the\fontinterwordstretch\font \NC\NR
+ \NC interwordshrink \NC \the\fontinterwordshrink \font \NC\NR
+ \NC exheight \NC \the\fontexheight \font \NC\NR
+ \NC emwidth \NC \the\fontemwidth \font \NC\NR
+ \NC extraspace \NC \the\fontextraspace \font \NC\NR
+ \stoptabulate}
+
+\protect \endinput