diff --git a/pitfall/ptest/all.rkt b/pitfall/ptest/all.rkt index ac524898..437e85c5 100644 --- a/pitfall/ptest/all.rkt +++ b/pitfall/ptest/all.rkt @@ -1,5 +1,5 @@ #lang racket -(for ([i (in-range 24)]) +(for ([i (in-range 25)]) (define which (string->symbol (format "ptest/test~a" i))) (println which) (dynamic-require which #f)) diff --git a/pitfall/ptest/assets/sarabun.ttf b/pitfall/ptest/assets/sarabun.ttf new file mode 100644 index 00000000..c4defb01 Binary files /dev/null and b/pitfall/ptest/assets/sarabun.ttf differ diff --git a/pitfall/ptest/test23.coffee b/pitfall/ptest/test23.coffee new file mode 100644 index 00000000..8f8b7726 --- /dev/null +++ b/pitfall/ptest/test23.coffee @@ -0,0 +1,26 @@ +PDFDocument = require 'pdfkit' +fs = require 'fs' + +# embed otf + +make = (doc) -> + + doc.registerFont('sarabun', 'assets/sarabun.ttf') + doc.registerFont('fira', 'assets/fira.otf') + + # Set the font, draw some text + doc.font('sarabun') + .fontSize(40) + .text('hello สวัสดีชาวโลก world', 100, 150, {width: false}) + + doc.end() + + +doc = new PDFDocument({compress: no}) +doc.pipe(fs.createWriteStream('test23.pdf')) +make doc + +doc = new PDFDocument({compress: yes}) +doc.pipe(fs.createWriteStream('test23c.pdf')) +make doc + diff --git a/pitfall/ptest/test23.pdf b/pitfall/ptest/test23.pdf new file mode 100644 index 00000000..d192c25e Binary files /dev/null and b/pitfall/ptest/test23.pdf differ diff --git a/pitfall/ptest/test23.rkt b/pitfall/ptest/test23.rkt index 97b04dab..fefa1c48 100644 --- a/pitfall/ptest/test23.rkt +++ b/pitfall/ptest/test23.rkt @@ -1,6 +1,23 @@ #lang debug racket/base -(require fontland/test/index - fontland/test/glyphs - fontland/test/directory - fontland/test/subset) -(time (void)) \ No newline at end of file +(require pitfall/pdftest) + +;; subset OTF font +(define-runtime-path sarabun "assets/sarabun.ttf") + +;; embed otf + +(define (proc doc) + (register-font doc "sarabun" (path->string sarabun)) + + ;; Set the font, draw some text + [font doc "sarabun"] + [font-size doc 40] + [text doc "hello สวัสดีชาวโลก world" 100 150]) + +;; test against non-subsetted font version +(define-runtime-path this "test23rkt.pdf") +(make-doc this #f proc) + +(define-runtime-path that "test23crkt.pdf") +(make-doc that #t proc) + diff --git a/pitfall/ptest/test23c.pdf b/pitfall/ptest/test23c.pdf new file mode 100644 index 00000000..1b0a9cf0 Binary files /dev/null and b/pitfall/ptest/test23c.pdf differ diff --git a/pitfall/ptest/test23crkt copy.pdf b/pitfall/ptest/test23crkt copy.pdf new file mode 100644 index 00000000..37a49e4a Binary files /dev/null and b/pitfall/ptest/test23crkt copy.pdf differ diff --git a/pitfall/ptest/test23rkt copy.pdf b/pitfall/ptest/test23rkt copy.pdf new file mode 100644 index 00000000..3df09f41 Binary files /dev/null and b/pitfall/ptest/test23rkt copy.pdf differ diff --git a/pitfall/ptest/test24.rkt b/pitfall/ptest/test24.rkt new file mode 100644 index 00000000..97b04dab --- /dev/null +++ b/pitfall/ptest/test24.rkt @@ -0,0 +1,6 @@ +#lang debug racket/base +(require fontland/test/index + fontland/test/glyphs + fontland/test/directory + fontland/test/subset) +(time (void)) \ No newline at end of file