light/dark

SVG DPI Example

Source code to produce the test images:

(defun foo (dpi)
  (with-output-to-svg-file (o "/tmp/foo.svg" :if-exists :supersede
                              :dpi dpi)
    (with-drawing-options (o :text-size (* 10 (/ dpi 72)))
      (draw-text* o (format nil ":DPI = ~D." dpi) 0 (* 5/4 dpi))
      (let ((x dpi))
        (draw-line* o 0 0 x 0)
        (draw-line* o 0 -5 0 5)
        (draw-line* o x -5 x 5)
        (draw-text* o "1in" (/ x 2) 8
                    :align-y :top :align-x :center))
      (with-translation (o 0 (* 1/2 dpi))
        (let ((x 200))
          (draw-line* o 0 0 x 0)
          (draw-line* o 0 -5 0 5)
          (draw-line* o x -5 x 5)
          (draw-text* o "200px" (/ x 2) 8
                      :align-y :top :align-x :center)))
      (with-translation (o (* 7/2 dpi) (/ dpi 2))
        (labels ((mm (x) (* dpi (/ x 25.4))))
          (draw-circle* o 0 0 (/ (mm 23.25) 2) :ink +gold-2+)
          (draw-circle* o 0 0 (mm (- (/ 23.25 2) 3)) :ink +gray-75+)
          (draw-circle* o 0 0 (/ (mm 23.25) 2)
                        :ink +black+
                        :line-thickness 2
                        :filled nil)
          (draw-text* o "1€ coin" 0 0
                      :align-y :center :align-x :center)) ))))

(foo 72) yields:

While (foo 96) gives me:

Apart from browsers having different ideas about what their output device resolution is, the "1in" bar should render same length in both images.

CSS

1in



200px