Code Monkey home page Code Monkey logo

Comments (6)

rfindler avatar rfindler commented on August 19, 2024 1

I think that maybe 'grapheme was the wrong argument to pass. After reading the docs a bit more carefully, I think you want the below.

#lang racket
(require racket/gui/base)

(define str "World")
(define (draw c dc)
  (send dc set-font (send the-font-list find-or-create-font
                          128 "Times New Roman" 'roman 'normal 'normal))
  (define x 10)
  (define y 10)
  (define-values (w h d a)
    (send dc get-text-extent (string (string-ref str 0))))
  (send dc draw-rectangle x y w h)
  (send dc draw-text str x y #t))
(define f (new frame% [width 200] [height 200] [label ""]))
(define c (new canvas% [parent f] [paint-callback draw]))
(send f show #t)

Here is how it looks on my machine:

Screenshot 2023-11-22 at 3 20 31 AM

And if you change the #t to #f or 'grapheme, then you see something similar to your screenshot, where the right edge of the box around the "W" lines up with the left edge of the "o".

from draw.

rfindler avatar rfindler commented on August 19, 2024

Hi-- do you get a better result if you use the fourth argument to draw-text?

from draw.

rfindler avatar rfindler commented on August 19, 2024

Ah, I see you answered the question about draw-text on discourse, that it doesn't help.

from draw.

soegaard avatar soegaard commented on August 19, 2024

Is it possible to move the discussion back to Discourse until the source of the problem?
[Or at least reference this big report on Discourse]

from draw.

ceving avatar ceving commented on August 19, 2024

It seems to be the default to ignore the kerning. The documentation could be a bit more explicit, because at least I did not expect that ignoring the kerning might be a useful default. In particular because usually in Scheme an undefined value counts as a true value. But you are right: the behavior conforms to the documentation.

from draw.

rfindler avatar rfindler commented on August 19, 2024

Yeah, sometimes things get complicated due to backwards compatibility and decisions that were made decades ago that, in retrospect, might not be the best choices. Sorry it took you so much effort to get all this sorted out. Glad to see you're using racket and I hope you'll find it suitable for your larger project!

from draw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.