summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/meta-imp-placeholders.mkxl
blob: aa48b814c020fe115614bfc1f36838b62c253f74 (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
%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