| 1 |
lars |
1 |
% $Header: /cvsroot/html2ps/postscript/box.inline.whitespace.ps,v 1.1 2005/12/18 07:21:36 Konstantin Exp $
|
|
|
2 |
|
|
|
3 |
% Whitespace flow control function. Do nothing if whitespace is at the beginning of the line box
|
|
|
4 |
% make a inline box containining space symbol otherwise.
|
|
|
5 |
/flow-whitespace { % => Parent Child
|
|
|
6 |
1 index get-current-x
|
|
|
7 |
2 index get-current-y % => Parent Child X Y
|
|
|
8 |
2 index
|
|
|
9 |
move-to-box % => Parent Child
|
|
|
10 |
|
|
|
11 |
% Check if there are any boxes in parent's line box
|
|
|
12 |
1 index
|
|
|
13 |
get-line
|
|
|
14 |
length 0 gt {
|
|
|
15 |
% there's some boxes in the parent's line box already
|
|
|
16 |
% just make a space (if previous inline box wasn't a whitespace!)
|
|
|
17 |
1 index get-line
|
|
|
18 |
dup length 1 sub get % => Parent Child LastInlineBox
|
|
|
19 |
|
|
|
20 |
get-box-dict
|
|
|
21 |
/Display get
|
|
|
22 |
/inline-whitespace ne {
|
|
|
23 |
dup get-default-baseline
|
|
|
24 |
1 index put-baseline
|
|
|
25 |
|
|
|
26 |
apply-line-height
|
|
|
27 |
|
|
|
28 |
dup get-vertical-align exec
|
|
|
29 |
|
|
|
30 |
dup /get-width call-method
|
|
|
31 |
2 index get-current-x
|
|
|
32 |
add
|
|
|
33 |
2 index put-current-x
|
|
|
34 |
} {
|
|
|
35 |
% Duplicate whitespace boxes should not offset further content and affect the line box length
|
|
|
36 |
|
|
|
37 |
% Make whitespace correctly aligned relative to the baseline
|
|
|
38 |
dup get-vertical-align exec
|
|
|
39 |
} ifelse
|
|
|
40 |
} {
|
|
|
41 |
% The very first whitespace in the line box should not affect neither height nor baseline of the line box;
|
|
|
42 |
% because following boxes can be smaller that assumed whitespace height
|
|
|
43 |
% Example: <br>[whitespace]<img height="2" width="2"><br>; whitespace can overextend this line
|
|
|
44 |
|
|
|
45 |
% Aslo, the very first whitespace should not offset further content and affect the line box length
|
|
|
46 |
|
|
|
47 |
} ifelse
|
|
|
48 |
|
|
|
49 |
dup 2 index append-line
|
|
|
50 |
|
|
|
51 |
% dup get-baseline
|
|
|
52 |
% 1 index get-default-baseline
|
|
|
53 |
% sub
|
|
|
54 |
% 1 index get-full-height
|
|
|
55 |
% add
|
|
|
56 |
dup get-full-height
|
|
|
57 |
exch pop
|
|
|
58 |
extend-height % => Parent
|
|
|
59 |
|
|
|
60 |
pop
|
|
|
61 |
} def
|
|
|
62 |
|
|
|
63 |
/make-whitespace-box { % => FontSize FontName
|
|
|
64 |
( )
|
|
|
65 |
2 index 2 index
|
|
|
66 |
make-text-box % => FontSize FontName Box
|
|
|
67 |
|
|
|
68 |
{flow-whitespace}
|
|
|
69 |
1 index put-flow-fun % => FontSize FontName Box
|
|
|
70 |
dup get-box-dict
|
|
|
71 |
/Display /inline-whitespace put
|
|
|
72 |
|
|
|
73 |
3 1 roll
|
|
|
74 |
pop pop
|
|
|
75 |
} def
|
|
|
76 |
|