[racket-dev] draw-text always pixel aligned?

From: David Vanderson (david.vanderson at gmail.com)
Date: Mon Dec 16 01:28:23 EST 2013

Hello,

It seems that draw-text always pixel-aligns its text. In the example 
below, I draw a black "hello" on top of a red one, with a pixel offset 
of 0, 0.1, 0.2, . . . 0.9. At least for me, I see no change until 0.5, 
where the black text jumps a whole pixel (see attached image).

Am I missing something? Do others see this behavior?  (I'm on Linux)

Thanks,
Dave


#lang racket/gui

(define (draw-text dc offset)
   (send dc set-text-foreground "red")
   (send dc draw-text "hello" 0 0 #t)
   (send dc set-text-foreground "black")
   (send dc draw-text "hello" offset offset #t))

(define (draw-screen canvas dc)
   (send dc set-smoothing 'smoothed)
   (send dc set-font
         (send the-font-list find-or-create-font
               12 'default 'normal 'normal #f 'smoothed #f 'aligned))
   (send dc set-initial-matrix (vector 1 0 0 1 0 0))
   (for ((i 10))
     (draw-text dc (/ i 10.0))
     (send dc translate 50 0)))

(define frame (new frame% (label "Test draw-text")))

(define canvas
   (new canvas%
        (parent frame)
        (min-width 500)
        (min-height 100)
        (paint-callback draw-screen)))

(send frame show #t)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: draw-text2.png
Type: image/png
Size: 6283 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20131216/3ec15bca/attachment-0001.png>

Posted on the dev mailing list.