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
|
%D \module
%D [ file=s-fnt-25,
%D version=2009.01.25,
%D title=\CONTEXT\ Style File,
%D subtitle=Math Glyph Checking,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\def\enableshowmathfontvirtual
{\ctxlua{fonts.tfm.auto_cleanup=false}}
\def\showmathfontcharacters
{\dodoubleempty\doshowmathfontcharacters}
\def\doshowmathfontcharacters[#1][#2]%
{\begingroup
\dontcomplain
\doifelsenothing{#1}
{\definedfont[MathRoman*math-text]}
{\definedfont[#1]}%
\doifelsenothing{#2}
{\ctxlua{document.showmathfont(font.current())}}
{\def\dodoshowmathfontcharacters##1{\ctxlua{document.showmathfont(font.current(),##1)}}%
\processcommalist[#2]\dodoshowmathfontcharacters}%
\endgroup}
\def\startmathfontlist
{\startpacked}
\def\stopmathfontlist
{\stoppacked}
\def\startmathfontlistentry
{\blank
\begingroup}
\def\stopmathfontlistentry
{\endgroup
\blank}
\def\mathfontlistentryhexdectit#1#2#3%
{#1: \char#2\enspace\ruledhbox{\char#2}\enspace#3\par
\advance\leftskip 1em\relax}
\def\mathfontlistentrywdhtdpic#1#2#3#4%
{width: #1, height: #2, depth: #3, italic: #4\par}
\def\mathfontlistentryresource#1%
{virtual: #1\par}
\def\mathfontlistentrynext#1#2%
{#1~\ruledhbox{\char#2}}
\def\mathfontlistentrynextlist#1%
{next: #1\par}
\def\fontlistentryvariants#1#2%
{#1~\ruledhbox{\char#2}}
\def\mathfontlistentryvariantslist#1%
{variants: #1\par}
\def\mathfontlistentrynextvariantslist#1#2%
{next: #1 => variants: #2\par}
\def\mathfontlistentryclassname#1#2%
{mathclass: #1, mathname: #2\par}
\def\mathfontlistentrysymbol#1#2%
{mathsymbol: #1~\ruledhbox{\char#2}\par}
\startluacode
function document.showmathfont(id,slot)
local data = characters.data
local tfmdata = fonts.ids[id]
local characters = tfmdata.characters
local sorted = (slot and { slot }) or table.sortedkeys(characters)
local function report(...)
tex.sprint(tex.ctxcatcodes,string.format(...))
end
local virtual, names = tfmdata.type == "virtual", { }
if virtual then
for k, v in ipairs(tfmdata.fonts) do
local name = fonts.ids[v.id].name
names[k] = (name and file.basename(name)) or v.id
end
end
local round = math.round
-- print(table.serialize(names))
for _, s in next, sorted do
local char = characters[s]
if char then
local info = data[s]
local cnext, cvert_variants, choriz_variants = char.next, char.vert_variants, char.horiz_variants
report("\\startmathfontlistentry")
report("\\mathfontlistentryhexdectit{U+%05X}{%s}{%s}",s,s,string.lower(info.description or "no description, private to font"))
report("\\mathfontlistentrywdhtdpic{%s}{%s}{%s}{%s}",round(char.width or 0),round(char.height or 0),round(char.depth or 0),round(char.italic or 0))
if virtual then
local commands = char.commands
if commands then
local t = { }
for i=1,#commands do
local ci = commands[i]
if ci[1] == "slot" then
local fnt, idx = ci[2], ci[3]
t[#t+1] = string.format("%s/%0X",names[fnt] or fnt,idx)
end
end
if #t > 0 then
report("\\mathfontlistentryresource{%s}",table.concat(t,", "))
end
end
end
if info.mathclass then
report("\\mathfontlistentryclassname{%s}{%s}",info.mathclass,info.mathname or "no name")
end
if info.mathspec then
for i=1,#info.mathspec do
report("\\mathfontlistentryclassname{%s}{%s}",info.mathspec[i].class,info.mathspec[i].name or "no name")
end
end
if info.mathsymbol then
report("\\mathfontlistentrysymbol{U+%05X}{%s}",info.mathsymbol,info.mathsymbol)
end
if cnext then
local t, done = { }, { }
while cnext do
if done[cnext] then
t[#t+1] = "CYCLE"
break
else
done[cnext] = true
t[#t+1] = string.format("\\mathfontlistentrynext{U+%05X}{%s}",cnext,cnext)
cnext = characters[cnext]
cvert_variants = cnext.vert_variants or cvert_variants
choriz_variants = cnext.horiz_variants or choriz_variants
if cnext then
cnext = cnext.next
end
end
end
cnext = t
end
if cvert_variants then
local t = { }
for k, v in next, cvert_variants do
t[#t+1] = string.format("\\fontlistentryvariants{U+%05X}{%s}",v.glyph,v.glyph)
end
cvert_variants = t
end
if choriz_variants then
local t = { }
for k, v in next, choriz_variants do
t[#t+1] = string.format("\\fontlistentryvariants{U+%05X}{%s}",v.glyph,v.glyph)
end
choriz_variants = t
end
local cvariants = choriz_variants or cvert_variants
if cvariants and cnext then
report("\\mathfontlistentrynextvariantslist{%s}{%s}",table.concat(cnext," => "),table.concat(cvariants," => "))
else
if cnext then
report("\\mathfontlistentrynextlist{%s}",table.concat(cnext," => "))
end
if variants then
report("\\mathfontlistentryvariantslist{%s}",table.concat(cvariants," "))
end
end
report("\\stopmathfontlistentry")
end
end
end
\stopluacode
\endinput
\startbuffer[mathtest]
\begingroup\mm\mr\showmathfontcharacters\endgroup
\stopbuffer
\starttext
\usetypescript[cambria] \setupbodyfont[cambria, 12pt] \getbuffer[mathtest]
\usetypescript[lmvirtual] \setupbodyfont[lmvirtual,12pt] \getbuffer[mathtest]
\usetypescript[pxvirtual] \setupbodyfont[pxvirtual,12pt] \getbuffer[mathtest]
\usetypescript[txvirtual] \setupbodyfont[txvirtual,12pt] \getbuffer[mathtest]
\usetypescript[palatino] \setupbodyfont[palatino, 10pt] \getbuffer[mathtest]
\usetypescript[mathtimes] \setupbodyfont[mathtimes,12pt] \getbuffer[mathtest]
\stoptext
|