main
Matthew Butterick 2 years ago
parent c574a9a844
commit 9e005433b0

@ -18,21 +18,16 @@
(not (quad-has-key? x :page-orientation))))
(define (parse-page-size attrs)
;; if set, debug-page-width and debug-page-height override the requested width & height
(define width (or (debug-page-width) (hash-ref attrs :page-width #false)))
(define height (or (debug-page-height) (hash-ref attrs :page-height #false)))
(define size (hash-ref attrs :page-size default-page-size))
(define orientation (hash-ref attrs :page-orientation default-page-orientation))
;; parsed-width and parsed-height are derived from named size & orientation
(match-define (list parsed-width parsed-height)
(sort
(page-sizes-ref size default-page-size)
(page-sizes-ref (hash-ref attrs :page-size default-page-size))
;; for portrait, shorter edge is width
(if (member orientation '("portrait" "tall")) < >)))
(if (member (hash-ref attrs :page-orientation default-page-orientation) '("portrait" "tall")) < >)))
(hash-set! attrs :page-width (or width parsed-width))
(hash-set! attrs :page-height (or height parsed-height))
;; if set, debug-page-width and debug-page-height override the requested width & height
(hash-set! attrs :page-width (or (debug-page-width) (hash-ref attrs :page-width #false) parsed-width))
(hash-set! attrs :page-height (or (debug-page-height) (hash-ref attrs :page-height #false) parsed-height))
(hash-remove! attrs :page-size)
(hash-remove! attrs :page-orientation)
attrs)

Loading…
Cancel
Save