gui icon indicating copy to clipboard operation
gui copied to clipboard

Unable to call get-text-extent on bitmap-dc

Open SimonLSchlee opened this issue 8 years ago • 0 comments

The documentation states that I should be able to call get-text-extent on a bitmap-dc without specifying a bitmap, but I get an error "drawing context is not ok".

#lang racket
;; Racket v6.10.1
 
(require racket/gui)
 
(define dummy-dc (new bitmap-dc%))

;; with a bitmap set it works
;; (define dummy-dc (new bitmap-dc% [bitmap (make-bitmap 1 1)]))
 
(define-values (width height delta-baseline vertical-space)
  (send dummy-dc get-text-extent "test text"))
 
(displayln width)

without a bitmap set I get:

get-text-extent in dc<%>: drawing context is not ok: (wrapper-object:bitmap-dc% ...)
context...:
/usr/share/racket/pkgs/draw-lib/racket/draw/private/dc.rkt:1341:4: core1416
...t/private/kw.rkt:763:9

although the documentation states: A bitmap% object must be supplied at initialization or installed into a bitmap DC using set-bitmap before any other method of the DC is called, except get-text-extent, get-char-height, or get-char-width.

SimonLSchlee avatar Oct 21 '17 21:10 SimonLSchlee