Spaces:
Sleeping
Sleeping
File size: 10,377 Bytes
07c3cdd | 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 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | % $Header: /cvsroot/html2ps/postscript/box.text.ps,v 1.1 2005/12/18 07:21:37 Konstantin Exp $
/box-text-create { % =>
box-generic-inline-create
% setup box-specific properties
dup /Text () put
dup /Encoding ISOLatin1Encoding put
% setup inherited method references
dup box-text-setup-methods
dup /box-text add-type
} def
/box-text-draw-overline { % => Text Box
newpath
% Get the thickness of the font underline
0
currentfont
font-underline-thick % => Text Box UThick
setlinewidth % => Text Box
% Get the position of the font underline
currentfont
font-overline-pos % => Text Box UPos
1 index get-left
2 index get-top
3 index get-default-baseline
sub % => Text Box UPos X Y'
% Note that UPos is negative
2 index add % => Text Box UPos X Y'
moveto
1 index /get-width call-method
0
rlineto
stroke % => Text Box UPos
pop pop pop
} def
/box-text-draw-line-through { % => Text Box
newpath
% Get the line thickness
0
currentfont
font-underline-thick % => Text Box UThick
setlinewidth % => Text Box
% Get the position of the font underline
currentfont
font-line-through-pos % => Text Box UPos
1 index get-left
2 index get-top
3 index get-default-baseline
sub % => Text Box UPos X Y'
% Note that UPos is negative
2 index add % => Text Box UPos X Y'
moveto
1 index /get-width call-method
0
rlineto
stroke % => Text Box UPos
pop pop pop
} def
/box-text-draw-underline { % => Text Box
newpath
% Get the line thickness
0
currentfont
font-underline-thick % => Text Box UThick
setlinewidth % => Text Box
% Get the position of the font underline
currentfont
font-underline-pos % => Text Box UPos
1 index get-left
2 index get-top
3 index get-default-baseline
sub % => Text Box UPos X Y'
% Note that UPos is negative
2 index add % => Text Box UPos X Y'
moveto
1 index /get-width call-method
0
rlineto
stroke % => Text Box UPos
pop pop pop
} def
/box-text-find-font { % => Box
dup /font-size get-css-value
1 index
/font-family get-css-value % => Box FontSize FontFamily
exch scalefont % => Box <<Font>>
exch pop % => <<Font>>
} def
/box-text-get-min-width { % => Context This
dup get-full-width
exch pop
exch pop
} def
/box-text-get-max-width { % => Context This
dup get-full-width
exch pop
exch pop
} def
/box-text-reflow { % => Context Parent This
% Check if we need a line break here (possilble several times in a row, if we
% have a long word and a floating box intersecting with this word
% To prevent infinite loop, we'll use a limit of 100 sequental line feeds
0 % => Content Parent This 0(LFs)
{
1 add % => Context Parent This LFs'
3 index
3 index
3 index
/maybe-line-break
call-method % => Context Parent This LFs Flag
1 index 100 ge
or {
exit
} if
} loop % => Context Parent This LFs
pop % => Context Parent This
% Determine the baseline position and height of the text-box using line-height CSS property
dup box-generic-apply-line-height
% set default baseline
dup get-default-baseline
1 index put-baseline
% append current box to parent line box
dup 2 index
box-container-append-line % => Context Parent This
% Determine coordinates of upper-left _margin_ corner
1 index 1 index
box-generic-guess-corner % => Context Parent This
% Offset parent current X coordinate
dup get-full-width
2 index get-current-x
add % => Context Parent This CX'
2 index put-current-x % => Context Parent This
% Extends parents height
dup get-bottom-margin % => Context Parent This BM
2 index
box-generic-extend-height % => Context Parent This
% Update the value of current collapsed margin; pure text (non-span)
% boxes always have zero margin
2 index context-pop-collapsed-margin
0 3 index context-push-collapsed-margin
% Clear the stack
pop pop pop
} def
/box-text-setup { % => Box
% select the font used to render current text box
dup box-text-find-font % => Box <<Font>>
dup font-ascender % => Box <<Font>> Ascender
1 index font-descender % => Box <<Font>> Ascender Descender
3 2 roll
setfont % => Box Ascender Descender
1 index 3 index put-default-baseline
add
% 1 index /font-size get-css-value min
1 index put-height % => Box
% determine the width of the current text box
dup get-text stringwidth % => Box SX __
pop % => Box SX
1 index put-width % => Box
pop
} def
/box-text-setup-methods { % => Box
% Setup method references
dup get-box-dict /Methods get % => Box Methods
dup /get-min-width {box-text-get-min-width} put
dup /get-max-width {box-text-get-max-width} put
dup /reflow {box-text-reflow} put
dup /show {box-text-show} put
pop pop
} def
/box-text-show { % => Viewport Box
% Check if current text box will be cut-off by the page edge
% Get Y coordinate of the top edge of the box
dup get-top-margin % => Viewport Box Top
% Get Y coordinate of the bottom edge of the box
1 index get-bottom-margin % => Viewport Box Top Bottom
1 index
4 index viewport-get-bottom
gt % => Viewport Box Top Bottom TopInside
1 index
5 index viewport-get-bottom
gt % => Viewport Box Top Bottom TopInside BottomInside
2 copy
not and % => Viewport Box Top Bottom TopInside BottomInside TopInside&&!BottomInside
{ % => Viewport Box Top Bottom TopInside BottomInside
% If yes, do not draw current text box at all; add an required value
% to the viewport page offset to make the text box fully visible on the next page
5 index
viewport-get-offset-delta % => Viewport Box Top Bottom TopInside BottomInside OD
4 index
7 index viewport-get-bottom
sub % => Viewport Box Top Bottom TopInside BottomInside OD ODNew
max % => Viewport Box Top Bottom TopInside BottomInside OD'
6 index
viewport-put-offset-delta % => Viewport Box Top Bottom TopInside BottomInside
pop pop
} { % => Viewport Box Top Bottom TopInside BottomInside
or not { % => Viewport Box Top Bottom
} { % => Viewport Box Top Bottom
% draw generic box
3 index 3 index
box-generic-show
2 index get-left
3 index get-top
4 index get-default-baseline
sub
moveto
2 index get-text % => Viewport Box Top Bottom Text
3 index
box-text-find-font % => Viewport Box Top Bottom Text <<Font>>
setfont
show % => Viewport Box Top Bottom
% draw text decoration
2 index /text-decoration get-css-value
3 index get-text % => Viewport Box Top Bottom Decoration Text
% underline
1 index /underline get { % => Viewport Box Top Bottom Decoration Text
dup
5 index % => Viewport Box Top Bottom Decoration Text Text Box
box-text-draw-underline % => Viewport Box Top Bottom Decoration Text
} if
% overline
1 index /overline get { % => Viewport Box Top Bottom Decoration Text
dup
5 index % => Viewport Box Top Bottom Decoration Text Text Box
box-text-draw-overline % => Viewport Box Top Bottom Decoration Text
} if
% line-through
1 index /line-through get { % => Viewport Box Top Bottom Decoration Text
dup
5 index % => Viewport Box Top Bottom Decoration Text Text Box
box-text-draw-line-through % => Viewport Box Top Bottom Decoration Text
} if
pop pop
} ifelse
} ifelse % => Viewport Box Top Bottom
pop pop pop pop
} def
/get-encoding {
/Encoding get
} def
/get-text { % => Box
/Text get
} def
/put-encoding { % => Encoding Box
exch
/Encoding
exch
put
} def
/put-text { % => Text Box
exch
/Text
exch
put
} def
%%%%%%%%%%%%%%%%%%%%
/show-enc-text-box {
% Check if this box will be cut on the bottom edge of the page (i.e. bottom < 0)
dup get-bottom bmargin gt {
show-enc-text-box-force
} {
% do not display this box; also, store the additional offset to show this text on the next page
/vdelta vdelta 2 index get-top bmargin sub max def
pop
} ifelse
} def
/show-enc-text-box-force { % => Box
show-generic-box % => Box
currentpoint
2 index get-content % => Box X Y Content
aload pop
show-enc-text
moveto
dup get-text-decoration % => Box Decor
dup /Underline known {
currentpoint
3 index get-content % => Box Decor X Y [Text <<Font>>]
aload pop pop
draw-underline
moveto
} if
dup /Overline known {
currentpoint
3 index get-content
aload pop pop
draw-overline
moveto
} if
dup /Line-Through known {
currentpoint
3 index get-content
aload pop pop
draw-line-through
moveto
} if
pop % => Box
} def
/show-enc-text { % => Text <<Font>>
setfont % => Text
show % =>
} def
|