diff --git a/quad/main.rkt b/quad/main.rkt index 050e75ad..64be38fa 100644 --- a/quad/main.rkt +++ b/quad/main.rkt @@ -4,6 +4,7 @@ (provide typeset) (define (input->nested-blocks i) + (define-syntax-rule (cons-reverse x y) (cons (reverse x) y)) (define-values (mps mcs bs b) (for/fold ([multipages empty][multicolumns empty][blocks empty][block-acc empty]) ([q (in-list (split-quad i))]) @@ -180,8 +181,7 @@ (define current-eof (make-parameter (gensym))) (define (eof? x) (equal? x (current-eof))) -(define-syntax-rule (cons-reverse x y) - (cons (reverse x) y)) + (define (quads->lines qs) (block->lines (quads->block qs))) @@ -190,9 +190,9 @@ (coerce/input? . -> . doc?) (load-text-cache-file) (define pages - (append* (for/list ([mp (in-list (input->nested-blocks x))]) - (columns->pages (append* (for/list ([mc (in-list mp)]) - (lines->columns (apply append (map quads->lines mc))))))))) + (append* (for/list ([multipage (in-list (input->nested-blocks x))]) + (columns->pages (append* (for/list ([multicolumn (in-list multipage)]) + (lines->columns (append* (map quads->lines multicolumn))))))))) (define doc (pages->doc pages)) (update-text-cache-file) doc) @@ -202,7 +202,7 @@ (require "render.rkt" racket/class profile) (require "samples.rkt") (activate-logger quad-logger) - (parameterize ([world:quality-default world:draft-quality] + (parameterize ([world:quality-default world:max-quality] [world:paper-width-default 600] [world:paper-height-default 700]) (define sample (ti5)) diff --git a/quad/samples.rkt b/quad/samples.rkt index dc195c88..5281f1f2 100644 --- a/quad/samples.rkt +++ b/quad/samples.rkt @@ -10,7 +10,7 @@ (define (ti4) (block '(measure 300 x-align justify x-align-last-line right leading 18) "In this Madagascarian hoo-ha, Racket isn’t exactly a language at all")) -(define (ti5) (block '(measure 240 font "Equity Text B" leading 16 size 13.5 x-align justify x-align-last-line left) (box '(width 15)) (block #f (block '(weight bold font "Equity Caps B") "Hot" (word '(size 22) "Z") "ogs, My Fellow Americans.") " This " (block '(no-break #t) "is some truly") " bullshit generated from my typesetting system, which is called Quad. I’m writing this in a source file in DrRacket. When I click [Run], a PDF pops out. Not bad\u200a—\u200aand no LaTeX needed. Quad, however, does use the fancy linebreaking algorithm developed for TeX. (It also includes a faster linebreaking algorithm for when speed is more important than quality.) Of course, it can also handle " (block '(font "Triplicate C4") "different fonts,") (block '(style italic) " styles, ") (word '(size 14 weight bold) "and sizes-") " within the same line. As you can see, it can also justify paragraphs." (block-break) (box '(width 15)) (block #f "“Each horizontal row represents an OS-level thread, and the colored dots represent important events in the execution of the program (they are color-coded to distinguish one event type from another). The upper-left blue dot in the timeline represents the future’s creation. The future executes for a brief period (represented by a green bar in the second line) on thread 1, and then pauses to allow the runtime thread to perform a future-unsafe operation.") (column-break) (box '(width 15))(block #f "In the Racket implementation, future-unsafe operations fall into one of two categories. A blocking operation halts the evaluation of the future, and will not allow it to continue until it is touched. After the operation completes within touch, the remainder of the future’s work will be evaluated sequentially by the runtime thread. A synchronized operation also halts the future, but the runtime thread may perform the operation at any time and, once completed, the future may continue running in parallel. Memory allocation and JIT compilation are two common examples of synchronized operations." (page-break) "another page")))) +(define (ti5) (block '(measure 240 font "Equity Text B" leading 16 vmeasure 300 size 13.5 x-align justify x-align-last-line left) (box '(width 15)) (block #f (block '(weight bold font "Equity Caps B") "Hot" (word '(size 22) "Z") "ogs, My Fellow Americans.") " This " (block '(no-break #t) "is some truly") " bullshit generated from my typesetting system, which is called Quad. I’m writing this in a source file in DrRacket. When I click [Run], a PDF pops out. Not bad\u200a—\u200aand no LaTeX needed. Quad, however, does use the fancy linebreaking algorithm developed for TeX. (It also includes a faster linebreaking algorithm for when speed is more important than quality.) Of course, it can also handle " (block '(font "Triplicate C4") "different fonts,") (block '(style italic) " styles, ") (word '(size 14 weight bold) "and sizes-") " within the same line. As you can see, it can also justify paragraphs." (block-break) (box '(width 15)) (block #f "“Each horizontal row represents an OS-level thread, and the colored dots represent important events in the execution of the program (they are color-coded to distinguish one event type from another). The upper-left blue dot in the timeline represents the future’s creation. The future executes for a brief period (represented by a green bar in the second line) on thread 1, and then pauses to allow the runtime thread to perform a future-unsafe operation.") (column-break) (box '(width 15))(block #f "In the Racket implementation, future-unsafe operations fall into one of two categories. A blocking operation halts the evaluation of the future, and will not allow it to continue until it is touched. After the operation completes within touch, the remainder of the future’s work will be evaluated sequentially by the runtime thread. A synchronized operation also halts the future, but the runtime thread may perform the operation at any time and, once completed, the future may continue running in parallel. Memory allocation and JIT compilation are two common examples of synchronized operations." (page-break) "another page")))) (define (ti6) (block '(font "Equity Text B" measure 210 leading 14 size 20 x-align justify x-align-last-line left) "Firstlinerhere" (column-break) "Secondlinerhere" (column-break) "Thirdlinerhere")) diff --git a/quad/todo.rkt b/quad/todo.rkt index 6dc4f6cd..e7ab285a 100644 --- a/quad/todo.rkt +++ b/quad/todo.rkt @@ -2,15 +2,11 @@ ;; todo next ;; pagination: vertical measuring -;; segfault on command line? ;; adaptive linebreak using fu-formula -;; use smawk penalty system for pagination too? ;; unified model of filling / positioning that works for every quad, recursively ;; how to handle constraint failure. At least a good error message. ;; imperative line break ;; why do certain MB fonts only appear in bold? ;; deal with separating / recombining footnote flow ;; deal with page number flags (for toc, index, etc) -;; disk cache of previously wrapped lines -;; fractional point sizes (asked Flatt) -;; how are opentype features handled (asked Flatt) +;; disk cache of previously wrapped lines \ No newline at end of file