racket / racket/gui

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

Open
#81 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
68
Forks
82
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided Racket example, then inspect racket/draw/private/dc.rkt around the reported line and the bitmap-dc% documentation for the exception behavior. Confirm whether the documented get-text-extent exception is supported; done means the implementation and documentation agree and the example behaves accordingly.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.