goodbye racket/function

main
Matthew Butterick 6 years ago
parent 4b458b7e76
commit b36489e986

@ -2,14 +2,13 @@
(require (require
racket/string racket/string
racket/format racket/format
racket/function
sugar/list) sugar/list)
(provide binprint) (provide binprint)
(define (binprint in #:width [width 16]) (define (binprint in #:width [width 16])
(unless (even? width) (raise-argument-error 'binprint "even width" width)) (unless (even? width) (raise-argument-error 'binprint "even width" width))
(for-each displayln (for-each displayln
(for/list ([bs (in-port (curry read-bytes width) in)]) (for/list ([bs (in-port (λ (p) (read-bytes width p)) in)])
(string-append (pad-string (hexline bs) (+ (* width 2) (sub1 (/ width 2)))) " " (alphaline bs))))) (string-append (pad-string (hexline bs) (+ (* width 2) (sub1 (/ width 2)))) " " (alphaline bs)))))

@ -9,7 +9,6 @@
racket/format racket/format
racket/contract racket/contract
racket/list racket/list
racket/function
br/define br/define
sugar/unstable/class sugar/unstable/class
sugar/unstable/js sugar/unstable/js
@ -61,14 +60,9 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
;; called from text.rkt ;; called from text.rkt
(define (encode this text [features #f]) (define (encode this text [features #f])
#;((string?) ((option/c list?)) . ->*m .
(list/c (listof string?) (listof glyphposition?)))
#;(report*/file 'starting-layout-in-embedded (description (· this font)))
(define glyphRun (send (· this font) layout text features)) (define glyphRun (send (· this font) layout text features))
(define glyphs (glyphrun-glyphs glyphRun)) (define glyphs (glyphrun-glyphs glyphRun))
(define positions (glyphrun-positions glyphRun)) (define positions (glyphrun-positions glyphRun))
#;(report/file (for/list ([p (in-list positions)])
(list (· p xAdvance) (· p xOffset))))
(define-values (subset-idxs new-positions) (define-values (subset-idxs new-positions)
(for/lists (idxs posns) (for/lists (idxs posns)
([(g i) (in-indexed glyphs)] ([(g i) (in-indexed glyphs)]
@ -109,7 +103,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
;; font descriptor flags ;; font descriptor flags
(match-define (list FIXED_PITCH SERIF SYMBOLIC SCRIPT _UNUSED NONSYMBOLIC ITALIC) (match-define (list FIXED_PITCH SERIF SYMBOLIC SCRIPT _UNUSED NONSYMBOLIC ITALIC)
(map (curry expt 2) (range 7))) (map (λ (x) (expt 2 x)) (range 7)))
(define flags (sum-flags (define flags (sum-flags
[(not (zero? (· this font post isFixedPitch))) FIXED_PITCH] [(not (zero? (· this font post isFixedPitch))) FIXED_PITCH]
@ -130,7 +124,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
'Type "FontDescriptor" 'Type "FontDescriptor"
'FontName name 'FontName name
'Flags flags 'Flags flags
'FontBBox (map (curry * (· this scale)) 'FontBBox (map (λ (x) (* (· this scale) x))
(list (BBox-minX bbox) (BBox-minY bbox) (list (BBox-minX bbox) (BBox-minY bbox)
(BBox-maxX bbox) (BBox-maxY bbox))) (BBox-maxX bbox) (BBox-maxY bbox)))
'ItalicAngle (· this font italicAngle) 'ItalicAngle (· this font italicAngle)

@ -1,35 +1,17 @@
#lang racket/base #lang racket/base
(require (require
(for-syntax racket/base) (for-syntax racket/base)
"helper.rkt"
"param.rkt" "param.rkt"
"struct.rkt"
sugar/debug
racket/class racket/class
racket/file
racket/match
racket/string racket/string
racket/format
racket/contract
racket/list
racket/port
racket/function
br/define br/define
sugar/unstable/class
sugar/unstable/js
sugar/unstable/dict
sugar/unstable/stub
sugar/unstable/port
sugar/unstable/contract
describe
"check-pdf.rkt") "check-pdf.rkt")
(provide check-copy-equal? check-pdfkit? make-doc) (provide check-copy-equal? check-pdfkit? make-doc)
(test-mode #t) (test-mode #t)
(require rackunit racket/runtime-path pitfall/document racket/class) (require rackunit pitfall/document racket/runtime-path racket/class)
(provide (all-from-out rackunit racket/runtime-path pitfall/document racket/class)) (provide (all-from-out rackunit racket/runtime-path pitfall/document racket/class))
(define (this->control this) (path-add-extension this #"" #" copy.")) (define (this->control this) (path-add-extension this #"" #" copy."))

@ -5,7 +5,6 @@
racket/string racket/string
racket/contract racket/contract
racket/list racket/list
racket/function
sugar/unstable/class sugar/unstable/class
sugar/unstable/js sugar/unstable/js
sugar/unstable/dict sugar/unstable/dict
@ -83,7 +82,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/mixins/text.coffee
(define (text this text-string [x #f] [y #f] [options (mhash)]) (define (text this text-string [x #f] [y #f] [options (mhash)])
(send this _text text-string x y options (curry _line this))) (send this _text text-string x y options (λ (x) (_line this x))))
(define/contract (widthOfString this str [options (mhash)]) (define/contract (widthOfString this str [options (mhash)])

Loading…
Cancel
Save