Function: shr--width-spec
shr--width-spec is a byte-compiled function defined in shr.el.gz.
Signature
(shr--width-spec PIXEL-WIDTH)
Documentation
Return a pixel specification for PIXEL-WIDTH in relative units.
This converts a PIXEL-WIDTH in pixels to units of the average-width of
the current face before point, like (N . width). That way, the
indentation is calculated correctly when using text-scale-adjust.
Source Code
;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
(defun shr--width-spec (pixel-width)
"Return a pixel specification for PIXEL-WIDTH in relative units.
This converts a PIXEL-WIDTH in pixels to units of the average-width of
the current face before point, like (N . width). That way, the
indentation is calculated correctly when using `text-scale-adjust'."
(let ((avg-space (propertize (buffer-substring (1- (point)) (point))
'display '(space :width (1 . width)))))
(cons (/ (float pixel-width) (string-pixel-width avg-space)) 'width)))