From edi at agharta.de Mon Mar 19 00:46:57 2007 From: edi at agharta.de (Edi Weitz) Date: Mon, 19 Mar 2007 01:46:57 +0100 Subject: [cl-gd-announce] New release 0.5.3 (Was: Help with the multline text) In-Reply-To: (Andrei Stebakov's message of "Sun, 18 Mar 2007 19:20:52 -0400") References: Message-ID: On Sun, 18 Mar 2007 19:20:52 -0400, "Andrei Stebakov" wrote: > When I call it (get-bounding-rect "Some #\Newline text" "arial" 50) > I get an error: > > Type-error in KERNEL::OBJECT-NOT-TYPE-ERROR-HANDLER: Ah, yes, there was a bug in there. Thanks for the report. The new release should fix that. > (defun get-bounding-rect (text font font-size) > (with-image* (0 0) > (let ((rect (draw-freetype-string 0 0 text > :do-not-draw t > :font-name font > :angle 0 > :line-spacing 1.05d0 > :color (find-color 0 0 255 :resolve t) > :point-size font-size))) > (values (- (aref rect 2) (aref rect 0)) (- (aref rect 3) (aref rect > 5)) (aref rect 0) (aref rect 1) rect)))) Here's an easier version: (defun get-bounding-rect (text font font-size) (let ((rect (draw-freetype-string 0 0 text :do-not-draw t :font-name font :line-spacing 1.05d0 :point-size font-size))) (values (- (aref rect 2) (aref rect 0)) (- (aref rect 3) (aref rect 5)) (aref rect 0) (aref rect 1) rect))) > I think it doesn't like my :line-spacing 1.05d0 parameter. That wasn't really the problem (but it showed the symptoms). > Also I am not sure that I can provide a string with #Newline. You can't do it the way you did. There are basically two easy ways to do it in portable Common Lisp. Number one: (get-bounding-rect "Some text" "arial" 50) Number two: (get-bounding-rect #.(format nil "Some~%text") "arial" 50) Or use CL-INTERPOL: (get-bounding-rect #?"Some\ntext" "arial" 50) Cheers, Edi.