Odd baseline for text drawn with `'swiss` on when that means Nimbus Sans
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 19
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
When I render the following 2htdp/image expression:
(overlay (text "3" 120 "yellow") (square 120 "solid" "dark brown"))
I get a picture that looks like this:

Note that it's not centered. If an actual Helvetica font is used, it produces a centered 3. Also if I use some other font like 'default, it works correctly:

To understand why, consider this program:
(require racket/draw)
(define text-sizing-bm (make-object bitmap-dc% (make-object bitmap% 1 1)))
(define ft (send the-font-list find-or-create-font 120 'swiss 'normal 'normal #f 'default #t))
(send text-sizing-bm get-text-extent "3" ft)
This produces (values 67.0 121.0 33.0 0.0) on my machine but (values 67.0 139.0 27.0 0.0) on a different machine (thanks @ccshan) with Helvetica installed.
It's not clear to me what the bug is here but the drawing definitely seems wrong.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the 2htdp/image expression and the racket/draw get-text-extent call shown in the issue on systems with and without Helvetica. Inspect how 'swiss maps to a font and how its metrics are used for placement. Done means the rendered text is centered consistently and the relevant font-metric behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100