anchor.diff:                  (text-style-mapping (port medium) (medium-text-style medium))))))))
   
   ;;; Translate from CLIM styles to CLX styles.
  -(defconstant +cap-shape-map+ '((:butt . :butt)
  -                               (:square . :projecting)
  -                               (:round . :round)
  -                               (:no-end-point . :not-last)))
  -
   (defun translate-cap-shape (clim-shape)
  -  (let ((clx-shape (cdr (assoc clim-shape +cap-shape-map+))))
  -    (if clx-shape
  -        clx-shape
  -        (progn
  -          (warn "Unknown cap style ~S, using :round" clim-shape)
  -          :round))))
  +  (case clim-shape
  +    (:butt         :butt)
  +    (:square       :projecting)
  +    (:round        :round)
  +    (:no-end-point :not-last)
  +    (otherwise
  +     (prog1 :round
  +       (warn "Unknown cap style ~S, using :round." clim-shape)))))
  +
  +(defun translate-join-shape (clim-shape)
  +  (case clim-shape
  +    (:miter :miter)
  +    (:bevel :bevel)
  +    (:round :round)
  +    (:none
  +     (prog1 :miter
  +       (warn "Unsupported join style :NONE, using :MITER.")))
  +    (otherwise
  +     (prog1 :miter
  +       (warn "Unknown join style ~s, using :MITER." clim-shape)))))
  +
   
   ;;; XXX: this should be refactored into a reusable protocol in clim-backend
   ;;; with specialization on medium. -- jd 2018-10-31
  
positive.code:                      (sqrt (+ (expt x 2) (expt y 2))))))))
  
  (defun line-style-effective-thickness (line-style medium)
    (round (* (line-style-thickness line-style)
              (line-style-scale line-style medium))))
  
  (defun line-style-effective-dashes (line-style medium)
    (let ((scale (line-style-scale line-style medium)))
      (map 'list #'(lambda (dash) (round (* dash scale)))
           (line-style-dashes line-style))))
  
  (defmethod (setf medium-line-style) :before (line-style (medium clx-medium))
    (with-slots (gc) medium
  
negative.code:         (unless (eq (line-style-joint-shape line-style)
                      (line-style-joint-shape old-line-style))
            (setf (xlib:gcontext-join-style gc)
                  (translate-join-shape (line-style-joint-shape line-style))))
          ;; we could do better here by comparing elements of the vector
          ;; -RS 2001-08-24
          (unless (and (eq (line-style-dashes line-style)
                           (line-style-dashes old-line-style))
                       (eq (line-style-unit line-style)
                           (line-style-unit old-line-style)))
            (if-let ((dash-pattern (line-style-effective-dashes line-style medium)))
              (setf (xlib:gcontext-line-style gc) :dash
                    (xlib:gcontext-dashes gc) (if (atom dash-pattern)
                                                  (round dash-pattern)
                                                  (mapcar #'round dash-pattern)))
              (setf (xlib:gcontext-line-style gc) :solid)))))))
  
  (defmethod (setf medium-transformation) :around (transformation (medium clx-medium))
    (let ((old-tr     (medium-transformation medium))
          (line-style (medium-line-style medium))
          (new-tr     (call-next-method)))
      (unless (and (eq :coordinate (line-style-unit line-style))
                   (not (transformation-equal old-tr new-tr)))
        (when-let ((gc (slot-value medium 'gc)))
          (setf (xlib:gcontext-line-width gc)
                (round (line-style-effective-thickness line-style medium)))
          (if-let ((dash-pattern (line-style-effective-dashes line-style medium)))
            (setf (xlib:gcontext-line-style gc) :dash
                  (xlib:gcontext-dashes gc) (if (atom dash-pattern)
                                                (round dash-pattern)
                                                (mapcar #'round dash-pattern)))
            (setf (xlib:gcontext-line-style gc) :solid))))
      new-tr))
  
  (defun %clip-region-pixmap (medium mask mask-gc clipping-region x1 y1 width height)
    (typecase clipping-region
  