+(define (lookup-paper-name module name landscape?)
+ "Look up @var{name} and return a number pair of width and height,
+where @var{landscape?} specifies whether the dimensions should be swapped
+unless explicitly overriden in the name."
+ (let* ((swapped?
+ (cond ((string-suffix? "landscape" name)
+ (set! name
+ (string-trim-right (string-drop-right name 9)))
+ #t)
+ ((string-suffix? "portrait" name)
+ (set! name
+ (string-trim-right (string-drop-right name 8)))
+ #f)
+ (else landscape?)))
+ (is-paper? (module-defined? module 'is-paper))
+ (entry (and is-paper?
+ (eval-carefully (assoc-get name paper-alist)
+ module
+ #f))))
+ (and entry is-paper?
+ (if swapped? (cons (cdr entry) (car entry)) entry))))
+
+(define (set-paper-dimensions m w h landscape?)