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 7855b837..9dbce0bc 100644 Binary files a/pitfall/pitfall/test/test12crkt copy.pdf and b/pitfall/pitfall/test/test12crkt copy.pdf differ diff --git a/pitfall/pitfall/test/test12crkt.pdf b/pitfall/pitfall/test/test12crkt.pdf index 7855b837..9dbce0bc 100644 Binary files a/pitfall/pitfall/test/test12crkt.pdf and b/pitfall/pitfall/test/test12crkt.pdf differ diff --git a/pitfall/pitfall/test/test12rkt copy.pdf b/pitfall/pitfall/test/test12rkt copy.pdf index 8641980e..4f208f60 100644 Binary files a/pitfall/pitfall/test/test12rkt copy.pdf and b/pitfall/pitfall/test/test12rkt copy.pdf differ diff --git a/pitfall/pitfall/test/test12rkt.pdf b/pitfall/pitfall/test/test12rkt.pdf index 8641980e..4f208f60 100644 Binary files a/pitfall/pitfall/test/test12rkt.pdf and b/pitfall/pitfall/test/test12rkt.pdf differ diff --git a/pitfall/pitfall/test/test13crkt copy.pdf b/pitfall/pitfall/test/test13crkt copy.pdf index ffcb9401..5f206284 100644 Binary files a/pitfall/pitfall/test/test13crkt copy.pdf and b/pitfall/pitfall/test/test13crkt copy.pdf differ diff --git a/pitfall/pitfall/test/test13crkt.pdf b/pitfall/pitfall/test/test13crkt.pdf index ffcb9401..5f206284 100644 Binary files a/pitfall/pitfall/test/test13crkt.pdf and b/pitfall/pitfall/test/test13crkt.pdf differ diff --git a/pitfall/pitfall/test/test13rkt copy.pdf b/pitfall/pitfall/test/test13rkt copy.pdf index e8fc9343..996a1a14 100644 Binary files a/pitfall/pitfall/test/test13rkt copy.pdf and b/pitfall/pitfall/test/test13rkt copy.pdf differ diff --git a/pitfall/pitfall/test/test13rkt.pdf b/pitfall/pitfall/test/test13rkt.pdf index e8fc9343..996a1a14 100644 Binary files a/pitfall/pitfall/test/test13rkt.pdf and b/pitfall/pitfall/test/test13rkt.pdf differ