[cl-gd-devel] Help with the multline text

Andrei Stebakov lispercat at gmail.com
Sun Mar 18 23:20:52 UTC 2007


I am trying to use draw-freetype-string to output the multiline text.
Here I go:

(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))))

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:
   #S(CL-GD::IMAGE
        :IMG #<Alien (* #) at #x00000000>) is not of type (OR NULL

SYSTEM:SYSTEM-AREA-POINTER
                                                              (ALIEN:ALIEN
                                                               (* #)))
   [Condition of type TYPE-ERROR]

Restarts:
 0: [ABORT] Return to SLIME's top level.
 1: [ABORT] Return to Top-Level.

Backtrace:
  0: (CL-GD::GD-IMAGE-STRING-FT-EX
      #S(CL-GD::IMAGE :IMG #<Alien # at #x00000000>)
      #<Alien (* #) at #x0808DF88>
      0
      "arial"
      ...)
  1: (DRAW-FREETYPE-STRING 0 0 "Some #Newline text" :ANTI-ALIASED ...)
  2: (GET-BOUNDING-RECT "Some #Newline text" "arial" 50)
  3: (GET-BOUNDING-RECT "Some #Newline text" "arial" 50)

I think it doesn't like my :line-spacing 1.05d0 parameter. Also I am not
sure that I can provide a string with #Newline. What's the proper way to do
it?

Thank you,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-gd-devel/attachments/20070318/b6cf0a63/attachment.html>


More information about the Cl-gd-devel mailing list