You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/quad2/main.rkt

53 lines
1.8 KiB
Racket

3 years ago
#lang debug racket/base
(require "layout.rkt"
"render.rkt"
"quad.rkt"
3 years ago
"pipeline.rkt"
"linearize.rkt"
"layout.rkt"
"draw.rkt"
racket/string
racket/match)
(define-pass (bootstrap x)
3 years ago
#:pre values
#:post quad?
(match x
3 years ago
[(or (? quad? q) (list (? quad? q))) q]
[(and (list (? quad?) ...) qs) (make-quad #:elems qs)]
[other (make-quad #:elems (list other))]))
3 years ago
(define-pass (make-weirdo-char-quads qs)
#:pre (list-of simple-quad?)
#:post (list-of simple-quad?)
(apply append
(for/list ([q (in-list qs)])
(match q
[(quad _ _ (list (? string? str)))
(for/list ([c (in-string str)])
(define new-attrs (make-hasheq (cons (cons 'char c) (hash->list (quad-attrs q)))))
(make-quad #:tag (quad-tag q)
#:attrs new-attrs
#:elems null))]
[_ (list q)]))))
(define quad-compile (make-pipeline (list
bootstrap
3 years ago
linearize
merge-adjacent-strings
split-whitespace
make-weirdo-char-quads
layout
3 years ago
make-drawing-insts
stackify)))
3 years ago
(define drawing-insts (parameterize ([current-wrap-width 13])
3 years ago
(quad-compile "Hello this is the earth")))
3 years ago
(displayln drawing-insts)
3 years ago
(render drawing-insts #:using text-renderer)
(render drawing-insts #:using drr-renderer)
3 years ago
#;(render-to-html drawing-insts)
#;(render-to-pdf drawing-insts)