Comments (6)
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](https://private-user-images.githubusercontent.com/399024/284852519-58ef38a4-87cd-430d-ac9a-98a53279b8e5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTU4MDY1NjEsIm5iZiI6MTcxNTgwNjI2MSwicGF0aCI6Ii8zOTkwMjQvMjg0ODUyNTE5LTU4ZWYzOGE0LTg3Y2QtNDMwZC1hYzlhLTk4YTUzMjc5YjhlNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNTE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDUxNVQyMDUxMDFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jNDNjYWE3ZDljMGNkNmFmYTg5YzNkOTJhYmRiMGRiNjlkNmQyMzMwMDE3YTdlNDNiMTI4N2Y5MzE5M2NhYTgxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.jpiOEyG2rIioFIP6wY_pQusJ5Gg-s9nNECBOHbZ9cEM)
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.
Hi-- do you get a better result if you use the fourth argument to draw-text
?
from draw.
Ah, I see you answered the question about draw-text
on discourse, that it doesn't help.
from draw.
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.
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.
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)
- get-recorded-procedure on record-dc seems to drop `set-clipping-rect`
- `draw-text` with `combine?` = `#t` missplaces diacritics. HOT 6
- Pango warning printed out in Racket 7.6 CS
- Is it possible to display bitmap in a loop? HOT 1
- [Feature Request] Add draw-circle and draw-square methods to dc<%> in racket/draw HOT 1
- Pango AppKit workaround for CS and/or Aarch64? HOT 1
- Should guard-foreign-escape use `#:callback-exns?`? HOT 1
- Emoji error when using macro stepper HOT 1
- A font% does not contain the leading
- Rotation and draw-text. HOT 7
- Rotating circles HOT 1
- memcpy given #<eof> in read-png-bytes HOT 3
- Possible bug? HOT 1
- get-text-extent errors for a bitmap-dc% object without a bitmap installed HOT 1
- Odd baseline for text drawn with `'swiss` on when that means Nimbus Sans HOT 1
- Bugs caused by internally constructed objects
- Internal error when getting pen% and brush% color
- [Feature Request] draw font% does not expose kerning
- manual class sections lack a <h3> title
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from draw.