1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22\startmodule[fontscharts]
23
24
25\starttexdefinition unexpanded FontChartSetSlot #1#2
26 \dontleavehmode
27 \setbox\scratchbox\vbox to 1cm \bgroup
28 \vss
29 \hbox to 1cm \bgroup
30 \infofont \hss\raise.25mm\hbox{#2}\hss
31 \egroup
32 \egroup
33 \wd\scratchbox0mm
34 \ht\scratchbox5mm
35 \dp\scratchbox5mm
36 \box\scratchbox
37 \setbox\scratchbox\ruledhbox to 1cm \bgroup
38 \hss\char#1\hss
39 \egroup
40 \ht\scratchbox5mm
41 \dp\scratchbox5mm
42 \box\scratchbox
43\stoptexdefinition
44
45\starttexdefinition unexpanded FontChartNoSlot
46 \dontleavehmode
47 \setbox\scratchbox\hbox to 1cm \bgroup
48
49 \egroup
50 \ht\scratchbox5mm
51 \dp\scratchbox5mm
52 \box\scratchbox
53\stoptexdefinition
54
55\starttexdefinition unexpanded FontChartSetLegend #1
56 \dontleavehmode
57
58 \setbox\scratchbox\hbox to 1cm \bgroup
59 \infofont\hss#1\hss
60 \egroup
61 \ht\scratchbox5mm
62 \dp\scratchbox5mm
63 \box\scratchbox
64\stoptexdefinition
65
66\starttexdefinition unexpanded FontChartSetCaption #1#2
67 \dontleavehmode
68 \setbox\scratchbox\hbox to 16cm \bgroup
69 \infofontbold\hskip1cm#1: #2\hss
70 \egroup
71 \ht\scratchbox7.5mm
72 \dp\scratchbox2.5mm
73 \box\scratchbox
74\stoptexdefinition
75
76\starttexdefinition unexpanded FontChartGap
77 \kern .5mm
78\stoptexdefinition
79
80\startluacode
81 local div, mod = math.div, math.mod
82 local formatters = string.formatters
83
84 moduledata.fonts = moduledata.fonts or { }
85 moduledata.fonts.charts = moduledata.fonts.charts or { }
86
87 function moduledata.fonts.charts.show(settings)
88
89 local settings = utilities.parsers.settings_to_hash(settings)
90
91 local filename = settings.filename or settings.name or ""
92 local fontid = true
93 local newpage = settings.page == interfaces.variables.yes
94 local all = settings.option == interfaces.variables.all
95
96 if filename ~= "" then
97 fontid = fonts.definers.internal({ name = filename, size = "10pt" },"chartfont")
98 end
99
100 local ranges = { }
101 local data = fonts.hashes.identifiers[fontid]
102 local private = fonts.constructors.privateoffset
103 local chars = data.characters
104
105 for u in table.sortedhash(chars) do
106 if not all and u >= private then
107 break
108 else
109 ranges[div(u,0xFF)] = true
110 end
111 end
112
113 local ctx_setlegend = context.FontChartSetLegend
114 local ctx_noslot = context.FontChartNoSlot
115 local ctx_setslot = context.FontChartSetSlot
116 local ctx_setcaption = context.FontChartSetCaption
117 local ctx_par = context.par
118 local ctx_gap = context.FontChartGap
119
120 for r in table.sortedhash(ranges) do
121 if newpage then
122 context.page()
123 end
124 context.startframed { offset = "overlay", frame = "off", align = "normal" }
125 if filename ~= "" then
126 context.chartfont()
127 end
128 context.dontcomplain()
129 context.offinterlineskip()
130 ctx_noslot()
131 for i=0,0xF do
132 ctx_gap()
133 ctx_setlegend(formatters["%03X"](r*0x10+i))
134 end
135 r = r * 0xFF
136 ctx_par()
137 for i=0,0xF do
138 ctx_setlegend(formatters["%0X"](i))
139 ctx_gap()
140 for j=0,0xF do
141 local u = r + i*0x10 + j
142 local d = chars[u]
143 if d then
144 ctx_setslot(u,formatters["%04X"](u))
145 else
146 ctx_noslot()
147 end
148 if j ~= 0xF then
149 ctx_gap()
150 end
151 end
152 ctx_par()
153 ctx_gap()
154 end
155 ctx_setcaption(formatters["%04X-%04X"](r,r+0xFF),file.basename(data.properties.filename))
156 ctx_par()
157 context.stopframed()
158 if newpage then
159 context.page()
160 end
161 end
162 end
163\stopluacode
164
165\installmodulecommandluasingle \showfontchart {moduledata.fonts.charts.show}
166
167\stopmodule
168
169\continueifinputfile{sfontscharts.mkiv}
170
171\usemodule[art01]
172
173\starttext
174
175 \showfontchart[filename=texgyredejavumath.otf,page=yes,option=all]
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\stoptext
214 |