font-tracking attribute (fixes #29)

main
Matthew Butterick 5 years ago committed by GitHub
parent 3b3eac5c4b
commit 7ffa1a20aa

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -92,6 +92,7 @@
['emoji emoji-font-family]
['math math-font-family]
[_ fallback-font-family]))
(hash-set! new-attrs run-key (eq-hash-code new-attrs))
(font-path-resolver new-attrs)
new-attrs]))
(cons maybe-fallback-attrs str))]))))

@ -572,6 +572,10 @@ Whether the quad has bold styling applied. Activated only when value is @racket[
Whether the quad has italic styling applied. Activated only when value is @racket["true"].
}
@defthing[#:kind "attribute" font-tracking symbol?]{
Spacing between characters. Value is given as a @tech{dimension string}.
}
@defthing[#:kind "attribute" line-height symbol?]{
Distance between baselines. Value is a @tech{dimension string}.
}

@ -69,7 +69,7 @@ Naming guidelines
font-features
font-italic
font-bold
character-tracking
font-tracking
bg
link
href

@ -25,7 +25,7 @@
(define str (unsafe-car (quad-elems q)))
(match-define (list x y) (quad-origin q))
(text doc str x y
#:tracking (quad-ref q :character-tracking 0)
#:tracking (quad-ref q :font-tracking 0)
#:bg (quad-ref q :bg)
#:features (quad-ref q :font-features default-font-features)
#:link (quad-ref q :link))))
@ -64,9 +64,11 @@
[str
(font-size pdf (quad-ref q :font-size default-font-size))
(font pdf (path->string (quad-ref q font-path-key default-font-face)))
(+ (string-width pdf str
#:tracking (quad-ref q :character-tracking 0)
#:features (quad-ref q :font-features default-font-features)))]
(if (equal? str "\u00AD")
(quad-ref q :font-tracking 0)
(+ (string-width pdf str
#:tracking (quad-ref q :font-tracking 0)
#:features (quad-ref q :font-features default-font-features))))]
[else 0]))
(list string-size (quad-ref q :line-height (current-line-height pdf)))))
@ -75,12 +77,12 @@
[(? line-break-quad?) q]
[_
(struct-copy
quad q:string
[attrs (let ([attrs (quad-attrs q)])
string-quad q:string
[attrs #:parent quad (let ([attrs (quad-attrs q)])
(hash-ref! attrs :font-size default-font-size)
attrs)]
[elems (quad-elems q)]
[size (make-size-promise q)])]))
[elems #:parent quad (quad-elems q)]
[size #:parent quad (make-size-promise q)])]))
(define (draw-debug q doc [fill-color "#f99"] [stroke-color "#fcc"] [stroke-width 0.5])

@ -21,7 +21,6 @@
:keep-first-lines "2"
:keep-last-lines "3"
:font-size-adjust "100%"
:character-tracking "0"
:hyphenate "true"
:display (symbol->string (gensym)))
attrs) exprs))

Loading…
Cancel
Save