[cl-typesetting-devel] A small layout glitch

Peter Seibel peter at javamonkey.com
Tue Feb 24 22:56:35 UTC 2004


Here's what seems to be a glitch in the layout that I observed in the
wild and reproduced in the lab. Certain (but not all) line breaks
following a semicolon end up with an extra bit of space at the
beginning of the following line. The function below demonstrates this.

-Peter

(defun weird-space-at-bol (&optional (file #P"/tmp/hello.pdf"))
  (let ((width 612)
        (height 792)
        (margins '(108 36 108 108))
        (header-height (- 108 36)))
    (pdf:with-document ()
      (let ((content (typeset::compile-text 
                      () 
                      (dotimes (i 20) 
                        (typeset::paragraph
                         (:h-align :left :font "Times-Roman" :font-size 12)
                         (typeset::vspace 12)
                         (dotimes (j 20)
                           (typeset::put-string 
                            (format nil "~d; The quick; brown; fox; jumps; over; the; lazy; dog; " j))))))))

        (loop for page-number from 1
            for header = (typeset::compile-text 
                          ()
                          (typeset::paragraph
                           (:h-align :right :font "Times-Roman" :font-size 12)
                           (typeset::put-string "HEADER") :eol))
            while (typeset::boxes content)
            do 
              (destructuring-bind (left &optional (top left) (right left) (bottom top)) margins
                (let ((x left)
                      (y (- height top))
                      (dx (- width left right))
                      (dy (- height top bottom)))
                  (pdf:with-page (:bounds (vector 0 0 width height))
                    (pdf:with-saved-state
                      (typeset::stroke (typeset::make-filled-vbox header dx header-height :top) x y))
                    (typeset::stroke (typeset::make-filled-vbox content  dx (- dy header-height) :top) x (- y header-height)))))))
      (pdf:write-document file))))


-- 
Peter Seibel                                      peter at javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp




More information about the cl-typesetting-devel mailing list