racket / racket/draw

Odd baseline for text drawn with `'swiss` on when that means Nimbus Sans

Open
#50 1 comment 0 reactions 0 assignees View on GitHub

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:
untitled

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:
untitled2

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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.