From b758ec27235449382c763771b717be9f7957a079 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 19 Jun 2017 12:34:22 -0700 Subject: [PATCH] step2 --- pitfall/fontkit/tables.rkt | 5 +++-- pitfall/pitfall/embedded.rkt | 17 +++++++++++------ pitfall/pitfall/test/test12.rkt | 9 +-------- pitfall/pitfall/test/test12crkt copy.pdf | Bin 4475 -> 4475 bytes pitfall/pitfall/test/test12crkt.pdf | Bin 4475 -> 4475 bytes pitfall/pitfall/test/test12rkt copy.pdf | Bin 6345 -> 6345 bytes pitfall/pitfall/test/test12rkt.pdf | Bin 6345 -> 6345 bytes pitfall/pitfall/test/test13crkt copy.pdf | Bin 4058 -> 4058 bytes pitfall/pitfall/test/test13crkt.pdf | Bin 4058 -> 4058 bytes pitfall/pitfall/test/test13rkt copy.pdf | Bin 5418 -> 5418 bytes pitfall/pitfall/test/test13rkt.pdf | Bin 5418 -> 5418 bytes 11 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pitfall/fontkit/tables.rkt b/pitfall/fontkit/tables.rkt index 5ddf5701..5a36cb1e 100644 --- a/pitfall/fontkit/tables.rkt +++ b/pitfall/fontkit/tables.rkt @@ -1,12 +1,13 @@ #lang fontkit/racket (provide (all-defined-out)) +(require (for-syntax racket/string)) (define-macro (define-table-codecs ID TABLE-ID ...) (with-pattern ([(TABLE-ID-STRING ...) (pattern-case-filter #'(TABLE-ID ...) - [STX (datum->syntax caller-stx (format "~a.rkt" (syntax->datum #'STX)))])]) + [STX (datum->syntax caller-stx (string-replace (format "~a.rkt" (syntax->datum #'STX)) "/" ""))])]) #'(begin (r+p TABLE-ID-STRING ...) (test-module (require (submod TABLE-ID-STRING test) ...)) (define ID (make-hasheq (map cons (list 'TABLE-ID ...) (list TABLE-ID ...))))))) -(define-table-codecs table-codecs maxp hhea head loca prep fpgm hmtx cvt_ glyf) \ No newline at end of file +(define-table-codecs table-codecs maxp hhea head loca prep fpgm hmtx cvt_ glyf OS/2 post) \ No newline at end of file diff --git a/pitfall/pitfall/embedded.rkt b/pitfall/pitfall/embedded.rkt index ff50b214..74c5b368 100644 --- a/pitfall/pitfall/embedded.rkt +++ b/pitfall/pitfall/embedded.rkt @@ -77,12 +77,17 @@ For now, we'll just measure width of the characters. #;(send (send (· this subset) encodeStream) pipe fontFile) (send fontFile end (send (send (· this subset) encodeStream) dump)) - ;; todo - ;; (define familyClass (send (· this font) has-table? #"OS/2")) - (define familyClass 0) - - ;; todo: flags - (define flags 0) + (define familyClass (let ([val (if (send (· this font) has-table? 'OS/2) + (· (send (· this font) _getTable 'OS/2) sFamilyClass) + 0)]) + (floor (/ val 256)))) ; equivalent to >> 8 + + (define flags (+ + (if (not (zero? (· (send (· this font) _getTable 'post) isFixedPitch))) (expt 2 0) 0) + (if (<= 1 familyClass 7) (expt 2 1) 0) + (expt 2 2) ; assume the font uses non-latin characters + (if (= familyClass 10) (expt 2 3) 0) + (if (· (send (· this font) _getTable 'head) macStyle italic) (expt 2 6) 0))) ;; generate a random tag (6 uppercase letters. 65 is the char code for 'A') (when (test-mode) (random-seed 0)) diff --git a/pitfall/pitfall/test/test12.rkt b/pitfall/pitfall/test/test12.rkt index ebb2adb2..ad086058 100644 --- a/pitfall/pitfall/test/test12.rkt +++ b/pitfall/pitfall/test/test12.rkt @@ -18,11 +18,4 @@ (make-doc this #f proc) (define-runtime-path that "test12crkt.pdf") -(make-doc that #t proc #:pdfkit #f) - -#;(module+ test - (define doc (make-object PDFDocument)) - (send doc registerFont "Charter" (path->string charter-path)) - (send* doc [font "Charter"]) - (send doc pipe (open-output-string)) - (send doc end)) +(make-doc that #t proc #:pdfkit #f) \ No newline at end of file diff --git a/pitfall/pitfall/test/test12crkt copy.pdf b/pitfall/pitfall/test/test12crkt copy.pdf index 7855b83718c2109a44c8c2083070ec28f267a722..9dbce0bc56542de9270483e70deee9062e0f54f9 100644 GIT binary patch delta 14 WcmeyZ^jm4edLBlT%^P@5vj6}yUj`Wf delta 14 WcmeyZ^jm4edLBlD%^P@5vj6}yM+OxD diff --git a/pitfall/pitfall/test/test12crkt.pdf b/pitfall/pitfall/test/test12crkt.pdf index 7855b83718c2109a44c8c2083070ec28f267a722..9dbce0bc56542de9270483e70deee9062e0f54f9 100644 GIT binary patch delta 14 WcmeyZ^jm4edLBlT%^P@5vj6}yUj`Wf delta 14 WcmeyZ^jm4edLBlD%^P@5vj6}yM+OxD diff --git a/pitfall/pitfall/test/test12rkt copy.pdf b/pitfall/pitfall/test/test12rkt copy.pdf index 8641980ec7363ae367aef1f12f1a1dee026427fb..4f208f6094af53f09393de72ccf9aae499e9e5e9 100644 GIT binary patch delta 14 VcmX?Uc+zl#pD?4zW`E%-Rsbq;1kV5f delta 14 VcmX?Uc+zl#pD?4rW`E%-Rsbqm1j_&b diff --git a/pitfall/pitfall/test/test12rkt.pdf b/pitfall/pitfall/test/test12rkt.pdf index 8641980ec7363ae367aef1f12f1a1dee026427fb..4f208f6094af53f09393de72ccf9aae499e9e5e9 100644 GIT binary patch delta 14 VcmX?Uc+zl#pD?4zW`E%-Rsbq;1kV5f delta 14 VcmX?Uc+zl#pD?4rW`E%-Rsbqm1j_&b diff --git a/pitfall/pitfall/test/test13crkt copy.pdf b/pitfall/pitfall/test/test13crkt copy.pdf index ffcb9401f116092b5a6d97a415b00c3483e54110..5f206284996e2c0727a0e806c766b3b52be4de9d 100644 GIT binary patch delta 14 Vcmca5e@lLY0ym?{W<~CuEC47=1fKu^ delta 14 Vcmca5e@lLY0ym?