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

89 lines
2.5 KiB
Racket

3 years ago
#lang debug racket/base
(require "layout.rkt"
"quad.rkt"
3 years ago
"pipeline.rkt"
"linearize.rkt"
"layout.rkt"
"draw.rkt"
"attr.rkt"
"attr-passes.rkt"
"font.rkt"
"constants.rkt"
"param.rkt"
"page.rkt"
racket/list
racket/match
racket/file)
(define quad-compile
3 years ago
(make-pipeline
;; each pass in the pipeline is at least
;; (list-of quad?) -> (list-of quad?)
3 years ago
;; attribute prep =============
;; all attrs start out as symbol-string pairs.
;; we convert keys & values to corresponding higher-level types.
upgrade-attr-keys
downcase-string-attr-values
convert-boolean-attr-values
convert-numeric-attr-values
convert-set-attr-values
convert-path-attr-values
3 years ago
;; wrap default values around top level
set-top-level-attr-values
3 years ago
;; pre-linearization resolutions & parsings =============
;; these need the tree shape
parse-dimension-strings
resolve-font-sizes
resolve-font-features
parse-page-sizes
resolve-font-paths
complete-attr-paths
3 years ago
3 years ago
;; linearization =============
;; we postpone this step until we're certain any
;; information encoded from the hierarchy of quads
;; has been absorbed into the attrs
;; (e.g., cascading font sizes)
;; because once we linearize, that information is gone.
linearize
3 years ago
;; post-linearization resolutions & parsings =============
3 years ago
mark-text-runs
merge-adjacent-strings
split-whitespace
split-into-single-char-quads
fill-missing-font-path
remove-font-without-char
insert-fallback-font
3 years ago
append-bop-and-eop
append-boq-and-eoq
3 years ago
layout
3 years ago
make-drawing-insts
3 years ago
stackify))
(module+ main
(require "render.rkt")
(define (test-compile x)
(define characters-in-line 13)
(define monospaced-em-width 0.6)
(parameterize ([current-wrap-width (* characters-in-line monospaced-em-width default-font-size)]
[current-attr-keys all-attr-keys]
[current-strict-attrs? #t]
[current-show-timing? #f]
[current-use-preconditions? #t]
[current-use-postconditions? #t])
(quad-compile (bootstrap-input x))))
3 years ago
(match (test-compile "WHO")
[(? string? insts)
(displayln insts)
3 years ago
#;(render insts #:using text-renderer)
#;(render insts #:using drr-renderer)
(render insts #:using (html-renderer (build-path (find-system-path 'desk-dir) "test.html")))
#;(render-to-pdf drawing-insts)
]))
3 years ago