goodbye racket/function

main
Matthew Butterick 6 years ago
parent 4b458b7e76
commit b36489e986

@ -2,14 +2,13 @@
(require
racket/string
racket/format
racket/function
sugar/list)
(provide binprint)
(define (binprint in #:width [width 16])
(unless (even? width) (raise-argument-error 'binprint "even width" width))
(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)))))

@ -9,7 +9,6 @@
racket/format
racket/contract
racket/list
racket/function
br/define
sugar/unstable/class
sugar/unstable/js
@ -61,14 +60,9 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
;; called from text.rkt
(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 glyphs (glyphrun-glyphs 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)
(for/lists (idxs posns)
([(g i) (in-indexed glyphs)]
@ -109,7 +103,7 @@ https://github.com/mbutterick/pdfkit/blob/master/lib/font/embedded.coffee
;; font descriptor flags
(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
[(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"
'FontName name
'Flags flags
'FontBBox (map (curry * (· this scale))
'FontBBox (map (λ (x) (* (· this scale) x))
(list (BBox-minX bbox) (BBox-minY bbox)
(BBox-maxX bbox) (BBox-maxY bbox)))
'ItalicAngle (· this font italicAngle)

@ -1,35 +1,17 @@
#lang racket/base
(require
(for-syntax racket/base)
"helper.rkt"
"param.rkt"
"struct.rkt"
sugar/debug
racket/class
racket/file
racket/match
racket/string
racket/format
racket/contract
racket/list
racket/port
racket/function
br/define
sugar/unstable/class
sugar/unstable/js
sugar/unstable/dict
sugar/unstable/stub
sugar/unstable/port
sugar/unstable/contract
describe
"check-pdf.rkt")
(provide check-copy-equal? check-pdfkit? make-doc)
(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))
(define (this->control this) (path-add-extension this #"" #" copy."))

@ -5,7 +5,6 @@
racket/string
racket/contract
racket/list
racket/function
sugar/unstable/class
sugar/unstable/js
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)])
(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)])

Loading…
Cancel
Save