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

[Feature Request] draw font% does not expose kerning #56

Open
ceving opened this issue Nov 22, 2023 · 0 comments
Open

[Feature Request] draw font% does not expose kerning #56

ceving opened this issue Nov 22, 2023 · 0 comments

Comments

@ceving
Copy link

ceving commented Nov 22, 2023

Is your feature request related to a problem? Please describe.
It is not possible to draw the letters "V" and "A" correctly next to each other, because the library racket/draw does not expose the kerning table of a font.

Describe the solution you'd like
I would like to have a function, which returns the kerning similar to kerning-value of "sfont".

It would be nice to have a function, which calculates the kerning between two strings or characters. It seems to me that currently this is the only way to calculate the kerning between two strings:

#lang racket/gui

(define font (make-font #:size 16 #:face "Latin Modern Roman"))

(define frame (new frame% [label ""]))
(define canvas (new canvas% [parent frame]))

(define dc (send canvas get-dc))

(define left "A")
(define right "V")
(define both (string-append left right))

(define-values (left-text-width left-text-height left-baseline-height left-extra-height)
  (send dc get-text-extent left font #t))
(values left-text-width left-text-height left-baseline-height left-extra-height)
(printf "\n")

(define-values (right-text-width right-text-height right-baseline-height right-extra-height)
  (send dc get-text-extent right font #t))
(values right-text-width right-text-height right-baseline-height right-extra-height)
(printf "\n")

(define-values (both-text-width both-text-height both-baseline-height both-extra-height)
  (send dc get-text-extent both font #t))
(values both-text-width both-text-height both-baseline-height both-extra-height)
(printf "\n")

(- (+ left-text-width right-text-width)
   both-text-width)
@sorawee sorawee transferred this issue from racket/racket Nov 22, 2023
@ceving ceving changed the title [Feature Request] draw font% does not support kerning [Feature Request] draw font% does not expose kerning Nov 23, 2023
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