1
2
3
4
5
6
7
8
9
10
11
12
13
14if known context_bare : endinput ; fi ;
15boolean context_bare ; context_bare := true ;
16
17vardef colordecimals primary c =
18 if cmykcolor c :
19 decimal cyanpart c & ":" & decimal magentapart c & ":" & decimal yellowpart c & ":" & decimal blackpart c
20 elseif rgbcolor c :
21 decimal redpart c & ":" & decimal greenpart c & ":" & decimal bluepart c
22 else :
23 decimal c
24 fi
25enddef ;
26
27rgbcolor mfun_tt_r ;
28numeric mfun_tt_n ; mfun_tt_n := 0 ;
29picture mfun_tt_o ; mfun_tt_o := nullpicture ;
30picture mfun_tt_c ; mfun_tt_c := nullpicture ;
31
32def mfun_reset_tex_texts =
33 mfun_tt_n := 0 ;
34 mfun_tt_o := nullpicture ;
35 mfun_tt_c := nullpicture ;
36enddef ;
37
38def mfun_flush_tex_texts =
39enddef ;
40
41vardef rawtextext(expr s) =
42 if s = "" :
43 nullpicture
44 else :
45 mfun_tt_n := mfun_tt_n 1 ;
46 mfun_tt_c := nullpicture ;
47 mfun_tt_o := nullpicture ;
48 addto mfun_tt_o doublepath origin _op_ ;
49 mfun_tt_r := runscript("mp.SomeText(" & decimal mfun_tt_n & "," & ditto & s & ditto & ")") ;
50 addto mfun_tt_c doublepath unitsquare
51 xscaled redpart mfun_tt_r
52 yscaled (greenpart mfun_tt_r bluepart mfun_tt_r)
53 shifted (0,bluepart mfun_tt_r)
54 withprescript "mf_object=text"
55 withprescript "tx_index=" & decimal mfun_tt_n
56 withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
57 ;
58 mfun_tt_c
59 fi
60enddef ;
61
62vardef rawmadetext =
63 mfun_tt_n := mfun_tt_n 1 ;
64 mfun_tt_c := nullpicture ;
65 mfun_tt_o := nullpicture ;
66 addto mfun_tt_o doublepath origin _op_ ;
67 mfun_tt_r := runscript("mp.MadeText(" & decimal mfun_tt_n & ")") ;
68 addto mfun_tt_c doublepath unitsquare
69 xscaled redpart mfun_tt_r
70 yscaled (greenpart mfun_tt_r bluepart mfun_tt_r)
71 shifted (0,bluepart mfun_tt_r)
72 withprescript "mf_object=text"
73 withprescript "tx_index=" & decimal mfun_tt_n
74 withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
75 ;
76 mfun_tt_c
77enddef ;
78
79extra_beginfig := extra_beginfig & "mfun_reset_tex_texts ;" ;
80extra_endfig := "mfun_flush_tex_texts ; mfun_reset_tex_texts ; " & extra_endfig ;
81
82primarydef str infont name =
83 if name = "" :
84 rawtextext(str)
85 else :
86 rawtextext("\definedfont[" & name & "]" & str)
87 fi
88enddef ;
89
90 |