[cl-typesetting-devel] More chaos

Peter Seibel peter at gigamonkeys.com
Sat Jul 9 03:42:35 UTC 2005


So, I'm playing around with user-drawn-box. Seems like what I want.  
But I'm getting some strange behavior. Here's some sample code:

(defun user-drawn-logo (box x y)
   (let* ((big-font 48)
      (small-font 16)
      (extra-spacing 7))
     (pdf:with-saved-state
       (pdf:translate x y)
       (pdf:scale (/ (typeset::dx box) 290) (/ (typeset::dy box) 80))
       (draw-block
        (compile-text ()
      (with-style (:font "Didot-Bold" :font-size big-font) (put- 
string "gigamonkeys")) :eol
      (vspace -2)
      (hspace 69)
      (with-style (:font "Optima-Regular" :font-size small-font)
        (loop for char across "CONSULTING" do
         (put-string (string char))
         (unless (char= char #\G)
           (typeset::add-box
            (make-instance 'typeset::h-spacing
                   :dx extra-spacing
                   :max-expansion extra-spacing
                   :max-compression extra-spacing
                   :expansibility 1.0
                   :compressibility 1.0))))))
        0 0 290 80 :border 0.1))))

(defun foo-logo (&optional (file "/tmp/logo.pdf"))
   (pdf:with-document ()
     (pdf:with-page (:bounds (vector 0 0 612 792))
       (draw-block
        (compile-text ()
      (user-drawn-box :dx 290 :dy 80 :stroke-fn 'user-drawn-logo)
      (user-drawn-box :dx 290/2 :dy 80/2 :stroke-fn 'user-drawn-logo))
        100 692 412 100))
     (pdf:write-document file)))

I'd expect this to draw a page with two copies of the logo, one full  
size and one half size. But it doesn't. And stranger yet, if I (trace  
user-drawn-logo) I only see it getting called once. *But* if I change  
the :dx and :dy arguments in the first call to user-drawn-box to  
290/2 and 80/2, then it gets called twice and I get two half-size  
logos. What's up with that?

Another odditity is that in user-drawn-logo I had to change the  
argument to the VSPACE call after I set "gigamonkeys" to -2 rather  
than -12 as it was in my old code, to get the "CONSULTING" to come  
out in the right place. Any ideas why that might be?

-Peter

-- 
Peter Seibel           * peter at gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/





More information about the cl-typesetting-devel mailing list