blob: f208c714900fe3c8c0affdd1bfee9f771dc4a890 (
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
|
%D \module
%D [ file=mp-txts.mp,
%D version=2006.06.08,
%D title=\CONTEXT\ \METAPOST\ graphics,
%D subtitle=more text support,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
if unknown context_tool : input mp-tool ; fi ;
if known context_txts : endinput ; fi ;
boolean context_txts ; context_txts := true ;
%D The real code:
string txtfile ; txtfile := "" ;
string txtfont ; txtfont := defaultfont ;
string txtpref ; txtpref := "00001::::" ;
numeric txtnext ; txtnext := 0 ;
numeric txtdepth ; txtdepth := 0 ;
vardef nexttxt =
txtnext := txtnext + 1 ;
txtnext
enddef ;
picture savedtxts[] ;
numeric depthtxts[] ;
vardef zerofilled(expr fd) =
if fd<10: "0000" else :
if fd<100: "000" else :
if fd<1000: "00" else :
if fd<10000: "0" else :
fi fi fi fi & decimal fd
enddef;
vardef savetxt(expr n,w,h,d) text t =
depthtxts[n] := d ;
savedtxts[n] := ((txtpref & zerofilled(n)) infont txtfont) xysized(w,h+d) t
enddef ;
vardef sometxt(expr n) =
if known savedtxts[n] :
txtdepth := depthtxts[n] ; savedtxts[n]
else :
txtdepth := 0 ; nullpicture
fi
enddef ;
def loadtxts =
if txtfile <> "" :
readfile(txtfile) ;
fi ;
enddef ;
def StartTexts =
loadtxts ;
enddef ;
def StopTexts =
enddef ;
|