tests 20 & 21

main
Matthew Butterick 5 years ago
parent 5a10976df7
commit 8a693b30af

@ -6,10 +6,11 @@ fs = require 'fs'
make = (doc) ->
# Register a font name for use later
doc.registerFont('the-font', 'assets/fira.otf')
doc.registerFont('fira', 'assets/fira.otf')
doc.registerFont('charter', 'assets/charter.otf')
# Set the font, draw some text
doc.font('the-font')
doc.font('fira')
.fontSize(40)
.text('Fira OTF rifle fire', 100, 100, {width: false})
@ -20,7 +21,7 @@ doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test20.pdf'))
make doc
#doc = new PDFDocument({compress: yes})
#doc.pipe(fs.createWriteStream('test20c.pdf'))
#make doc
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test20c.pdf'))
make doc

Binary file not shown.

@ -2,22 +2,24 @@
(require pitfall/pdftest)
;; subset OTF font
(define-runtime-path otf-path "assets/fira.otf")
(define-runtime-path fira "assets/fira.otf")
(define-runtime-path charter "assets/charter.otf")
;; embed otf
(define (proc doc)
;; Register a font name for use later
(register-font doc "the-font" (path->string otf-path))
(register-font doc "fira" (path->string fira))
(register-font doc "charter" (path->string charter))
;; Set the font, draw some text
[font doc "the-font"]
[font doc "fira"]
[font-size doc 40]
[text doc "Fira OTF rifle fire" 100 100])
;; test against non-subsetted font version
(define-runtime-path this "test20rkt.pdf")
(make-doc this #f proc #:test #f)
(make-doc this #f proc)
#;(define-runtime-path that "test20crkt.pdf")
#;(make-doc that #t proc #:pdfkit #f)
(define-runtime-path that "test20crkt.pdf")
(make-doc that #t proc)

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,27 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# embed otf
make = (doc) ->
# Register a font name for use later
doc.registerFont('fira', 'assets/fira.otf')
doc.registerFont('charter', 'assets/charter.otf')
# Set the font, draw some text
doc.font('charter')
.fontSize(40)
.text('Charter OTF rifle fire', 100, 100, {width: false})
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test21.pdf'))
make doc
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test21c.pdf'))
make doc

Binary file not shown.

@ -0,0 +1,25 @@
#lang debug racket/base
(require pitfall/pdftest)
;; subset OTF font
(define-runtime-path fira "assets/fira.otf")
(define-runtime-path charter "assets/charter.otf")
;; embed otf
(define (proc doc)
;; Register a font name for use later
(register-font doc "fira" (path->string fira))
(register-font doc "charter" (path->string charter))
;; Set the font, draw some text
[font doc "fira"]
[font-size doc 40]
[text doc "Fira OTF rifle fire" 100 100])
;; test against non-subsetted font version
(define-runtime-path this "test20rkt.pdf")
(make-doc this #f proc)
(define-runtime-path that "test20crkt.pdf")
(make-doc that #t proc)

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save