segfault demo

main
Matthew Butterick 10 years ago
parent 21a6447740
commit 77d17b5c9f

@ -16,13 +16,17 @@
"Firstlinerhere" (column-break) "Secondlinerhere" (column-break) "Thirdlinerhere"))
(define (make-jude jude-text)
(define jude-blocks (map (λ(s) (regexp-replace* #rx"\n" s " ")) (string-split (file->string jude-text) "\n\n")))
(define (make-sample jude-text [line-limit #f])
(define sample-string (if line-limit
(let ([lines (file->lines jude-text)])
(string-join (take lines (min line-limit (length lines))) "\n"))
(file->string jude-text)))
(define jude-blocks (map (λ(s) (regexp-replace* #rx"\n" s " ")) (string-split sample-string "\n\n")))
(apply block '(font "Equity Text B" measure 360 leading 14 column-count 1 column-gutter 10 size 11.5 x-align justify x-align-last-line left) (add-between (map (λ(jb) (block #f (box '(width 10)) (optical-kern) jb)) jude-blocks) (block-break))))
(define (jude) (make-jude "texts/jude.txt"))
(define (jude0) (make-jude "texts/jude0.txt"))
(define (judebig) (make-jude "texts/judebig.txt"))
(define (jude) (make-sample "texts/jude.txt"))
(define (jude0) (make-sample "texts/jude0.txt"))
(define (judebig) (make-sample "texts/judebig.txt"))
(define (segfault) (make-sample "texts/segfault.txt"))
(define (jude1) (block '(font "Equity Text B" measure 150 leading 14 column-count 4 size 11 x-align justify x-align-last-line left) "this—is—a—test—of—em—dashes—breakable—or—not?"))

@ -0,0 +1,16 @@
#lang racket/base
(require "main.rkt" "samples.rkt" "render.rkt" "world.rkt" racket/class)
(module+ main
(define line-limit (with-handlers ([exn:fail? (λ(exn) #f)])
(string->number (vector-ref (current-command-line-arguments) 0))))
(parameterize ([world:quality-default world:max-quality]
[world:paper-width-default 412]
[world:paper-height-default 600])
(define path "texts/segfault.txt")
(displayln "Making text sample")
(define text-sample (time (make-sample path line-limit)))
(displayln "Typsetting sample")
(define typeset-sample (time (typeset text-sample)))
(displayln "Rendering sample to PDF")
(time (send (new pdf-renderer%) render-to-file typeset-sample "texts/segfault.pdf"))))

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save