s-math-extensibles.mkiv /size: 6091 b    last modification: 2023-12-21 09:45
1%D \module
2%D   [      file=s-math-extensibles.mkiv,
3%D        version=2013.02.03,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Math Stackers Checking,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D This module provides a macro that will typeset a table of (horizontal)
15%D extensibles including some tracing. You can set up the \type {demo}
16%D stacker category to tweak things.
17%D
18%D \starttyping
19%D \showmathextensibles[alternative=a|b]
20%D \stoptyping
21
22\startmodule[math-extensibles]
23
24\unprotect
25
26\definemathstackers
27  [demo]
28  [math]
29  [\c!offset=\v!max]
30
31\installcorenamespace{modulemathextensibles}
32\installcorenamespace{modulemathextensiblesalternative}
33
34\installdirectsetuphandler \??modulemathextensibles {modulemathextensibles}
35
36\setupmodulemathextensibles
37  [\c!alternative=\v!a]
38
39\unexpanded\def\showmathextensibles
40  {\dosingleempty\module_math_extensibles_show_all}
41
42\def\module_math_extensibles_show_all[#1]%
43  {\begingroup
44   \setupcurrentmodulemathextensibles[#1]%
45   \expandnamespacevalue\??modulemathextensiblesalternative\c!alternative\v!a
46   \endgroup}
47
48\def\modulemathextensiblesalternativea#1#2#3%
49  {\NC U+#1
50   \NC \filledhboxm{\math{\char"#1}}
51   \NC \hbox{\math{\mathstacker[demo]{"#1}{top}{bottom}}}
52   \NC \hbox{\math{\mathstacker[demo]{"#1}{}{bottom}}}
53   \NC \hbox{\math{\mathstacker[demo]{"#1}{top}{}}}
54   \NC \nohyphens \veryraggedright #2
55   \NC\NR}
56
57\setvalue{\??modulemathextensiblesalternative\v!a}%
58  {\enabletrackers[math.stackers.texts]
59   \starttabulate[|Tl|l|l|l|l|Tp|]
60   \ctxlua { moduledata.math.extensibles.show {
61        command = "modulemathextensiblesalternativea",
62   } }
63   \stoptabulate
64   \disabletrackers[math.stackers.texts]}
65
66\def\modulemathextensiblesalternativeb#1#2#3%
67  {\NC U+#1
68   \NC \math{\char"#1}
69   \NC \nohyphens \veryraggedright #3
70   \NC \NR}
71
72\setvalue{\??modulemathextensiblesalternative\v!b}%
73  {\enabletrackers[math.stackers.texts]
74   \starttabulate[|Tl|l|Tp|]
75   \ctxlua { moduledata.math.extensibles.show {
76        command = "modulemathextensiblesalternativeb",
77        sparse  = true,
78   } }
79   \stoptabulate
80   \disabletrackers[math.stackers.texts]}
81
82\startluacode
83    moduledata.math             = moduledata.math             or { }
84    moduledata.math.extensibles = moduledata.math.extensibles or { }
85
86    function moduledata.math.extensibles.show(settings)
87        local command = settings.command
88        local sparse  = settings.sparse
89        for k, v in table.sortedhash(characters.data) do
90            local mathextensible = v.mathextensible
91            if mathextensible == "r" or mathextensible == "l" or mathextensible == "h" then
92                local names = { }
93                local mathname = v.mathname
94                if mathname then
95                    names[#names+1] = v.mathclass .. ":"  .. mathname
96                end
97                local mathspec = v.mathspec
98                if mathspec then
99                    for i=1,#mathspec do
100                        local v = mathspec[i]
101                        names[#names+1] = v.class .. ":"  .. v.name
102                    end
103                end
104                local mathfiller = v.mathfiller
105                if mathfiller then
106                    names[#names+1] = "filler:" .. mathfiller
107                end
108                if not sparse or #names > 0 then
109                    context[command](string.format("%04X",k),v.description,table.concat(names," "))
110                end
111            end
112        end
113    end
114\stopluacode
115
116\protect
117
118\stopmodule
119
120\continueifinputfile{s-math-extensibles.mkiv}
121
122\setuplayout
123  [width=middle,
124   height=middle,
125   footer=0cm,
126   backspace=1.5cm,
127   topspace=1.5cm]
128
129\setuphead[chapter][style=\bfc]
130\setuphead[section][style=\bfa]
131
132\starttext
133
134    \dowith {a,b} {
135
136        \page                          \title {Latin Modern} \showmathextensibles[alternative=#1]
137        \page \setupbodyfont[pagella]  \title {Pagella}      \showmathextensibles[alternative=#1]
138        \page \setupbodyfont[termes]   \title {Termes}       \showmathextensibles[alternative=#1]
139        \page \setupbodyfont[dejavu]   \title {Xits}         \showmathextensibles[alternative=#1]
140        \page \setupbodyfont[cambria]  \title {Cambria}      \showmathextensibles[alternative=#1]
141        \page \setupbodyfont[lucidaot] \title {Lucida}       \showmathextensibles[alternative=#1]
142
143    }
144
145\stoptext
146
147% This could also be some tracer
148
149\definefontfeature[mathextra][goodies=] % or use the raw unpatched font
150
151
152\def\Test#1%
153  {\left(
154   \scratchdimen\Umathaxis\displaystyle
155   \blackrule
156     [height=\dimexpr#1ex+\scratchdimen\relax,
157      depth=\dimexpr#1ex-\scratchdimen\relax]
158   \right)}
159
160
161\startbuffer[p]
162%   \Umathconnectoroverlapmin\allmathstyles \zeropoint
163%   \Umathconnectoroverlapmin\allmathstyles 2pt % \zeropoint
164    \Umathdelimitershortfall \allmathstyles \zeropoint
165    \showboxes
166    \showglyphs
167    \Test{4.0}
168    \Test{4.5}
169    \Test{5.0}
170    \Test{8.0}
171    \quad
172    \dorecurse{\mathvariantcount `(} {
173        \char\mathvariantcode `( #1
174    }
175\stopbuffer
176
177\startbuffer[p]
178    \showboxes
179    \showglyphs
180    \overparent{\blackrule[color=darkgray,width=1em,height=2ex]}\quad
181    \overparent{\blackrule[color=darkgray,width=2em,height=2ex]}\quad
182    \overparent{\blackrule[color=darkgray,width=4em,height=2ex]}\quad
183    \overparent{\blackrule[color=darkgray,width=8em,height=2ex]}
184\stopbuffer
185
186\startbuffer
187    \hpack\bgroup
188    $
189        \getbuffer[p]
190    $
191    \egroup
192\stopbuffer
193
194\def\TestFont#1%
195  {\dontleavehmode
196   \begingroup
197   \hbox to 5.5em{\hss\type{#1}:}\quad
198   \switchtobodyfont[#1]\getbuffer
199   \endgroup
200   \par}
201
202\starttext
203    \startTEXpage[offset=1dk]
204%     \TestFont{modern}
205%     \TestFont{pagella}
206%     \TestFont{termes}
207%     \TestFont{bonum}
208    \TestFont{lucida}
209%     \TestFont{cambria}
210    \TestFont{ebgaramond}
211%     \TestFont{xits}
212    \stopTEXpage
213\stoptext
214