Motivation:

It is essential to have functionality where image size adjusts
automatically to the display conditions.  Right now we have `em'
element to specify image size relative to the font size.  However,
this is not enough for the grain control of how the image is displayed.
Because for the same font, but different font sizes, ratio of font
height to font size and ratio of average font width to font size
**differs**.  Making it impossible to have the same image to look the same
for different font sizes of the same font.

Here is an example.  I need an image which occupies 2 chars, but in
the same time its height must not exceed line height:

  (defun my-em-width-ratio ()
    (let ((info (font-info (face-font 'default))))
      ;; avg-width / pixel-size
      (/ (float (aref info 11)) (aref info 2))))

  (defun my-em-height-ratio ()
    (let ((info (font-info (face-font 'default))))
      ;; height / pixel-size
      (/ (float (aref info 3)) (aref info 2))))

  (list 'image :type 'svg :file "file.svg" :scale 1.0 :ascent 'center
         :width (cons (* 2 (my-em-width-ratio)) 'em)
         :max-height (cons (* 1 (my-em-height-ratio)) 'em))

Note that `em' means font size and not the font height, but for some
fonts font size and font height differs.

This works very well.  However, if I execute `M-x text-scale-decrease
RET' or `M-x text-scale-increase RET' image starts looking
differently, not fitting into 2 chars width.  Because font ratios
changes.

Before scaling:
  (my-em-width-ratio)  => 0.5111111111111111
  (my-em-height-ratio) => 1.0666666666666667

After scaling:
  (my-em-width-ratio)  => 0.5135135135135135
  (my-em-height-ratio) => 1.054054054054054

With applied patch and image specified as:

  (list 'image :type 'svg :file "file.svg" :scale 1.0 :ascent 'center
         :width '(2 . cw)
         :max-height '(1 . ch))

Image looks the same and occupies exactly the same amount of
characters for different font sizes of the same font.

Thanks.

--
lg