|
|
|
@ -13,23 +13,25 @@
|
|
|
|
|
(define-pass (make-drawing-insts qs)
|
|
|
|
|
#:pre (list-of has-position?)
|
|
|
|
|
#:post (list-of $drawing-inst?)
|
|
|
|
|
(flatten
|
|
|
|
|
(list ($doc 'start) ($page 'start)
|
|
|
|
|
(apply append
|
|
|
|
|
(let ([current-font #false])
|
|
|
|
|
(for/list ([q (in-list qs)])
|
|
|
|
|
(append
|
|
|
|
|
(match (quad-ref q :font-path)
|
|
|
|
|
[(== current-font) null]
|
|
|
|
|
[font-path
|
|
|
|
|
(set! current-font font-path)
|
|
|
|
|
(list ($font font-path))])
|
|
|
|
|
(cond
|
|
|
|
|
[(quad? q)
|
|
|
|
|
(cond
|
|
|
|
|
[(eq? boq q) (list ($doc-start))]
|
|
|
|
|
[(eq? eoq q) (list ($doc-end))]
|
|
|
|
|
[(bop-quad? q) (list ($page-start (quad-ref q :page-width) (quad-ref q :page-height)))]
|
|
|
|
|
[(eop-quad? q) (list ($page-end))]
|
|
|
|
|
[(quad? q)
|
|
|
|
|
(append
|
|
|
|
|
(match (quad-ref q :font-path)
|
|
|
|
|
[(== current-font) null]
|
|
|
|
|
[font-path
|
|
|
|
|
(set! current-font font-path)
|
|
|
|
|
(list ($font font-path))])
|
|
|
|
|
(if (pair? (quad-elems q))
|
|
|
|
|
(list ($move (quad-posn q)) ($text (char->integer (car (string->list (car (quad-elems q)))))))
|
|
|
|
|
null)]
|
|
|
|
|
[else (error 'render-unknown-thing)]))))
|
|
|
|
|
($page 'end) ($doc 'end))))
|
|
|
|
|
null))]
|
|
|
|
|
[else (error 'render-unknown-thing)])))))
|
|
|
|
|
|
|
|
|
|
(define valid-tokens '(doc-start doc-end page-start page-end text move set-font))
|
|
|
|
|
|
|
|
|
@ -45,8 +47,8 @@
|
|
|
|
|
[($move ($point x y)) (list y x 'move)]
|
|
|
|
|
[($text charint) (list charint 'text)]
|
|
|
|
|
[($font path-string) (list path-string 'set-font)]
|
|
|
|
|
[($doc 'start) '(doc-start)]
|
|
|
|
|
[($doc 'end) '(doc-end)]
|
|
|
|
|
[($page 'start) (list ymax xmax 'page-start)]
|
|
|
|
|
[($page 'end) '(page-end)]
|
|
|
|
|
[($doc-start) '(doc-start)]
|
|
|
|
|
[($doc-end) '(doc-end)]
|
|
|
|
|
[($page-start width height) (list height width 'page-start)]
|
|
|
|
|
[($page-end) '(page-end)]
|
|
|
|
|
[_ (error 'unknown-drawing-inst)])) " ")) "\n"))
|