%D \module %D [ file=meta-imp-placeholders, %D version=2021.02.01, %D title=\METAPOST\ Graphics, %D subtitle=Missing Glyph Placeholders, %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 is a drop in for the already existing placeholder function. It could be made %D more clever by hashing similar shapes but as this is mostly a diagnostic feature %D we go a quick an ddirty two dimensional array. %D It is now mostly a file one can run to get an idea what the replace macro triggers %D so I've added it to the distribution. % \startMPcalculation{simplefun} % loadfile("mp-miss.mpxl") ; % \stopMPcalculation % % \startluacode % % local chardata = characters.data % local fontdata = fonts.hashes.identifiers % local mapping = fonts.checkers.mapping % % function fonts.checkers.placeholder(font,char) % local category = chardata[char].category or "lu" -- todo: unknown % local fakedata = mapping[category] % local tfmdata = fontdata[font] % local units = tfmdata.parameters.units or 1000 % local slant = (tfmdata.parameters.slant or 0)/65536 % local scale = units/1000 % local rawdata = tfmdata.shared and tfmdata.shared.rawdata % local weight = (rawdata and rawdata.metadata and rawdata.metadata.pfmweight or 400)/400 % local specification = { % code = "MissingGlyph", % scale = scale, % slant = slant, % weight = weight, % namespace = font, % shapes = { { shape = fakedata[1], color = fakedata[2] } }, % } % fonts.helpers.setmetaglyphs("missing", font, char, specification) % end % % \stopluacode %D We enable the checker: % \enabletrackers[fonts.missing=replace] \replacemissingcharacters \continueifinputfile{meta-imp-placeholders.mkxl} % \enableexperiments[fonts.compact] % \showglyphs \startbuffer \startlines[before=,after=] \strut {\tf test \char 12345\ test \char 12346\ test} \strut {\bf test \char 12345\ test \char 12346\ test} \strut {\it test \char 12345\ test \char 12346\ test} \strut {\bi test \char 12345\ test \char 12346\ test} \strut {test ὀ ρ φ α ν ῖ ο ς test} \stoplines \stopbuffer \starttext \startTEXpage[offset=2pt,strut=no] \getbuffer \switchtobodyfont[pagella] \getbuffer \switchtobodyfont[dejavu] \getbuffer \stopTEXpage \stoptext