summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-math-extensibles.mkiv
blob: b3fcf0e1f67ab7cfb33a7c2b1d7b14fd32e15748 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
%D \module
%D   [      file=s-math-extensibles.mkiv,
%D        version=2013.02.03,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Math Stackers Checking,
%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 provides a macro that will typeset a table of (horizontal)
%D extensibles including some tracing. You can set up the \type {demo}
%D stacker category to tweak things.
%D
%D \starttyping
%D \showmathextensibles[alternative=a|b]
%D \stoptyping

\startmodule[math-extensibles]

\unprotect

\definemathstackers
  [demo]
  [math]
  [\c!offset=\v!max]

\installcorenamespace{modulemathextensibles}
\installcorenamespace{modulemathextensiblesalternative}

\installdirectsetuphandler \??modulemathextensibles {modulemathextensibles}

\setupmodulemathextensibles
  [\c!alternative=\v!a]

\unexpanded\def\showmathextensibles
  {\dosingleempty\module_math_extensibles_show_all}

\def\module_math_extensibles_show_all[#1]%
  {\begingroup
   \setupcurrentmodulemathextensibles[#1]%
   \expandnamespacevalue\??modulemathextensiblesalternative\c!alternative\v!a
   \endgroup}

\def\modulemathextensiblesalternativea#1#2#3%
  {\NC U+#1
   \NC \filledhboxm{\math{\char"#1}}
   \NC \hbox{\math{\mathstacker[demo]{"#1}{top}{bottom}}}
   \NC \hbox{\math{\mathstacker[demo]{"#1}{}{bottom}}}
   \NC \hbox{\math{\mathstacker[demo]{"#1}{top}{}}}
   \NC \nohyphens \veryraggedright #2
   \NC\NR}

\setvalue{\??modulemathextensiblesalternative\v!a}%
  {\enabletrackers[math.stackers.texts]
   \starttabulate[|Tl|l|l|l|l|Tp|]
   \ctxlua { moduledata.math.extensibles.show {
        command = "modulemathextensiblesalternativea",
   } }
   \stoptabulate
   \disabletrackers[math.stackers.texts]}

\def\modulemathextensiblesalternativeb#1#2#3%
  {\NC U+#1
   \NC \math{\char"#1}
   \NC \nohyphens \veryraggedright #3
   \NC \NR}

\setvalue{\??modulemathextensiblesalternative\v!b}%
  {\enabletrackers[math.stackers.texts]
   \starttabulate[|Tl|l|Tp|]
   \ctxlua { moduledata.math.extensibles.show {
        command = "modulemathextensiblesalternativeb",
        sparse  = true,
   } }
   \stoptabulate
   \disabletrackers[math.stackers.texts]}

\startluacode
    moduledata.math             = moduledata.math             or { }
    moduledata.math.extensibles = moduledata.math.extensibles or { }

    function moduledata.math.extensibles.show(settings)
        local command = settings.command
        local sparse  = settings.sparse
        for k, v in table.sortedhash(characters.data) do
            local mathextensible = v.mathextensible
            if mathextensible == "r" or mathextensible == "l" or mathextensible == "h" then
                local names = { }
                local mathname = v.mathname
                if mathname then
                    names[#names+1] = v.mathclass .. ":"  .. mathname
                end
                local mathspec = v.mathspec
                if mathspec then
                    for i=1,#mathspec do
                        local v = mathspec[i]
                        names[#names+1] = v.class .. ":"  .. v.name
                    end
                end
                local mathfiller = v.mathfiller
                if mathfiller then
                    names[#names+1] = "filler:" .. mathfiller
                end
                if not sparse or #names > 0 then
                    context[command](string.format("%04X",k),v.description,table.concat(names," "))
                end
            end
        end
    end
\stopluacode

\protect

\stopmodule

\continueifinputfile{s-math-extensibles.mkiv}

\setuplayout
  [width=middle,
   height=middle,
   footer=0cm,
   backspace=1.5cm,
   topspace=1.5cm]

\setuphead[chapter][style=\bfc]
\setuphead[section][style=\bfa]

\starttext

    \dowith {a,b} {

        \page                          \title {Latin Modern} \showmathextensibles[alternative=#1]
        \page \setupbodyfont[pagella]  \title {Pagella}      \showmathextensibles[alternative=#1]
        \page \setupbodyfont[termes]   \title {Termes}       \showmathextensibles[alternative=#1]
        \page \setupbodyfont[dejavu]   \title {Xits}         \showmathextensibles[alternative=#1]
        \page \setupbodyfont[cambria]  \title {Cambria}      \showmathextensibles[alternative=#1]
        \page \setupbodyfont[lucidaot] \title {Lucida}       \showmathextensibles[alternative=#1]

    }

\stoptext

% This could also be some tracer

\definefontfeature[mathextra][goodies=] % or use the raw unpatched font


\def\Test#1%
  {\left(
   \scratchdimen\Umathaxis\displaystyle
   \blackrule
     [height=\dimexpr#1ex+\scratchdimen\relax,
      depth=\dimexpr#1ex-\scratchdimen\relax]
   \right)}


\startbuffer[p]
%   \Umathconnectoroverlapmin\allmathstyles \zeropoint
%   \Umathconnectoroverlapmin\allmathstyles 2pt % \zeropoint
    \Umathdelimitershortfall \allmathstyles \zeropoint
    \showboxes
    \showglyphs
    \Test{4.0}
    \Test{4.5}
    \Test{5.0}
    \Test{8.0}
    \quad
    \dorecurse{\mathvariantcount `(} {
        \char\mathvariantcode `( #1
    }
\stopbuffer

\startbuffer[p]
    \showboxes
    \showglyphs
    \overparent{\blackrule[color=darkgray,width=1em,height=2ex]}\quad
    \overparent{\blackrule[color=darkgray,width=2em,height=2ex]}\quad
    \overparent{\blackrule[color=darkgray,width=4em,height=2ex]}\quad
    \overparent{\blackrule[color=darkgray,width=8em,height=2ex]}
\stopbuffer

\startbuffer
    \hpack\bgroup
    $
        \getbuffer[p]
    $
    \egroup
\stopbuffer

\def\TestFont#1%
  {\dontleavehmode
   \begingroup
   \hbox to 5.5em{\hss\type{#1}:}\quad
   \switchtobodyfont[#1]\getbuffer
   \endgroup
   \par}

\starttext
    \startTEXpage[offset=1dk]
%     \TestFont{modern}
%     \TestFont{pagella}
%     \TestFont{termes}
%     \TestFont{bonum}
    \TestFont{lucida}
%     \TestFont{cambria}
    \TestFont{ebgaramond}
%     \TestFont{xits}
    \stopTEXpage
\stoptext