s-fonts-outlines.mkxl /size: 8130 b    last modification: 2025-02-21 11:03
1%D \module
2%D   [      file=s-fonts-outlines,
3%D        version=2024.01.05,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Showing Outlines,
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 is mostly used for debugging a font and might evolve accordingly. The
15%D current interface is minimalistic. It was made when debugging some cff issues with
16%D old type one fonts that we needed to support.
17%D
18%D Processing all fonts on my disk results in some 2500 pages and the highest memory
19%D usage I ever encountered with \LUAMETATEX: when we start with an empty cache we
20%D need some 30 GB and for a final run more than 10; much relates to \LUA\ allocating
21%D beforehand (doubling table memory as they grow) and garbage collection.
22
23\startbuffer[samplefonttext]
24    a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\crlf
25    A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z\crlf
26    @\\1\\2\\3\\4\\5\\6\\7\\8\\9\\0\\(\\)\\[\\]\\\{\\\}\\&\\+\\-\\=\\<\\>\\%
27    \textslash\\\textbackslash\\\texthash\\\textpercent\\_\\-\\*\\!\\?\\,\\.\\:\\;%
28\stopbuffer
29
30\startbuffer[samplefont]
31    \framed
32      [offset=overlay,
33       frame=off,
34       align=middle]
35      {\def\\{\kern.2\emwidth}%
36       \getbuffer[samplefonttext]}%
37\stopbuffer
38
39\startMPdefinitions
40
41presetparameters "samplefont" [
42    name   = "",
43    labels = false,
44    buffer = "samplefont"
45] ;
46
47def lmt_samplefont = applyparameters "samplefont" "lmt_do_samplefont" enddef ;
48
49vardef lmt_do_samplefont =
50    image (
51        pushparameters "samplefont" ;
52
53        save sample ; string sample ; sample := "\getbuffer[" & (getparameter "buffer") & "]" ;
54        save banner ; string banner ; banner := "\strut\tttf " & (getparameter "name") ;
55
56        save p ; picture p[] ;
57
58        p[1] := lmt_outline [ text = sample ] ;
59        p[2] := textext(sample) ;
60        p[3] := textext.ulft(banner) ;
61
62        p[1] := (p[1] shifted - center p[1]) scaled 20 ;
63        p[2] := (p[2] shifted - center p[2]) scaled 20 ;
64        p[3] :=  p[3]                        scaled  4 ;
65
66        save c ; string c[] ;
67
68        c[1] := "middlered"   ; c[4] := "middlemagenta" ;
69        c[2] := "middlegreen" ; c[5] := "middlecyan"    ;
70        c[3] := "middleblue"  ; c[6] := "middleyellow"  ;
71
72        save n ; numeric n ; n := 1 ;
73
74        for i within p[1] :
75            drawpath pathpart i ;
76            drawpoints pathpart i withcolor c[n] ;
77            n := if n == 6 : 1 else : n + 1 fi ;
78        endfor ;
79
80        if (getparameter "labels") :
81
82            save defaultfont  ; string  defaultfont  ; defaultfont  := "Mono" ;
83            save defaultscale ; numeric defaultscale ; defaultscale := .4 ;
84
85            c[1] := "darkred"   ; c[4] := "darkmagenta" ;
86            c[2] := "darkgreen" ; c[5] := "darkcyan"    ;
87            c[3] := "darkblue"  ; c[6] := "darkyellow"  ;
88
89            n := 1 ;
90
91            for i within p[1] :
92                drawpointlabels pathpart i withcolor c[n] ;
93                n := if n == 6 : 1 else : n + 1 fi ;
94            endfor ;
95
96        fi ;
97
98        draw p[2]
99            shifted (0,-1.1*bbheight(p2)) ;
100
101        draw p[3]
102            shifted urcorner currentpicture ;
103
104        popparameters ;
105    )
106enddef ;
107
108\stopMPdefinitions
109
110\starttexdefinition protected samplefont[#1]
111    \begingroup
112        \getdummyparameters[name=dejavuserif.otf,buffer=samplefont,labels=no,#1]
113        \writestatus{fontfile}{\dummyparameter{name}}
114        \definedfont[\dummyparameter{name}]
115        \iffontchar\font`a\relax
116            \startMPpage[offset=2ts]
117                draw lmt_samplefont [
118                    buffer = "\dummyparameter{buffer}",
119                    name   = "\dummyparameter{name}",
120                    labels = \ifcstok{\dummyparameter{labels}}{yes}true\else false\fi
121                ] ;
122            \stopMPpage
123        \else
124            \writestatus{fontfile}{\dummyparameter{name} has no 'a'}
125        \fi
126    \endgroup
127\stoptexdefinition
128
129\continueifinputfile{s-fonts-outlines.mkxl}
130
131% \enabledirectives[fonts.cff.flatten]
132
133\starttext
134% \disabledirectives[fonts.streams.pack]
135% \enabletrackers[fonts.cff.charstrings]
136% \samplefont[name=gentiumbookplusitalic.ttf,labels=yes] % missing contours
137% \samplefont[name=lmr10.afm,labels=yes]
138% \samplefont[name=ibmplexmath.otf]
139\samplefont[name=sab.afm]
140\samplefont[name=creditsuissetyperoman.ttf]
141\samplefont[name=calibri.ttf]
142% \samplefont[name=lmmonoprop10-regular.otf]
143% \samplefont[name=texgyrepagella-regular.otf]
144% \samplefont[name=lmmonoltcond10-regular.otf]
145% \samplefont[name=lmsans10-boldoblique.otf]
146% \samplefont[name=sourcecodevariableitalic.otf]
147% \samplefont[name=sourcecodevariableroman.otf]
148% \samplefont[name=sourcehansansextralight.otf]
149% \samplefont[name=notosanscjkkrlight.otf]
150% \samplefont[name=notosanscjkscdemilight.otf]
151% \samplefont[name=notosanscjktclight.otf]
152% \samplefont[name=dfminchopstdw5.otf]
153\stoptext
154
155%D I might look into some of the crashes but some of these fonts are experimental
156%D and might be produced manually. Also some are plain ugly due to their state of
157%D development, but it's what I had to test at some point, so they stuck around and
158%D I have no motivation to sort out the mess.
159
160\starttext
161
162\startluacode
163    local todo = {
164
165        ["adobeblank.otf"]                  = "useless",
166        ["adobeblank2.otf"]                 = "useless",
167        ["lastresort.ttf"]                  = "useless",
168
169        ["sourcecodevariableitalic.otf"]    = "crash",
170        ["sourcecodevariableroman.otf"]     = "crash",
171        ["sourcehansansextralight.otf"]     = "crash",
172        ["sourceserif4displaylight.otf"]    = "crash",
173        ["notosanscjkkrlight.otf"]          = "crash",
174        ["notosanscjkscdemilight.otf"]      = "crash",
175        ["notosanscjktclight.otf"]          = "crash",
176        ["junicodetwobetaregularvf.otf"]    = "crash",
177        ["junicodetwobetabold.otf"]         = "crash",
178        ["dfminchopstdw5.otf"]              = "crash",
179        ["alegreyasansthin.otf"]            = "crash",
180        ["alegreyasansthinitalic.otf"]      = "crash",
181
182
183        ["lte52172.ttf"]                    = "crash",
184        ["avkv.ttf"]                        = "crash",
185        ["tirekv.ttf"]                      = "crash",
186
187        ["bhb.afm"]                         = "crash",
188        ["bhd.afm"]                         = "crash",
189        ["bhh.afm"]                         = "crash",
190        ["bhl.afm"]                         = "crash",
191        ["bhm.afm"]                         = "crash",
192        ["a.afm"]                           = "crash",
193        ["myriadmmitweight400width600.afm"] = "crash",
194        ["myriadmmitweight700width600.afm"] = "crash",
195        ["myriadmmweight400width600.afm"]   = "crash",
196        ["myriadmmweight700width600.afm"]   = "crash",
197
198    }
199
200    local skip = {
201        ["^arial"]    = "bugged",
202        ["^myriad"]   = "bugged",
203        ["^junicode"] = "bugged",
204        ["^noto"]     = "big",
205        ["^source"]   = "big",
206        ["^amiri"]    = "bugged",
207    }
208
209    local function isbad(name)
210        if todo[name] then
211            return todo[name]
212        else
213            for k, v in next, skip do
214                if string.find(name,k) then
215                    return v
216                end
217            end
218        end
219        return false
220    end
221
222    fonts.names.load()
223    local data = fonts.names.data
224    for k, v in table.sortedhash(data.files) do
225        local bad = isbad(k)
226        if bad then
227            context.writestatus("fontfile","skipping '" .. k .. "' : " .. bad)
228        else
229            local s = string.lower(file.suffix(k))
230            if s == "otf" or s == "ttf" or s == "afm" then
231         -- if s == "otf" then
232         -- if s == "ttf" then
233         -- if s == "afm" then
234                context.showsampleFont { name = k }
235            end
236        end
237    end
238\stopluacode
239
240\stoptext
241