| 1 |
lars |
1 |
% $Header: /cvsroot/html2ps/postscript/text-align.ps,v 1.1 2005/12/18 07:21:38 Konstantin Exp $
|
|
|
2 |
|
|
|
3 |
% Constants
|
|
|
4 |
/max-justify-fraction {0.33} def
|
|
|
5 |
|
|
|
6 |
/line-length-delta { % Context Box
|
|
|
7 |
dup line-length % Context Box LineLength
|
|
|
8 |
% calculate length line to be expanded
|
|
|
9 |
2 index 2 index
|
|
|
10 |
box-container-get-available-width
|
|
|
11 |
exch sub % Context Box Delta
|
|
|
12 |
% Quick workaround - line delta should not be less than 0
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
exch pop
|
|
|
16 |
exch pop
|
|
|
17 |
} def
|
|
|
18 |
|
|
|
19 |
/text-align-left { % => LastLine Context Box
|
|
|
20 |
pop pop pop
|
|
|
21 |
} def
|
|
|
22 |
|
|
|
23 |
/text-align-center { % => LastLine Context Box
|
|
|
24 |
2 copy line-length-delta % => LastLine Context Box Delta
|
|
|
25 |
2 div % => LastLine Context Box Delta/2
|
|
|
26 |
1 index get-line % => LastLine Context Box Delta/2 Line
|
|
|
27 |
{ % => LastLine Context Box Delta/2 LineElement
|
|
|
28 |
|
|
|
29 |
2 index exch % => LastLine Context Box Delta/2 0 Delta/2 LineElement
|
|
|
30 |
/offset call-method
|
|
|
31 |
} forall % => LastLine Context Box Delta/2
|
|
|
32 |
pop pop pop pop
|
|
|
33 |
} def
|
|
|
34 |
|
|
|
35 |
/text-align-right { % => LastLine Context Box
|
|
|
36 |
2 copy line-length-delta % => LastLine Context Box Delta
|
|
|
37 |
1 index get-line % => LastLine Context Box Delta Line
|
|
|
38 |
{ % => LastLine Context Box Delta LineElement
|
|
|
39 |
|
|
|
40 |
2 index exch % => LastLine Context Box Delta/2 Delta/2 0 LineElement
|
|
|
41 |
/offset call-method
|
|
|
42 |
} forall % => LastLine Context Box Delta/2
|
|
|
43 |
pop pop pop pop
|
|
|
44 |
} def
|
|
|
45 |
|
|
|
46 |
/text-align-justify { % => LastLine Context Box
|
|
|
47 |
% last line is never justified
|
|
|
48 |
2 index not { % => LastLine Context Box
|
|
|
49 |
|
|
|
50 |
% If line box contains less that two items, no justification can be done, just return
|
|
|
51 |
dup get-line length 2 ge { % => LastLine Context Box
|
|
|
52 |
|
|
|
53 |
% Calculate extra space to be filled by this line
|
|
|
54 |
2 copy line-length-delta % => LastLine Context Box Delta
|
|
|
55 |
|
|
|
56 |
% note that if it is the very first line inside the container, 'text-indent' value
|
|
|
57 |
% should not be taken into account while calculating delta value
|
|
|
58 |
1 index
|
|
|
59 |
box-container-get-first
|
|
|
60 |
get-uid % => LastLine Context Box Delta FirstUID
|
|
|
61 |
2 index get-line
|
|
|
62 |
|
|
|
63 |
eq { % => LastLine Context Box Delta
|
|
|
64 |
1 index box-generic-calc-text-indent
|
|
|
65 |
sub
|
|
|
66 |
} if % => LastLine Context Box Delta
|
|
|
67 |
|
|
|
68 |
% if line takes less that MAX_JUSTIFY_FRACTION of available space, no justtification should be done
|
|
|
69 |
1 index line-length
|
|
|
70 |
max-justify-fraction mul % => LastLine Context Box Delta LL*MJF
|
|
|
71 |
1 index ge { % => LastLine Context Box Delta
|
|
|
72 |
% Calculate offset for each box
|
|
|
73 |
dup
|
|
|
74 |
2 index get-line length
|
|
|
75 |
1 sub div % => LastLine Context Box Delta Offset
|
|
|
76 |
dup % => LastLine Context Box Delta Offset COffset
|
|
|
77 |
|
|
|
78 |
% Offset all boxes in current line box
|
|
|
79 |
3 index get-line { % => LastLine Context Box Delta Offset COffset Child
|
|
|
80 |
|
|
|
81 |
/offset call-method % => LastLine Context Box Delta Offset COffset Child
|
|
|
82 |
|
|
|
83 |
pop
|
|
|
84 |
1 index add % => LastLine Context Box Delta Offset COffset
|
|
|
85 |
} forall
|
|
|
86 |
|
|
|
87 |
pop pop % => LastLine Context Box Delta
|
|
|
88 |
} if
|
|
|
89 |
|
|
|
90 |
pop % => LastLine Context Box
|
|
|
91 |
} if
|
|
|
92 |
} if
|
|
|
93 |
|
|
|
94 |
pop pop pop
|
|
|
95 |
} def
|