1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17if known metafun_loaded_page : endinput ; fi ;
18
19newinternal boolean metafun_loaded_page ; metafun_loaded_page := true ; immutable metafun_loaded_page ;
20
21def LoadPageState = enddef ;
22
23
24
25
26
27LeftEdge := -4 ; Top := -40 ;
28LeftEdgeSeparator := -3 ; TopSeparator := -30 ;
29LeftMargin := -2 ; Header := -20 ;
30LeftMarginSeparator := -1 ; HeaderSeparator := -10 ;
31Text := 0 ; Text := 0 ;
32RightMarginSeparator := +1 ; FooterSeparator := +10 ;
33RightMargin := +2 ; Footer := +20 ;
34RightEdgeSeparator := +3 ; BottomSeparator := +30 ;
35RightEdge := +4 ; Bottom := +40 ;
36
37numeric HorPos ; HorPos := 0 ;
38numeric VerPos ; VerPos := 0 ;
39
40immutable
41 Text, HorPos, VerPos,
42 LeftEdge, LeftEdgeSeparator, LeftMargin, LeftMarginSeparator,
43 RightMarginSeparator, RightMargin, RightEdgeSeparator, RightEdge,
44 Top, TopSeparator, Header, HeaderSeparator,
45 FooterSeparator, Footer, BottomSeparator, Bottom ;
46
47
48
49
50
51
52
53
54
55path mfun_page_area[][] ;
56pair mfun_page_location[][] ;
57path mfun_page_field[][] ;
58numeric mfun_page_vsize[] ;
59numeric mfun_page_hsize[] ;
60numeric mfun_page_vstep[] ;
61numeric mfun_page_hstep[] ;
62
63newinternal mfun_page_done ; mfun_page_done := 0 ;
64
65def mfun_page_check_vsize =
66 mfun_page_vsize[Top] := TopHeight ;
67 mfun_page_vsize[TopSeparator] := TopDistance ;
68 mfun_page_vsize[Header] := HeaderHeight ;
69 mfun_page_vsize[HeaderSeparator] := HeaderDistance ;
70 mfun_page_vsize[Text] := TextHeight ;
71 mfun_page_vsize[FooterSeparator] := FooterDistance ;
72 mfun_page_vsize[Footer] := FooterHeight ;
73 mfun_page_vsize[BottomSeparator] := BottomDistance ;
74 mfun_page_vsize[Bottom] := BottomHeight ;
75enddef ;
76
77def mfun_page_check_hsize =
78 mfun_page_hsize[LeftEdge] := LeftEdgeWidth ;
79 mfun_page_hsize[LeftEdgeSeparator] := LeftEdgeDistance ;
80 mfun_page_hsize[LeftMargin] := LeftMarginWidth ;
81 mfun_page_hsize[LeftMarginSeparator] := LeftMarginDistance ;
82 mfun_page_hsize[Text] := MakeupWidth ;
83 mfun_page_hsize[RightMarginSeparator] := RightMarginDistance ;
84 mfun_page_hsize[RightMargin] := RightMarginWidth ;
85 mfun_page_hsize[RightEdgeSeparator] := RightEdgeDistance ;
86 mfun_page_hsize[RightEdge] := RightEdgeWidth ;
87enddef ;
88
89def mfun_page_check_vstep =
90 mfun_page_vstep[TopSeparator] := PaperHeightTopSpace ;
91 mfun_page_vstep[Top] := mfun_page_vstep[TopSeparator] mfun_page_vsize[TopSeparator] ;
92 mfun_page_vstep[Header] := mfun_page_vstep[TopSeparator] mfun_page_vsize[Header] ;
93 mfun_page_vstep[HeaderSeparator] := mfun_page_vstep[Header] mfun_page_vsize[HeaderSeparator] ;
94 mfun_page_vstep[Text] := mfun_page_vstep[HeaderSeparator]mfun_page_vsize[Text] ;
95 mfun_page_vstep[FooterSeparator] := mfun_page_vstep[Text] mfun_page_vsize[FooterSeparator] ;
96 mfun_page_vstep[Footer] := mfun_page_vstep[FooterSeparator]mfun_page_vsize[Footer] ;
97 mfun_page_vstep[BottomSeparator] := mfun_page_vstep[Footer] mfun_page_vsize[BottomSeparator] ;
98 mfun_page_vstep[Bottom] := mfun_page_vstep[BottomSeparator]mfun_page_vsize[Bottom] ;
99enddef ;
100
101def mfun_page_check_hstep =
102 mfun_page_hstep[Text] := BackSpace ;
103 mfun_page_hstep[LeftMarginSeparator] := mfun_page_hstep[Text] mfun_page_hsize[LeftMarginSeparator] ;
104 mfun_page_hstep[RightMarginSeparator] := mfun_page_hstep[Text] mfun_page_hsize[Text] ;
105 mfun_page_hstep[LeftMargin] := mfun_page_hstep[LeftMarginSeparator] mfun_page_hsize[LeftMargin] ;
106 mfun_page_hstep[RightMargin] := mfun_page_hstep[RightMarginSeparator]mfun_page_hsize[RightMarginSeparator] ;
107 mfun_page_hstep[LeftEdgeSeparator] := mfun_page_hstep[LeftMargin] mfun_page_hsize[LeftEdgeSeparator] ;
108 mfun_page_hstep[LeftEdge] := mfun_page_hstep[LeftEdgeSeparator] mfun_page_hsize[LeftEdge] ;
109 mfun_page_hstep[RightEdgeSeparator] := mfun_page_hstep[RightMargin] mfun_page_hsize[RightMargin] ;
110 mfun_page_hstep[RightEdge] := mfun_page_hstep[RightEdgeSeparator] mfun_page_hsize[RightEdgeSeparator] ;
111enddef ;
112
113def mfun_check_page_dimensions =
114 if mfun_page_done <> RealPageNumber :
115 if LayoutHasChanged :
116 mfun_page_check_vsize ;
117 mfun_page_check_hsize ;
118 mfun_page_check_vstep ;
119 mfun_page_check_hstep ;
120 fi ;
121 mfun_page_done := RealPageNumber ;
122 fi ;
123enddef;
124
125
126def mfun_check_page_area =
127 mfun_check_page_dimensions ;
128 for VerPos=Top step 10 until Bottom:
129 for HorPos=LeftEdge step 1 until RightEdge:
130 mfun_page_area[HorPos][VerPos] := unitsquare xscaled mfun_page_hsize[HorPos] yscaled mfun_page_vsize[VerPos] ;
131 mfun_page_area[VerPos][HorPos] := mfun_page_area[HorPos][VerPos] ;
132 endfor ;
133 endfor ;
134enddef ;
135
136def mfun_check_page_location =
137 mfun_check_page_dimensions ;
138 for VerPos=Top step 10 until Bottom:
139 for HorPos=LeftEdge step 1 until RightEdge:
140 mfun_page_location[HorPos][VerPos] := (mfun_page_hstep[HorPos],mfun_page_vstep[VerPos]) ;
141 mfun_page_location[VerPos][HorPos] := mfun_page_location[HorPos][VerPos] ;
142 endfor ;
143 endfor ;
144enddef ;
145
146def mfun_check_page_field =
147 mfun_check_page_dimensions ;
148 for VerPos=Top step 10 until Bottom:
149 for HorPos=LeftEdge step 1 until RightEdge:
150 mfun_page_field[HorPos][VerPos] := unitsquare xscaled mfun_page_hsize[HorPos] yscaled mfun_page_vsize[VerPos] shifted (mfun_page_hstep[HorPos],mfun_page_vstep[VerPos]) ;
151 mfun_page_field[VerPos][HorPos] := mfun_page_field[HorPos][VerPos] ;
152 endfor ;
153 endfor ;
154enddef ;
155
156def Area = hide(mfun_check_page_area ;) mfun_page_area enddef ;
157def Location = hide(mfun_check_page_location ;) mfun_page_location enddef ;
158def Field = hide(mfun_check_page_field ;) mfun_page_field enddef ;
159def Vsize = hide(mfun_check_page_dimensions ;) mfun_page_vsize enddef ;
160def Hsize = hide(mfun_check_page_dimensions ;) mfun_page_hsize enddef ;
161def Vstep = hide(mfun_check_page_dimensions ;) mfun_page_vstep enddef ;
162def Hstep = hide(mfun_check_page_dimensions ;) mfun_page_hstep enddef ;
163
164immutable
165 Area, Location, Field, Vsize, Hsize, Vstep, Hstep ;
166
167vardef FrontPageWidth = PaperWidth enddef ;
168vardef BackPageWidth = PaperWidth enddef ;
169vardef CoverWidth = 2 PaperWidth SpineWidth enddef ;
170vardef CoverHeight = PaperHeight enddef ;
171
172vardef FrontPageHeight = PaperHeight enddef ;
173vardef BackPageHeight = PaperHeight enddef ;
174vardef SpineHeight = PaperHeight enddef ;
175
176path mfun_page_page, mfun_page_cover, mfun_page_spine, mfun_page_back, mfun_page_front ;
177
178def mfun_check_page = mfun_page_page := unitsquare xscaled PaperWidth yscaled PaperHeight ; enddef ;
179def mfun_check_cover = mfun_page_cover := unitsquare xscaled CoverWidth yscaled CoverHeight ; enddef ;
180def mfun_check_spine = mfun_page_spine := unitsquare xscaled SpineWidth yscaled CoverHeight shifted (BackPageWidth,0) ; enddef ;
181def mfun_check_back = mfun_page_back := unitsquare xscaled BackPageWidth yscaled CoverHeight ; enddef ;
182def mfun_check_front = mfun_page_front := unitsquare xscaled FrontPageWidth yscaled CoverHeight shifted (BackPageWidthSpineWidth,0) ; enddef ;
183
184def Page = hide(mfun_check_page ;) mfun_page_page enddef ;
185def CoverPage = hide(mfun_check_cover ;) mfun_page_cover enddef ;
186def Spine = hide(mfun_check_spine ;) mfun_page_spine enddef ;
187def BackPage = hide(mfun_check_back ;) mfun_page_back enddef ;
188def FrontPage = hide(mfun_check_front ;) mfun_page_front enddef ;
189
190
191
192def StartPage =
193 begingroup ;
194 setbounds currentpicture to Page ;
195enddef ;
196
197def StopPage =
198 setbounds currentpicture to Page ;
199 endgroup ;
200enddef ;
201
202
203
204def StartCover =
205 begingroup ;
206 setbounds currentpicture to CoverPage enlarged PaperBleed ;
207enddef ;
208
209def StopCover =
210 setbounds currentpicture to CoverPage enlarged PaperBleed ;
211 endgroup ;
212enddef ;
213
214immutable
215 FrontPageWidth, BackPageWidth, CoverWidth, FrontPageHeight, BackPageHeight, CoverHeight,
216 SpineHeight, Page, CoverPage, Spine, BackPage, FrontPage,
217 StartPage, StopPage, StartCover, StopCover ;
218
219
220
221def OverlayBox =
222 (unitsquare xyscaled (OverlayWidth,OverlayHeight))
223enddef ;
224
225def BoundToOverlayBox =
226 setbounds currentpicture to OverlayBox;
227enddef ;
228
229immutable
230 OverlayBox ;
231
232permanent
233 BoundToOverlayBox ;
234
235
236
237def innerenlarged =
238 if OnRightPage : leftenlarged else : rightenlarged fi
239enddef ;
240
241def outerenlarged =
242 if OnRightPage : rightenlarged else : leftenlarged fi
243enddef ;
244
245permanent
246 innerenlarged, outerenlarged ;
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267string RuleDirection ; RuleDirection := "" ;
268string RuleOption ; RuleOption := "" ;
269numeric RuleWidth ; RuleWidth := 0 ;
270numeric RuleHeight ; RuleHeight := 0 ;
271numeric RuleDepth ; RuleDepth := 0 ;
272numeric RuleH ; RuleH := 0 ;
273numeric RuleV ; RuleV := 0 ;
274numeric RuleThickness ; RuleThickness := 0 ;
275numeric RuleFactor ; RuleFactor := 0 ;
276numeric RuleOffset ; RuleOffset := 0 ;
277 def RuleColor = (.5white) enddef ;
278
279def FakeWord(expr RuleWidth, RuleHeight, RuleDepth, RuleThickness) (text RuleColor) =
280 fill unitsquare
281 xscaled RuleWidth
282 yscaled (RuleDepthRuleThickness2)
283 withcolor RuleColor ;
284 fill unitsquare
285 xscaled RuleWidth
286 yscaled (RuleHeightRuleDepthRuleThickness2)
287 shifted (0,RuleDepthRuleThickness)
288 withcolor RuleColor ;
289enddef ;
290
291def FakeRule(expr RuleWidth, RuleHeight, RuleDepth, RuleThickness) (text RuleColor) =
292 fill unitsquare
293 xscaled RuleWidth
294 yscaled RuleHeight
295 withcolor RuleColor ;
296enddef ;
297
298mutable
299 RuleDirection, RuleOption, RuleWidth, RuleHeight, RuleDepth, RuleH, RuleV, RuleThickness,
300 RuleFactor, RuleOffset, RuleColor;
301
302permanent
303 FakeWord, FakeRule ;
304 |