summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/meta-imp-glyphs.mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl/meta-imp-glyphs.mkxl')
-rw-r--r--tex/context/base/mkxl/meta-imp-glyphs.mkxl65
1 files changed, 65 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/meta-imp-glyphs.mkxl b/tex/context/base/mkxl/meta-imp-glyphs.mkxl
new file mode 100644
index 000000000..96f7aecd3
--- /dev/null
+++ b/tex/context/base/mkxl/meta-imp-glyphs.mkxl
@@ -0,0 +1,65 @@
+%D \module
+%D [ file=meta-imp-glyphs,
+%D version=2022.10.26, % moved from test files by MS and HH
+%D title=\METAPOST\ Graphics,
+%D subtitle=Glyph Shape Manipulations,
+%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.
+
+\startMPdefinitions
+
+ def LoadGlyph(expr tag, filename, unicode) =
+ glyphshape_start(filename,unicode) ;
+ expandafter picture scantokens(tag & "char");
+ expandafter path scantokens(tag & "bbox") ;
+ expandafter numeric scantokens(tag & "accent") ;
+ expandafter numeric scantokens(tag & "italic") ;
+ scantokens(tag & "char") := image (draw for i=1 upto glyphshape_n : glyphshape_path(i) && endfor cycle ;) ;
+ scantokens(tag & "bbox") := glyphshape_usedbox ;
+ scantokens(tag & "accent") := glyphshape_accent ;
+ scantokens(tag & "italic") := xpart urcorner glyphshape_usedbox - glyphshape_italic ;
+ glyphshape_stop ;
+ enddef ;
+
+ def ScaleGlyph(expr tag, s) =
+ scantokens(tag & "char") := scantokens(tag & "char") scaled s ;
+ scantokens(tag & "bbox") := scantokens(tag & "bbox") scaled s ;
+ scantokens(tag & "accent") := s * scantokens(tag & "accent") ;
+ scantokens(tag & "italic") := s * scantokens(tag & "italic") ;
+ enddef ;
+
+ def ShiftGlyph(expr tag, dx, dy) =
+ scantokens(tag & "char") := scantokens(tag & "char") shifted (dx, dy) ;
+ scantokens(tag & "bbox") := scantokens(tag & "bbox") shifted (dx, dy) ;
+ scantokens(tag & "accent") := scantokens(tag & "accent") + dx ;
+ scantokens(tag & "italic") := scantokens(tag & "italic") + dx ;
+ enddef ;
+
+ def DrawGlyph(expr tag) =
+ draw scantokens(tag & "char") withpen pencircle scaled 1 ;
+ draw scantokens(tag & "bbox") withcolor "darkyellow" ;
+ draw (scantokens(tag & "accent"), (ypart urcorner scantokens(tag & "bbox"))) withcolor "darkmagenta" withpen pencircle scaled 5 ;
+ draw (scantokens(tag & "italic"), .5(ypart urcorner scantokens(tag & "bbox"))) withcolor "orange" withpen pencircle scaled 5 ;
+ enddef ;
+
+\stopMPdefinitions
+
+\startMPdefinitions
+
+ def ShowShape(expr font, slot) =
+ glyphshape_start(font, slot) ;
+ draw for i=1 upto glyphshape_n : glyphshape_path(i) && endfor cycle ;
+ draw glyphshape_boundingbox withcolor red ;
+ draw glyphshape_usedline withcolor green ;
+ draw glyphshape_usedbox withcolor blue ;
+ draw (glyphshape_accent,glyphshape_depth) withcolor "orange" withpen pencircle scaled 5 ;
+ draw (glyphshape_italic,glyphshape_depth) withcolor "orange" withpen pencircle scaled 5 ;
+ glyphshape_stop ;
+ enddef;
+
+\stopMPdefinitions