Subject: bug#54688: 29.0.50; Sliced image in margin looks bad

From: dalanicolai <[email-masked]>
Date: Sun, 3 Apr 2022 13:04:55 +0200

I would think that this :ascent of 80, behaves how :ascent 50 (the default)
is supposed to behave?

On Sun, 3 Apr 2022 at 13:03, dalanicolai <[email-masked]> wrote:

> (Once more using reply-all)
>
> Playing around with :ascent, makes possible to keep the line-pixel-height
> fixed.
>
> So in the following I simply use `insert-image`. Without the :ascent, the
> 'line-pixel-height' increases when inserting another character. With the
> :ascent it is possible to reduce this 'increase'. For me the increase is 0
> when I use an ascent value of 80.
> (below the used code)
>
> (with-current-buffer (get-buffer-create "test")
>   (setq left-margin-width 5)
>   (insert-image (svg-image (let* ((ph (line-pixel-height))
>                                   (size ph)
>                                   (svg (svg-create size size)))
>                              (svg-circle svg ph ph ph :fill "red")
>                              svg)
>                            :ascent 80))
>   (switch-to-buffer (current-buffer)))
>
> On Sun, 3 Apr 2022 at 12:54, Eli Zaretskii <[email-masked]> wrote:
>
>> > From: dalanicolai <[email-masked]>
>> > Date: Sun, 3 Apr 2022 12:33:01 +0200
>> > Cc: [email-masked]
>> >
>> > Thank you for the quick reply. However, the height of the image,
>> > (* 2 (line-pixel-height)), is equal to twice the `default-font-height`
>> > (the 'line-pixel-height' and 'default-font-height' are equal, here both
>> > 17).
>> >
>> > So before I add the character after the image, (line-pixel-height)
>> > returns 17. But when I insert a character after it (with
>> > 'default-font-height' is 17), the `line-pixel-height` increases to
>> > 22. So I am not sure how to not let the line height increase.
>> > I will try to play a little with the :ascent value.
>>
>> Images can also have margins:
>>
>>   int
>>   image_ascent (struct image *img, struct face *face, struct glyph_slice
>> *slice)
>>   {
>>     int height;
>>     int ascent;
>>
>>     if (slice->height == img->height)
>>       height = img->height + img->vmargin;
>>     else if (slice->y == 0)
>>       height = slice->height + img->vmargin;
>>     else
>>       height = slice->height;
>>
>> Maybe those make the difference?
>>
>> In any case, once I add a character, the line height grows, which
>> tells us some vertical dimension somewhere is unaccounted for.
>>
>