You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/fontkit/glyph-position.rkt

30 lines
1.2 KiB
Racket

#lang fontkit/racket
8 years ago
(provide (all-defined-out))
;; Represents positioning information for a glyph in a GlyphRun.
(define-subclass object% (GlyphPosition
;; The amount to move the virtual pen in the X direction after rendering this glyph.
[xAdvance 0]
;; The amount to move the virtual pen in the Y direction after rendering this glyph.
[yAdvance 0]
;; The offset from the pen position in the X direction at which to render this glyph.
[xOffset 0]
;; The offset from the pen position in the Y direction at which to render this glyph.
[yOffset 0]
[advanceWidth 0])
(as-methods
scale)
)
(define/contract (scale this factor)
(number? . ->m . (is-a?/c GlyphPosition))
(set-field! xAdvance this (* factor (· this xAdvance)))
(set-field! yAdvance this (* factor (· this yAdvance)))
(set-field! xOffset this (* factor (· this xOffset)))
(set-field! yOffset this (* factor (· this yOffset)))
(set-field! advanceWidth this (* factor (· this advanceWidth)))
this)