Menu

#499 text drawing functions ignore :start & :end parameters

lisp error
closed-fixed
clx (17)
5
2008-10-27
2008-10-11
No

DRAW-GLYPHS and DRAW-IMAGE-GLYPHS functions ingnore :start and :end parameters

Discussion

  • Drutsa Pavel

    Drutsa Pavel - 2008-10-11

    fix general_draw_text behavior

     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-11
    • summary: text drawing function ignore :start & :end parameters --> text drawing functions ignore :start & :end parameters
     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-11
    • assigned_to: haible --> sds
     
  • Sam Steingold

    Sam Steingold - 2008-10-12

    thanks for the patch.
    you are not testing whether the :start/:stop parameters are actually valid, aren't you?

     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-13

    I suppose that the :start and :end parameters are natural numbers.
    They will be truncated quiet up to the string length.

    That kind of other validity cheks will be suitable?

     
  • Sam Steingold

    Sam Steingold - 2008-10-13

    see test_vector_limits()

     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-13

    Attemt to use 'test_vector_limits'. Seems to work.

     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-23

    Somebody, look at my second patch, please.

     
  • Sam Steingold

    Sam Steingold - 2008-10-23

    looks good. now, we need a test case and the patch will be complete.

     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-27

    (require "clx")

    (defvar use-timeout 1)
    (defvar start-text 0)
    (defvar end-text 1)
    (defvar draw-message "Hello world! This is the start and end test")
    (defvar font)

    (defun draw-hello (drawable g-context x y text &key start end)
    (let ((draw-part (subseq text start end)))
    (xlib:draw-glyphs drawable g-context x y draw-part )
    )
    )

    (defun events (&rest event-data &key display
    event-key
    send-event-p
    window
    &allow-other-keys)
    (when (eq event-key :exposure)
    (let ((gc (xlib:create-gcontext :drawable window :foreground 0 :font font)))
    (draw-hello window gc 10 10 draw-message
    :start start-text :end end-text)
    (xlib:draw-glyphs window gc 10 30 draw-message
    :start start-text :end end-text)
    )
    )
    )

    (let* ((dpy (xlib:open-display ""))
    (top-win (xlib:create-window
    :parent (xlib:screen-root (first (xlib:display-roots dpy) ))
    :x 100 :y 100
    :width 250
    :height 250
    :bit-gravity :north-west
    :background 1617116666
    :event-mask (xlib:MAKE-EVENT-MASK :exposure)))
    (font (xlib:open-font dpy "fixed"))
    )
    (xlib:map-window top-win)
    (xlib:display-force-output dpy)

    (loop
    (xlib:process-event dpy :handler #'events :timeout use-timeout :discard-p t)
    (incf end-text)
    (if (> end-text (length draw-message)) (setf end-text 1))
    (xlib:clear-area top-win :exposures-p t)
    )
    )

     
  • Sam Steingold

    Sam Steingold - 2008-10-27

    thanks - next time please supply the test case in a form suitable for new-clx/test.tst

     
  • Sam Steingold

    Sam Steingold - 2008-10-27

    as indicated by this test, your patch does not work:

    (xlib:with-open-display (dpy)
    (let* ((top-win (xlib:create-window
    :parent (xlib:screen-root (first (xlib:display-roots dpy)))
    :x 300 :y 300 :width 300 :height 70
    :bit-gravity :north-west :background 1617116666
    :event-mask (xlib:make-event-mask :exposure)))
    (font (xlib:open-font dpy "fixed"))
    (timeout 0.1) (start 0) (end 1)
    (message "these three lines should grow together in sync")
    (m1 (make-array (length message) :element-type 'character
    :displaced-to (ext:string-concat #1="abazonk" message)
    :displaced-index-offset (length #1#))))
    (assert (string= message m1))
    (flet ((events (&rest event-data
    &key display event-key send-event-p window
    &allow-other-keys)
    (when (eq event-key :exposure)
    (let ((gc (xlib:create-gcontext
    :drawable window :foreground 0 :font font)))
    (xlib:draw-glyphs window gc 10 10
    (subseq message start end))
    (xlib:draw-glyphs window gc 10 30
    message :start start :end end)
    (xlib:draw-glyphs window gc 10 30
    m1 :start start :end end)
    ))))
    (xlib:map-window top-win)
    (xlib:display-force-output dpy)
    (loop
    (xlib:process-event dpy :handler #'events :timeout timeout :discard-p t)
    (incf end)
    (if (> end (length message)) (return))
    (xlib:clear-area top-win :exposures-p t)))))

    in fact, there is more bad :START/:END code in clx.f, I will fix it in a uniform way.

     
  • Sam Steingold

    Sam Steingold - 2008-10-27

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold

    Sam Steingold - 2008-10-27
    • status: open --> closed-fixed
     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-27

    The displased arrays it's an other history. It's too deep for me, now.

     
  • Sam Steingold

    Sam Steingold - 2008-10-27

    please test cvs head.
    thanks for your report and the excellent test case.

     
  • Drutsa Pavel

    Drutsa Pavel - 2008-10-27

    IMHO timeout = 0.1 secs it's too quickly, for understanding something I changed it to 0,5.

     

Log in to post a comment.