main
Matthew Butterick 6 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))] [scale (/ 1000 (font-units-per-em font))]
[ascender (* (font-ascent font) scale)] [ascender (* (font-ascent font) scale)]
[descender (* (font-descent font) scale)] [descender (* (font-descent font) scale)]
[lineGap (* (font-linegap font) scale)] [line-gap (* (font-linegap font) scale)]
[bbox (font-bbox font)]) [bbox (font-bbox font)])
(as-methods (as-methods
@ -218,7 +218,7 @@ HERE
(check-equal? (send ef widthOfString "f" 1000) 321.0) (check-equal? (send ef widthOfString "f" 1000) 321.0)
(check-equal? (· ef ascender) 980) (check-equal? (· ef ascender) 980)
(check-equal? (· ef descender) -238) (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)) (check-equal? (bbox->list (· ef bbox)) '(-161 -236 1193 963))
(define H-gid 41) (define H-gid 41)
(check-equal? (· ef widths) (mhash 0 278)) (check-equal? (· ef widths) (mhash 0 278))

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

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

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

Loading…
Cancel
Save