[cl-typesetting-devel] Reusing bits of code

Peter Seibel peter at gigamonkeys.com
Wed Jul 6 03:35:04 UTC 2005


I have some code that generates a logo using cl-typesetting. Now I'd  
like to generate documents that use that same logo in different  
places (and possibly even scaled). What's the best way to separate  
the code that sets the logo so I can reuse it in different contexts.  
FWIW, here's the function I used to genarate the logo:

(defun logo (&optional (file "/tmp/logo.pdf"))
   (let ((big-font 48)
     (small-font 16)
     (extra-spacing 7))

     (pdf:with-document ()
       (pdf:with-page (:bounds (vector 0 0 612 792))
     (let ((content
            (compile-text ()
          (with-style (:font "Didot-Bold" :font-size big-font)
            (put-string "gigamonkeys")) :eol
          (vspace -12)
          (hspace 69)
          (with-style (:font "Optima-Regular" :font-size small-font)
            (loop for char across "CONSULTING" do
             (put-string (string char))
             (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)))))))
       (typeset::draw-block content 100 (- 792 100) (- 612 (* 2 100))  
100 :v-align :fill :border nil)))
       (pdf:write-document file))))

-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