make PDF button work

main
Matthew Butterick 8 years ago
parent ccf72bafe9
commit d35ef4b221

@ -5,10 +5,10 @@
(require quad quad/quads quad/render)
(time (send (new pdf-renderer%) render-to-file (typeset 1-out) "f1-test.pdf"))
;(time (send (new pdf-renderer%) render-to-file (typeset 1-out) "f1-test.pdf"))
(require (prefix-in 2- "foo2.rkt"))
(time (send (new pdf-renderer%) render-to-file (typeset 2-out) "f2-test.pdf"))
(require (prefix-in 3- "foo3.rkt"))
(time (send (new pdf-renderer%) render-to-file (typeset 3-out) "f3-test.pdf"))
;(time (send (new pdf-renderer%) render-to-file (typeset 3-out) "f3-test.pdf"))

@ -1,3 +1,3 @@
#lang quad
(block '(measure 240.0 font "Times New Roman" leading 16.0 vmeasure 300.0 size 13.5 x-align justify x-align-last-line left) (box '(width 15.0)) (block '() (block '(weight bold) "Hot " (word '(size 22.0) "D") "ang, My Fellow Americans.") " This " (block '(no-break #t) "is some truly") " nonsense generated from my typesetting system, which is called Quad. Im 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 "Courier") "different fonts,") (block '(style italic) " styles, ") (word '(size 14.0 weight bold) "and sizes-") " within the same line. As you can see, it can also justify paragraphs."))
1 1.1 1.2 Hello world and so on. 2 Hello world and so on. 3 Hello world and so on. 4 Hello world and so on.

@ -0,0 +1,30 @@
#lang racket/base
(require racket/runtime-path
racket/gui/base
racket/class
quad/render
quad)
(provide make-drracket-buttons)
(module test racket/base) ; suppress testing by `raco test`
(define-runtime-path html-png-path "cmd-char.png")
#| for toolbar callbacks, see
http://pkg-build.racket-lang.org/doc/tools/drracket_module-language-tools.html#%28elem._drracket~3atoolbar-buttons%29
|#
(define (make-command-char-button command-char)
(let ([label "Render PDF"]
[bitmap (make-object bitmap% html-png-path 'png/mask)]
[callback (λ (drr-frame)
(time (send (new pdf-renderer%) render-to-file (typeset 'boom) "f2-test.pdf")))]
[number 99])
(list label bitmap callback number)))
(define (make-drracket-buttons command-char)
(let ([command-char-button (make-command-char-button command-char)])
(list command-char-button)))

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

@ -9,6 +9,7 @@
[(_ expr ...)
(replace-context #'(expr ...)
#'(#%module-begin
(define result (memf block? (list expr ...)))
(define out (if result (car result) (block #f)))
(provide out)))]))
(define out (block '(measure 200.0 font "Times New Roman" leading 16.0 vmeasure 300.0 size 13.5) expr ...))
(provide out)))]))

@ -3,6 +3,7 @@ quad/lang/quad
#:read quad-read
#:read-syntax quad-read-syntax
#:whole-body-readers? #t ;; need this to make at-reader work
#:info custom-get-info
(require scribble/reader)
(define (quad-read p)
@ -14,4 +15,18 @@ quad/lang/quad
#:syntax? #t
#:inside? #t))
(define source-stx (quad-at-reader path-string p))
source-stx)
source-stx)
(define (custom-get-info key default [proc (λ _ #f)])
(displayln 'yay)
(case key
[(color-lexer)
(define my-make-scribble-inside-lexer
(dynamic-require 'syntax-color/scribble-lexer 'make-scribble-inside-lexer (λ () #f)))
(cond [my-make-scribble-inside-lexer
(my-make-scribble-inside-lexer #:command-char #\◊)]
[else default])]
[(drracket:toolbar-buttons)
(define my-make-drracket-buttons (dynamic-require 'quad/lang/buttons 'make-drracket-buttons))
(my-make-drracket-buttons #\◊)]
[else default]))

@ -3,4 +3,4 @@
(provide quick-sample)
(define quick-sample
(block '(measure 240.0 font "Times New Roman" leading 16.0 vmeasure 300.0 size 13.5 x-align justify x-align-last-line left) (box '(width 15.0)) (block '() (block '(weight bold) "Hot " (word '(size 22.0) "D") "ang, My Fellow Americans.") " This " (block '(no-break #t) "is some truly") " nonsense generated from my typesetting system, which is called Quad. Im 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 "Courier") "different fonts,") (block '(style italic) " styles, ") (word '(size 14.0 weight bold) "and sizes-") " within the same line. As you can see, it can also justify paragraphs." (block-break) (box '(width 15.0)) (block '() "“Each horizontal row represents " (box '(color "Red" background "Yellow") "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 futures 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.0))(block '() "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 futures 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"))))
(block '(measure 480.0 font "Times New Roman" leading 16.0 vmeasure 300.0 size 13.5 x-align justify x-align-last-line left) (box '(width 15.0)) (block '() (block '(weight bold) "Hot " (word '(size 22.0) "D") "ang, My Fellow Americans.") " This " (block '(no-break #t) "is some truly") " nonsense generated from my typesetting system, which is called Quad. Im 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 "Courier") "different fonts,") (block '(style italic) " styles, ") (word '(size 14.0 weight bold) "and sizes-") " within the same line. As you can see, it can also justify paragraphs." (block-break) (box '(width 15.0)) (block '() "“Each horizontal row represents " (box '(color "Red" background "Yellow") "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 futures 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.0))(block '() "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 futures 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"))))
Loading…
Cancel
Save