diff --git a/plot-lib/plot/private/plot3d/plot-area.rkt b/plot-lib/plot/private/plot3d/plot-area.rkt index c6b6f85f..1bb03d53 100644 --- a/plot-lib/plot/private/plot3d/plot-area.rkt +++ b/plot-lib/plot/private/plot3d/plot-area.rkt @@ -2,7 +2,7 @@ (require typed/racket/class typed/racket/draw racket/match racket/list racket/math racket/flonum (only-in math fl vector->flvector) - (only-in typed/pict pict?) + (only-in typed/pict pict? pict-height) "../common/type-doc.rkt" "../common/types.rkt" "../common/math.rkt" @@ -372,7 +372,13 @@ (fl- area-y-mid (fl* z area-per-view-z)))))) (: init-top-margin Real) - (define init-top-margin (if (and (plot-decorations?) (plot-title)) (* 3/2 char-height) 0)) + (define init-top-margin + (let ([title (plot-title)]) + (cond [(and (plot-decorations?) title) + (if (pict? title) + (+ (pict-height title) (* 1/2 char-height)) + (* 3/2 char-height))] + [else 0]))) ;; Initial view->dc (: view->dc (-> FlVector (Vectorof Real))) diff --git a/plot-test/plot/tests/PRs/76.rkt b/plot-test/plot/tests/PRs/76.rkt new file mode 100644 index 00000000..9e947d81 --- /dev/null +++ b/plot-test/plot/tests/PRs/76.rkt @@ -0,0 +1,25 @@ +#lang racket +(require rackunit + plot pict + racket/draw + racket/runtime-path + "../helpers.rkt") + +;; Tests for: https://github.com/racket/plot/pull/68 + +(define (do-plot-title output-fn) + (output-fn + (surface3d (λ (x y) 1) 0 1 0 1) + #:title (standard-fish 100 50))) + +(define-runtime-path pr76-data "./test-data/pr76.dat") + +(define pr76-test-suite + (test-suite + "PR#76: pict title for plot3d" + (test-case "pr76-plot3d-title" + (check-draw-steps-3d do-plot-title pr76-data)))) + +(module+ test + (require rackunit/text-ui) + (run-tests pr76-test-suite)) diff --git a/plot-test/plot/tests/PRs/test-data/pr76.dat b/plot-test/plot/tests/PRs/test-data/pr76.dat new file mode 100644 index 00000000..bc0ae731 Binary files /dev/null and b/plot-test/plot/tests/PRs/test-data/pr76.dat differ diff --git a/plot-test/plot/tests/PRs/test-data/pr76.png b/plot-test/plot/tests/PRs/test-data/pr76.png new file mode 100644 index 00000000..73bfc1a2 Binary files /dev/null and b/plot-test/plot/tests/PRs/test-data/pr76.png differ