1
2
3
4
5
6
7
8
9
10
11
12
13
14\startMPdefinitions
15
16 def LoadGlyph(expr tag, filename, unicode) =
17 glyphshape_start(filename,unicode) ;
18 expandafter picture scantokens(tag & "char");
19 expandafter path scantokens(tag & "bbox") ;
20 expandafter numeric scantokens(tag & "accent") ;
21 expandafter numeric scantokens(tag & "italic") ;
22 scantokens(tag & "char") := image (draw for i=1 upto glyphshape_n : glyphshape_path(i) && endfor cycle ;) ;
23 scantokens(tag & "bbox") := glyphshape_usedbox ;
24 scantokens(tag & "accent") := glyphshape_accent ;
25 scantokens(tag & "italic") := xpart urcorner glyphshape_usedbox glyphshape_italic ;
26 glyphshape_stop ;
27 enddef ;
28
29 def ScaleGlyph(expr tag, s) =
30 scantokens(tag & "char") := scantokens(tag & "char") scaled s ;
31 scantokens(tag & "bbox") := scantokens(tag & "bbox") scaled s ;
32 scantokens(tag & "accent") := s scantokens(tag & "accent") ;
33 scantokens(tag & "italic") := s scantokens(tag & "italic") ;
34 enddef ;
35
36 def ShiftGlyph(expr tag, dx, dy) =
37 scantokens(tag & "char") := scantokens(tag & "char") shifted (dx, dy) ;
38 scantokens(tag & "bbox") := scantokens(tag & "bbox") shifted (dx, dy) ;
39 scantokens(tag & "accent") := scantokens(tag & "accent") dx ;
40 scantokens(tag & "italic") := scantokens(tag & "italic") dx ;
41 enddef ;
42
43 def DrawGlyph(expr tag) =
44 draw scantokens(tag & "char") withpen pencircle scaled 1 ;
45 draw scantokens(tag & "bbox") withcolor "darkyellow" ;
46 draw (scantokens(tag & "accent"), (ypart urcorner scantokens(tag & "bbox"))) withcolor "darkmagenta" withpen pencircle scaled 5 ;
47 draw (scantokens(tag & "italic"), .5(ypart urcorner scantokens(tag & "bbox"))) withcolor "orange" withpen pencircle scaled 5 ;
48 enddef ;
49
50\stopMPdefinitions
51
52\startMPdefinitions
53
54 def ShowShape(expr font, slot) =
55 glyphshape_start(font, slot) ;
56 draw for i=1 upto glyphshape_n : glyphshape_path(i) && endfor cycle ;
57 draw glyphshape_boundingbox withcolor red ;
58 draw glyphshape_usedline withcolor green ;
59 draw glyphshape_usedbox withcolor blue ;
60 draw (glyphshape_accent,glyphshape_depth) withcolor "orange" withpen pencircle scaled 5 ;
61 draw (glyphshape_italic,glyphshape_depth) withcolor "orange" withpen pencircle scaled 5 ;
62 glyphshape_stop ;
63 enddef;
64
65\stopMPdefinitions
66 |