more fallback work (addresses #6)

main
Matthew Butterick 6 years ago
parent b739ce847b
commit a1900aa5a1

@ -52,8 +52,6 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(efont
name id ascender descender upm line-gap bbox #f #f efont-embedded efont-encode efont-measure-string
font subset unicode widths scale encoding-cache))
(define (efont-measure-string ef str size [features null])
; #f disables features ; null enables default features ; list adds features
@ -66,7 +64,6 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(define width (for/sum ([p (in-vector posns)]) (glyph-position-x-advance p)))
(* width scale))
(define (efont-encode ef str [features-in null])
(define features (sort (remove-duplicates features-in) bytes<? #:key car))
(hash-ref! (efont-encoding-cache ef) (cons str features)
@ -85,7 +82,8 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
(vector-set! subset-idxs idx subset-idx)
(set-glyph-position-advance-width! posn (glyph-advance-width glyph))
(scale-glyph-position! posn (efont-scale ef))
;; next line commented out to make 2048 em work
#;(scale-glyph-position! posn (efont-scale ef))
(vector-set! new-positions idx posn)
(hash-ref! (efont-widths ef) gid (λ () (glyph-position-advance-width posn)))

@ -32,7 +32,7 @@
(define (line-height f size [include-gap #f])
(define gap (if include-gap (pdf-font-line-gap f) 0))
(* (/ (+ (pdf-font-ascender f) gap (- (pdf-font-descender f))) 1000.0) size))
(* (/ (+ (pdf-font-ascender f) gap (- (pdf-font-descender f))) (pdf-font-upm f)) size))
(define (open-pdf-font name id)
((if (standard-font-name? name) make-standard-font make-embedded-font) name id))

@ -48,7 +48,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/mixins/text.coffee
(define (add-text doc x y str features)
(match-define (list encoded-char-strs positions) (encode (pdf-current-font doc) str features))
(define scale (/ (pdf-current-font-size doc) 1000.0))
(define scale (/ (pdf-current-font-size doc) (pdf-font-upm (pdf-current-font doc))))
(define commands empty)
;; Adds a segment of text to the TJ command buffer

Loading…
Cancel
Save