Skip to content

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

@ceving

Description

@ceving

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions