[cl-typesetting-devel] Reusing bits of code

Peter Seibel peter at gigamonkeys.com
Sat Jul 9 04:17:16 UTC 2005


On Jul 8, 2005, at 9:10 AM, Marc Battyani wrote:

> You can get the "natural" size on some text content with something  
> like
> that:
>
> (compute-boxes-natural-size
>    (boxes (compile-text ()
>           (with-style (:font "Times-Roman") "foo"))) #'dx)
> 15.996

Okay, more puzzles. Why does this function:

(defun measure-logo ()
   (let* ((big-font 48)
      (small-font 16)
      (extra-spacing 7)
      (content
       (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))))))))
     (values
      (typeset::compute-boxes-natural-size (boxes content)  
#'typeset::dx)
      (typeset::compute-boxes-natural-size (boxes content)  
#'typeset::dy))))

return

521.12006
823.6001

The logo is *not* bigger than a piece of 8.5x11 paper!

-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