main
Matthew Butterick 5 years ago
parent 07a470a0ac
commit 0672e129d1

@ -35,7 +35,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
[scale (/ 1000 (font-units-per-em font))]
[ascender (* (font-ascent font) scale)]
[descender (* (font-descent font) scale)]
[lineGap (* (font-linegap font) scale)]
[line-gap (* (font-linegap font) scale)]
[bbox (font-bbox font)])
(as-methods
@ -218,7 +218,7 @@ HERE
(check-equal? (send ef widthOfString "f" 1000) 321.0)
(check-equal? (· ef ascender) 980)
(check-equal? (· ef descender) -238)
(check-equal? (· ef lineGap) 0)
(check-equal? (· ef line-gap) 0)
(check-equal? (bbox->list (· ef bbox)) '(-161 -236 1193 963))
(define H-gid 41)
(check-equal? (· ef widths) (mhash 0 278))

@ -19,7 +19,7 @@
[ascender (· font ascender)]
[descender (· font descender)]
[bbox (· font bbox)]
[lineGap (· font lineGap)])
[line-gap (· font line-gap)])
(as-methods
embed
encode

@ -22,13 +22,13 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/mixins/text.coffee
(define (text-mixin [% mixin-tester%])
(class %
(super-new)
(field [_lineGap #f]
(field [_line-gap #f]
[_textOptions #f])
(as-methods
initText
_initOptions
lineGap
line-gap
moveDown
moveUp
_text
@ -40,19 +40,19 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/mixins/text.coffee
(->m void?)
(set-field! x this 0)
(set-field! y this 0)
(lineGap this 0)
(line-gap this 0)
(void))
(define/contract (lineGap this _lineGap)
(define/contract (line-gap this _line-gap)
(number? . ->m . object?)
(set-field! _lineGap this _lineGap)
(set-field! _line-gap this _line-gap)
this)
(define/contract (moveDown this [lines 1] #:factor [factor 1])
(() (number? #:factor number?) . ->*m . object?)
(increment-field! y this (* factor (send this currentLineHeight #t) (+ lines (· this _lineGap))))
(increment-field! y this (* factor (send this currentLineHeight #t) (+ lines (· this _line-gap))))
this)
@ -123,12 +123,12 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/mixins/text.coffee
(define/contract (_line this text [options (mhash)] [wrapper #f])
((string?) (hash? (or/c procedure? #f)) . ->*m . void?)
(send this _fragment text (· this x) (· this y) options)
(define lineGap (or (· options lineGap) (· this _lineGap) 0))
(define line-gap (or (· options line-gap) (· this _line-gap) 0))
;; 180325 suppress the size tracking: we'll do our own line measurement
;; 181120 unsuppress the size tracking for now because it breaks test 04
(if (not wrapper)
(increment-field! x this (send this widthOfString text))
(increment-field! y (+ (send this currentLineHeight #t) lineGap)))
(increment-field! y (+ (send this currentLineHeight #t) line-gap)))
(void))

@ -44,29 +44,29 @@
(send* doc [line-width 25])
;; line cap settings
(send* doc [lineCap 'butt]
(send* doc [line-cap 'butt]
[move-to 50 20]
[line-to 100 20]
[stroke]
[lineCap 'round]
[line-cap 'round]
[move-to 150 20]
[line-to 200 20]
[stroke])
;; square line cap shown with a circle instead of a line so you can see it
(send* doc [lineCap 'square]
(send* doc [line-cap 'square]
[move-to 250 20]
[circle 275 30 15]
[stroke])
;; line join settings
(send* doc [lineJoin 'miter]
(send* doc [line-join 'miter]
[rect 50 100 50 50]
[stroke]
[lineJoin 'round]
[line-join 'round]
[rect 150 100 50 50]
[stroke]
[lineJoin 'bevel]
[line-join 'bevel]
[rect 250 100 50 50]
[stroke]))

Loading…
Cancel
Save