diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-02-05 18:08:41 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-02-05 18:08:41 +0100 |
commit | 5a7dd5d18ced4a73b05467f208d4c4b0d1afebc0 (patch) | |
tree | 7138a651a94fb013e584b080c50c4681321617cc /metapost | |
parent | ab4fc27d8b1541b491621e07ab1f40f30aaf50ae (diff) | |
download | context-5a7dd5d18ced4a73b05467f208d4c4b0d1afebc0.tar.gz |
2021-02-05 17:44:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpxl/mp-lmtx.mpxl | 10 | ||||
-rw-r--r-- | metapost/context/base/mpxl/mp-miss.mpxl | 68 |
2 files changed, 74 insertions, 4 deletions
diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl index 57794e544..56a0ec066 100644 --- a/metapost/context/base/mpxl/mp-lmtx.mpxl +++ b/metapost/context/base/mpxl/mp-lmtx.mpxl @@ -2224,6 +2224,7 @@ newscriptindex mfid_registerglyph ; mfid_registerglyph := scriptindex "registe % An experimental macro: vardef registercomposedglyph (expr u) (suffix snippets) = + save s ; s := getparameterdefault "mpsfont" "scale" 1 ; save llx, lly, urx, ury ; llx := xpart llcorner snippets[u] ; if llx <> 0 : @@ -2231,9 +2232,9 @@ vardef registercomposedglyph (expr u) (suffix snippets) = snippets[u] := snippets[u] shifted (-llx, 0) ; llx := 0; fi ; - lly := ypart llcorner snippets[u] ; - urx := xpart urcorner snippets[u] ; - ury := ypart urcorner snippets[u] ; + lly := ypart llcorner snippets[u] / s ; + urx := xpart urcorner snippets[u] / s ; + ury := ypart urcorner snippets[u] / s ; lmt_registerglyph [ category = getparameter "mpsfont" "category", unicode = u, @@ -2247,6 +2248,7 @@ enddef ; vardef composeglyph (suffix snippets) = save u ; u := getparameter "mpsfont" "unicode" ; + save s ; s := getparameterdefault "mpsfont" "scale" 1 ; snippets[u] := image ( for i=1 upto getparametercount "mpsfont" "shapes" : draw scantokens ( getparameter "mpsfont" "shapes" i "shape" ) @@ -2254,7 +2256,7 @@ vardef composeglyph (suffix snippets) = withcolor getparameter "mpsfont" "shapes" i "color" fi ; endfor ; - ) ; + ) scaled s ; registercomposedglyph(u, snippets) ; enddef ; diff --git a/metapost/context/base/mpxl/mp-miss.mpxl b/metapost/context/base/mpxl/mp-miss.mpxl new file mode 100644 index 000000000..0788fece4 --- /dev/null +++ b/metapost/context/base/mpxl/mp-miss.mpxl @@ -0,0 +1,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 ; |