1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16if known context_page : endinput ; fi ;
17
18boolean context_page ; context_page := true ;
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180def LoadPageState = enddef ;
181def SwapPageState = enddef ;
182
183
184
185
186
187
188
189
190LeftEdge := -4 ; Top := -40 ;
191LeftEdgeSeparator := -3 ; TopSeparator := -30 ;
192LeftMargin := -2 ; Header := -20 ;
193LeftMarginSeparator := -1 ; HeaderSeparator := -10 ;
194Text := 0 ; Text := 0 ;
195RightMarginSeparator := +1 ; FooterSeparator := +10 ;
196RightMargin := +2 ; Footer := +20 ;
197RightEdgeSeparator := +3 ; BottomSeparator := +30 ;
198RightEdge := +4 ; Bottom := +40 ;
199
200
201
202
203
204
205
206
207numeric HorPos ; HorPos := 0 ;
208numeric VerPos ; VerPos := 0 ;
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320def SetPageVsize =
321 numeric Vsize[] ;
322 Vsize[Top] = TopHeight ;
323 Vsize[TopSeparator] = TopDistance ;
324 Vsize[Header] = HeaderHeight ;
325 Vsize[HeaderSeparator] = HeaderDistance ;
326 Vsize[Text] = TextHeight ;
327 Vsize[FooterSeparator] = FooterDistance ;
328 Vsize[Footer] = FooterHeight ;
329 Vsize[BottomSeparator] = BottomDistance ;
330 Vsize[Bottom] = BottomHeight ;
331enddef ;
332
333def SetPageHsize =
334 numeric Hsize[] ;
335 Hsize[LeftEdge] = LeftEdgeWidth ;
336 Hsize[LeftEdgeSeparator] = LeftEdgeDistance ;
337 Hsize[LeftMargin] = LeftMarginWidth ;
338 Hsize[LeftMarginSeparator] = LeftMarginDistance ;
339 Hsize[Text] = MakeupWidth ;
340 Hsize[RightMarginSeparator] = RightMarginDistance ;
341 Hsize[RightMargin] = RightMarginWidth ;
342 Hsize[RightEdgeSeparator] = RightEdgeDistance ;
343 Hsize[RightEdge] = RightEdgeWidth ;
344enddef ;
345
346def SetPageVstep =
347 numeric Vstep[] ;
348 Vstep[Top] = Vstep[TopSeparator] Vsize[TopSeparator] ;
349 Vstep[TopSeparator] = PaperHeightTopSpace ;
350 Vstep[Header] = Vstep[TopSeparator] Vsize[Header] ;
351 Vstep[HeaderSeparator] = Vstep[Header] Vsize[HeaderSeparator] ;
352 Vstep[Text] = Vstep[HeaderSeparator]Vsize[Text] ;
353 Vstep[FooterSeparator] = Vstep[Text] Vsize[FooterSeparator] ;
354 Vstep[Footer] = Vstep[FooterSeparator]Vsize[Footer] ;
355 Vstep[BottomSeparator] = Vstep[Footer] Vsize[BottomSeparator] ;
356 Vstep[Bottom] = Vstep[BottomSeparator]Vsize[Bottom] ;
357enddef ;
358
359def SetPageHstep =
360 numeric Hstep[] ;
361 Hstep[LeftEdge] = Hstep[LeftEdgeSeparator] Hsize[LeftEdge] ;
362 Hstep[LeftEdgeSeparator] = Hstep[LeftMargin] Hsize[LeftEdgeSeparator] ;
363 Hstep[LeftMargin] = Hstep[LeftMarginSeparator] Hsize[LeftMargin] ;
364 Hstep[LeftMarginSeparator] = Hstep[Text] Hsize[LeftMarginSeparator] ;
365 Hstep[Text] = BackSpace ;
366 Hstep[RightMarginSeparator] = Hstep[Text] Hsize[Text] ;
367 Hstep[RightMargin] = Hstep[RightMarginSeparator]Hsize[RightMarginSeparator] ;
368 Hstep[RightEdgeSeparator] = Hstep[RightMargin] Hsize[RightMargin] ;
369 Hstep[RightEdge] = Hstep[RightEdgeSeparator] Hsize[RightEdgeSeparator] ;
370enddef ;
371
372def SetPageArea =
373 path Area[][] ;
374 for VerPos=Top step 10 until Bottom:
375 for HorPos=LeftEdge step 1 until RightEdge:
376 Area[HorPos][VerPos] := unitsquare xscaled Hsize[HorPos] yscaled Vsize[VerPos] ;
377 Area[VerPos][HorPos] := Area[HorPos][VerPos] ;
378 endfor ;
379 endfor ;
380enddef ;
381
382def SetPageLocation =
383 pair Location[][] ;
384 for VerPos=Top step 10 until Bottom:
385 for HorPos=LeftEdge step 1 until RightEdge:
386 Location[HorPos][VerPos] := (Hstep[HorPos],Vstep[VerPos]) ;
387 Location[VerPos][HorPos] := Location[HorPos][VerPos] ;
388 endfor ;
389 endfor ;
390enddef ;
391
392def SetPageField =
393 path Field[][] ;
394 for VerPos=Top step 10 until Bottom:
395 for HorPos=LeftEdge step 1 until RightEdge:
396 Field[HorPos][VerPos] := unitsquare xscaled Hsize[HorPos] yscaled Vsize[VerPos] shifted (Hstep[HorPos],Vstep[VerPos]) ;
397 Field[VerPos][HorPos] := Field[HorPos][VerPos] ;
398 endfor ;
399 endfor ;
400enddef ;
401
402def mfun_page_Area = hide(SetPageArea ;) Area enddef ;
403def mfun_page_Location = hide(SetPageLocation ;) Location enddef ;
404def mfun_page_Field = hide(SetPageField ;) Field enddef ;
405def mfun_page_Vsize = hide(SetPageVsize ;) Vsize enddef ;
406def mfun_page_Hsize = hide(SetPageHsize ;) Hsize enddef ;
407def mfun_page_Vstep = hide(SetPageVstep ;) Vstep enddef ;
408def mfun_page_Hstep = hide(SetPageHstep ;) Hstep enddef ;
409
410def SetAreaVariables =
411 let Area = mfun_page_Area ;
412 let Location = mfun_page_Location ;
413 let Field = mfun_page_Field ;
414 let Vsize = mfun_page_Vsize ;
415 let Hsize = mfun_page_Hsize ;
416 let Vstep = mfun_page_Vstep ;
417 let Hstep = mfun_page_Hstep ;
418enddef ;
419
420
421
422vardef FrontPageWidth = PaperWidth enddef ;
423vardef BackPageWidth = PaperWidth enddef ;
424vardef CoverWidth = 2 PaperWidth SpineWidth enddef ;
425vardef CoverHeight = PaperHeight enddef ;
426
427vardef FrontPageHeight = PaperHeight enddef ;
428vardef BackPageHeight = PaperHeight enddef ;
429vardef SpineHeight = PaperHeight enddef ;
430
431def SetPagePage = path Page ; Page := unitsquare xscaled PaperWidth yscaled PaperHeight ; enddef ;
432def SetPageCoverPage = path CoverPage ; CoverPage := unitsquare xscaled CoverWidth yscaled CoverHeight ; enddef ;
433def SetPageSpine = path Spine ; Spine := unitsquare xscaled SpineWidth yscaled CoverHeight shifted (BackPageWidth,0) ; enddef ;
434def SetPageBackPage = path BackPage ; BackPage := unitsquare xscaled BackPageWidth yscaled CoverHeight ; enddef ;
435def SetPageFrontPage = path FrontPage ; FrontPage := unitsquare xscaled FrontPageWidth yscaled CoverHeight shifted (BackPageWidthSpineWidth,0) ; enddef ;
436
437def mfun_page_Page = hide(SetPagePage ;) Page enddef ;
438def mfun_page_CoverPage = hide(SetPageCoverPage;) CoverPage enddef ;
439def mfun_page_Spine = hide(SetPageSpine ;) Spine enddef ;
440def mfun_page_BackPage = hide(SetPageBackPage ;) BackPage enddef ;
441def mfun_page_FrontPage = hide(SetPageFrontPage;) FrontPage enddef ;
442
443def SetPageVariables =
444 SetAreaVariables ;
445
446 let Page = mfun_page_Page ;
447 let CoverPage = mfun_page_CoverPage ;
448 let Spine = mfun_page_Spine ;
449 let BackPage = mfun_page_BackPage ;
450 let FrontPage = mfun_page_FrontPage ;
451enddef ;
452
453SetPageVariables ;
454
455let SetPageAreas = SetPageVariables ;
456
457def BoundPageAreas =
458
459 bboxmargin := 0 ; setbounds currentpicture to Page ;
460enddef ;
461
462def StartPage =
463 begingroup ;
464
465
466
467
468 SetPageVariables ;
469 BoundPageAreas ;
470enddef ;
471
472def StopPage =
473 BoundPageAreas ;
474 endgroup ;
475enddef ;
476
477
478
479def BoundCoverAreas =
480
481 bboxmargin := 0 ; setbounds currentpicture to CoverPage enlarged PaperBleed ;
482enddef ;
483
484let SetCoverAreas = SetPageVariables ;
485
486def StartCover =
487 begingroup ;
488
489
490
491 SetPageVariables ;
492 SetCoverAreas ;
493 BoundCoverAreas ;
494enddef ;
495
496def StopCover =
497 BoundCoverAreas ;
498 endgroup ;
499enddef ;
500
501
502
503def OverlayBox =
504 (unitsquare xyscaled (OverlayWidth,OverlayHeight))
505enddef ;
506
507def BoundToOverlayBox =
508 setbounds currentpicture to OverlayBox;
509enddef ;
510
511
512
513def innerenlarged =
514 hide(LoadPageState)
515 if OnRightPage : leftenlarged else : rightenlarged fi
516enddef ;
517
518def outerenlarged =
519 hide(LoadPageState)
520 if OnRightPage : rightenlarged else : leftenlarged fi
521enddef ;
522
523
524
525def llEnlarged (expr p,d) = (llcorner p shifted (d,d)) enddef ;
526def lrEnlarged (expr p,d) = (lrcorner p shifted (d,d)) enddef ;
527def urEnlarged (expr p,d) = (urcorner p shifted (d,d)) enddef ;
528def ulEnlarged (expr p,d) = (ulcorner p shifted (d,d)) enddef ;
529
530def Enlarged (expr p, d) =
531 (llEnlarged (p,d) --
532 lrEnlarged (p,d) --
533 urEnlarged (p,d) --
534 ulEnlarged (p,d) -- cycle)
535enddef ;
536
537
538
539string RuleDirection ; RuleDirection := "" ;
540string RuleOption ; RuleOption := "" ;
541numeric RuleWidth ; RuleWidth := 0 ;
542numeric RuleHeight ; RuleHeight := 0 ;
543numeric RuleDepth ; RuleDepth := 0 ;
544numeric RuleH ; RuleH := 0 ;
545numeric RuleV ; RuleV := 0 ;
546numeric RuleThickness ; RuleThickness := 0 ;
547numeric RuleFactor ; RuleFactor := 0 ;
548numeric RuleOffset ; RuleOffset := 0 ;
549 def RuleColor = (.5white) enddef ;
550
551def FakeWord(expr RuleWidth, RuleHeight, RuleDepth, RuleThickness) (text RuleColor) =
552 fill unitsquare
553 xscaled RuleWidth
554 yscaled (RuleDepthRuleThickness2)
555 withcolor RuleColor ;
556 fill unitsquare
557 xscaled RuleWidth
558 yscaled (RuleHeightRuleDepthRuleThickness2)
559 shifted (0,RuleDepthRuleThickness)
560 withcolor RuleColor ;
561enddef ;
562
563def FakeRule(expr RuleWidth, RuleHeight, RuleDepth, RuleThickness) (text RuleColor) =
564 fill unitsquare
565 xscaled RuleWidth
566 yscaled RuleHeight
567 withcolor RuleColor ;
568enddef ;
569 |