main
Matthew Butterick 7 years ago
parent eb2a5715e2
commit 26e15f7d76

@ -28,7 +28,9 @@ https://github.com/mbutterick/fontkit/blob/master/src/opentype/GlyphInfo.js
[cursiveAttachment #f] [cursiveAttachment #f]
[markattachment #f] [markattachment #f]
[shaperInfo #f] [shaperInfo #f]
[substituted #f]) [substituted #f]
[isMark #f]
[isLigature #f])
(define/public (id [id-in #f]) (define/public (id [id-in #f])
(cond (cond

@ -1,15 +1,18 @@
PDFDocument = require 'pdfkit' PDFDocument = require 'pdfkit'
fs = require 'fs' fs = require 'fs'
# test ss03 (alternate ampersand form)
make = (doc) -> make = (doc) ->
# Register a font name for use later # Register a font name for use later
doc.registerFont('the-font', 'assets/fira.otf') doc.registerFont('the-font', 'assets/fira.ttf')
# Set the font, draw some text # Set the font, draw some text
doc.font('the-font') doc.font('the-font')
.fontSize(100) .fontSize(100)
.text('x', 100, 100, {width: false}) .text('A&B', 100, 100, {width: false})
.text('X&Y', 100, 200, {width: false, features: ["ss03"]})
doc.end() doc.end()

Binary file not shown.

@ -3,6 +3,8 @@
;; subset font with GPOS table ;; subset font with GPOS table
(define-runtime-path ttf-path "assets/fira.ttf") (define-runtime-path ttf-path "assets/fira.ttf")
; test ss03 (alternate ampersand form)
(define (proc doc) (define (proc doc)
;; Register a font name for use later ;; Register a font name for use later
(send doc registerFont "the-font" (path->string ttf-path)) (send doc registerFont "the-font" (path->string ttf-path))
@ -10,12 +12,13 @@
;; Set the font, draw some text ;; Set the font, draw some text
(send* doc (send* doc
[font "the-font"] [font "the-font"]
[fontSize 25] [fontSize 100]
[text "Hola Hola" 100 100 (hash 'width #f)])) [text "A&B" 100 100 (hash 'width #f)]
[text "X&Y" 100 200 (hash 'width #f 'features '(ss03))]))
;; test against non-subsetted font version ;; test against non-subsetted font version
(define-runtime-path this "test14rkt.pdf") (define-runtime-path this "test19rkt.pdf")
(make-doc this #f proc ) (make-doc this #f proc)
(define-runtime-path that "test14crkt.pdf") (define-runtime-path that "test19crkt.pdf")
(make-doc that #t proc #:pdfkit #f) (make-doc that #t proc #:pdfkit #f)

Loading…
Cancel
Save