summaryrefslogtreecommitdiff
path: root/metapost/context/base/mpxl/mp-miss.mpxl
blob: 0788fece4cac1b918e655f129886278a26029408 (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
%D \module
%D   [       file=mp-miss.mpiv,
%D        version=2021.02.01,
%D          title=\CONTEXT\ \METAPOST\ graphics,
%D       subtitle=missing glyphs,
%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.

if known metafun_loaded_miss : endinput ; fi ;

newinternal boolean metafun_loaded_miss ; metafun_loaded_miss := true ; immutable metafun_loaded_miss ;

picture MissingSnippets[][];

vardef MissingGlyphSymbol(expr w, h, d) =
    image (
        draw (0,-d)--(w,-d)--(w,h)--(0,h)--cycle ;
        if d <> 0 : draw (0,0)--(w,0) ;
    )
enddef ;

vardef MissingLowercase   = image ( draw MissingGlyphSymbol(.45, .55,  .20) scaled 1000 ; ) enddef ;
vardef MissingUppercase   = image ( draw MissingGlyphSymbol(.65, .70,  .25) scaled 1000 ; ) enddef ;
vardef MissingMark        = image ( draw MissingGlyphSymbol(.15, .70, -.50) scaled 1000 ; ) enddef ;
vardef MissingPunctuation = image ( draw MissingGlyphSymbol(.15, .55,  .20) scaled 1000 ; ) enddef ;
vardef MissingUnknown     = image ( draw MissingGlyphSymbol(.45, .20,    0) scaled 1000 ; ) enddef ;

% vardef MissingGlyph =
%     pickup pencircle scaled 0.05 ;
%     composeglyph(MissingSnippets[getparameterdefault "mpsfont" "namespace" 1]) ;
% enddef ;

vardef MissingGlyph =
    save u ; u := getparameterdefault "mpsfont" "unicode" 1;
    save s ; s := getparameterdefault "mpsfont" "scale" 1 ;
    save n ; n := getparameterdefault "mpsfont" "namespace" 1 ;
    save i ; i := getparameterdefault "mpsfont" "slant" 0 ;
    save w ; w := getparameterdefault "mpsfont" "weight" 1 ;
    pickup pencircle scaled (0.05 * w) ;
    MissingSnippets[n][u] := image (
        draw scantokens ( getparameter "mpsfont" "shapes" (1) "shape" )
            withcolor getparameter "mpsfont" "shapes" (1) "color"
    ) scaled s slanted i ;
    registercomposedglyph(u, MissingSnippets[n]) ;
enddef ;

lmt_registerglyphs [
    name   = "missing",
    units  =  1000,
    width  =  100,
    height =  100,
    depth  =  0,
] ;

% we need to set up some basics (signals to the backend and such) at definition
% time so we just force a bogus shape (zero)

lmt_registerglyph [
    category = "missing",
] ;

permanent MissingSnippets, MissingGlyphSymbol, MissingLowercase, MissingUppercase,
    MissingMark, MissingPunctuation, MissingUnknown, MissingGlyph ;