summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/typo-txt.mkvi
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/typo-txt.mkvi')
-rw-r--r--Master/texmf-dist/tex/context/base/typo-txt.mkvi71
1 files changed, 71 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/typo-txt.mkvi b/Master/texmf-dist/tex/context/base/typo-txt.mkvi
new file mode 100644
index 00000000000..f2859b58fe9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/typo-txt.mkvi
@@ -0,0 +1,71 @@
+%D \module
+%D [ file=typo-txt,
+%D version=2011.10.27,
+%D title=\CONTEXT\ Typesetting Macros,
+%D subtitle=Texts,
+%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 module replaces the by now rather old supp-fun module.
+
+\unprotect
+
+%D \NormalizeFontHeight \name {sample text} {height} {font}
+%D \NormalizeFontWidth \name {sample text} {width} {font}
+%D \NormalizeTextHeight {font} {height} {text}
+%D \NormalizeTextWidth {font} {width} {text}
+
+\newbox\b_typo_normalizers
+
+\def\typo_normalizers_size#axis#size%
+ {\dimexpr\ifdim#1\b_typo_normalizers=\zeropoint
+ \bodyfontsize
+ \else
+ \cldcontext{\number\dimexpr10pt\relax*\number\dimexpr#size\relax/\number#axis\b_typo_normalizers}\scaledpoint
+ \fi\relax}
+
+\def\typo_normalizers_font_at_size#axis#cs#text#size#font% avoid overflow by using lua
+ {\begingroup
+ \setbox\b_typo_normalizers\hbox{\definedfont[#font at 10pt]\settrialtypesetting#text}%
+ \normalexpanded{\endgroup\edef\noexpand\TheNormalizedFontSize{\the\typo_normalizers_size{#axis}{#size}}}%
+ \edef#cs{\noexpand\definedfont[#font at \TheNormalizedFontSize]}}
+
+\unexpanded\def\typo_normalizers_text_at_size#axis#font#size#text%
+ {\dontleavehmode
+ \begingroup
+ \setbox\b_typo_normalizers\hbox{\definedfont[#font at 10pt]\settrialtypesetting#text}%
+ \definedfont[#font at \the\typo_normalizers_size{#axis}{#size}]#text%
+ \endgroup}
+
+\let\TheNormalizedFontSize\!!zeropoint
+
+%D Traditionally we use UpperCasedNames for this kind of
+%D functionality.
+
+\unexpanded\def\NormalizeFontHeight{\typo_normalizers_font_at_size\ht}
+\unexpanded\def\NormalizeFontWidth {\typo_normalizers_font_at_size\wd}
+
+\unexpanded\def\NormalizeTextHeight{\typo_normalizers_text_at_size\ht}
+\unexpanded\def\NormalizeTextWidth {\typo_normalizers_text_at_size\wd}
+
+\unexpanded\def\WidthSpanningText#text#width#font% compatibility macro
+ {\hbox{\NormalizeFontWidth\temp{#text}{#width}{#font}\temp\the\everydefinedfont#1}}
+
+%D \startbuffer
+%D \NormalizeFontWidth \MyFontName {sample text} {10cm} {Serif*default}
+%D
+%D \ruledhbox{\MyFontName sample text}
+%D \blank
+%D \blackrule[width=10cm]
+%D \blank
+%D \ruledhbox{\NormalizeTextWidth {Serif*default} {10cm} {sample text}}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\protect \endinput