blob: f2859b58fe970b0936f1e234502393ef383cf7b7 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
|