main
Matthew Butterick 8 years ago
parent 638a578faa
commit a0d6aa449c

@ -2,7 +2,7 @@
(require "freetype-ffi.rkt" ffi/unsafe racket/runtime-path "subset.rkt" "glyph.rkt" "layout-engine.rkt" "bbox.rkt" "glyphrun.rkt" "cmap-processor.rkt" "directory.rkt")
(provide (all-defined-out))
(define-runtime-path charter-path "test/assets/charter.ttf")
(define-runtime-path charter-path "../pitfall/test/assets/charter.ttf")
#|
approximates

@ -0,0 +1,6 @@
#lang restructure/racket
(r+p "font.rkt"
"glyph-position.rkt"
"subset.rkt"
"bbox.rkt")

@ -1,50 +0,0 @@
#lang pitfall/racket
(define binarizer%
(class object%
(super-new)
(init-field [parts null])
(define/public (encode x) (error 'must-override-encode))
(define/public (decode x) (error 'must-override-encode))))
(define Byte
(class binarizer%
(super-new)
(define/override (encode x)
(let loop ([x x])
(cond
[(bytes? x)
(if (= (bytes-length x) 1)
x
(raise-argument-error 'Byte "byte string of length 1" x))]
[(number? x)
(if (<= 0 x 255)
(bytes x)
(raise-argument-error 'Byte "number that fits into one byte" x))]
[(char? x) (loop (char->integer x))]
[(symbol? x) (loop (symbol->string x))]
[(string? x) (loop (string->bytes/latin-1 x))]
[else (raise-argument-error 'Byte "convertible type" x)])))))
(define (>Byte . xs)
(apply make-object Byte xs))
(get-field parts (>Byte 23))
#|
(define (Bio x)
(define template (list 'age Byte
'name short
'city long))
(if (hash? x)
(hash->bytes x template)
(bytes->hash x template)))
(define h (hash 'age 24
'name 1000
'city 200000))
(define bs (Bio h))
(Bio bs)|#

@ -1,5 +1,5 @@
#lang pitfall/racket
(require "font.rkt" "glyph-position.rkt" "glyphrun.rkt" "subset.rkt" "reference.rkt")
(require "font.rkt" fontkit "reference.rkt")
(provide EmbeddedFont)
(define-subclass PDFFont (EmbeddedFont document font id)
@ -182,7 +182,7 @@ For now, we'll just measure width of the characters.
(module+ test
(require rackunit "fontkit.rkt" "bbox.rkt")
(require rackunit fontkit)
(define f (openSync "test/assets/Charter.ttf" #f))
(define ef (make-object EmbeddedFont #f f #f))
(check-equal? (send ef widthOfString "f" 1000) 321.0)

@ -1,5 +1,5 @@
#lang pitfall/racket
(require "standard-font.rkt" "font.rkt" "fontkit.rkt" "embedded.rkt")
(require "standard-font.rkt" "font.rkt" fontkit "embedded.rkt")
(provide PDFFont-open)
(define/contract (PDFFont-open document src family id)

@ -1,6 +1,6 @@
#lang pitfall/racket
(require "afm-font.rkt" "font.rkt" "glyph-position.rkt")
(require racket/runtime-path (for-syntax racket/base racket/path racket/syntax sugar/debug))
(require "afm-font.rkt" "font.rkt" fontkit)
(require racket/runtime-path)
(provide isStandardFont standard-fonts StandardFont)
(define-subclass PDFFont (StandardFont document name id)

Loading…
Cancel
Save