Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-text-extent errors for a bitmap-dc% object without a bitmap installed #47

Closed
rymaju opened this issue May 6, 2022 · 1 comment
Closed

Comments

@rymaju
Copy link

rymaju commented May 6, 2022

Hi! 👋
Found an inconsistency with current behavior and the docs, thought it was worth making an issue.

Per the documentation at https://docs.racket-lang.org/draw/bitmap-dc_.html

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. If any other bitmap-dc% method is called before a bitmap is selected, the method call is ignored.

Also in the docs for get-text-extent

Unlike most methods, this method can be called for a bitmap-dc% object without a bitmap installed.

However, when I try:

(define text-size-dc-unset (new bitmap-dc%))
(send text-size-dc-unset get-text-extent "Pickles")

I get an error:

get-text-extent in dc<%>: drawing context is not ok: (wrapper-object:bitmap-dc% ...)

Which probably comes from here:

(check-ok 'get-text-extent)

The other two methods, get-char-width and get-char-height work fine, its just this one :/

I'm using Racket v8.4 on a MacBook Pro (2019).

@rymaju
Copy link
Author

rymaju commented May 7, 2022

After trying to patch this locally I was able to narrow it down it a little further. I took out the check-ok, which of course got rid of the error but led to some unsatisfactory results.

It looks like what I'm running into is that the cr used here

(if w
(values w h d a)
(with-unchanged-cr
(values 1.0 1.0 0.0 0.0)
cr
(do-text cr #f s 0 0 use-font combine? offset 0.0))))))
is #f when the bitmap is uninstalled, which causes the method to return 1 1 0 0.

Not exactly sure where to go from here, so thats where my exploration ends 😅 Hope that helps!

camoy added a commit to camoy/draw that referenced this issue May 7, 2022
camoy added a commit to camoy/draw that referenced this issue Jun 20, 2022
@mflatt mflatt closed this as completed in 7cfdea4 Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant