Subject: Re: bug#75712: HAVE_RSVG: svg_css_length_to_pixels doesn't handle RSVG_UNIT_CH

From: Eli Zaretskii <[email-masked]>
Date: Tue, 21 Jan 2025 15:59:16 +0200

> Cc: Pip Cet <[email-masked]>
> From: Stefan Kangas <[email-masked]>
> Date: Mon, 20 Jan 2025 20:25:18 -0600
> 
> --- a/src/image.c
> +++ b/src/image.c
> @@ -12008,9 +12008,15 @@ svg_css_length_to_pixels (RsvgLength length, double dpi, int font_size)
>  	 what size we make the image.  */
>        value = 0;
>        break;
> -    default:
> -      /* We should never reach this.  */
> -      value = 0;
> +#if LIBRSVG_CHECK_VERSION (2, 58, 0)
> +    case RSVG_UNIT_CH:
> +      /* FIXME: With CSS 3, "the ch unit falls back to 0.5em in the
> +	 general case, and to 1em when it would be typeset upright".
> +	 However, I could not find a way to easily get the relevant CSS
> +	 attributes using librsvg.  Thus, we simply wrongly assume the
> +	 general case is always true here.  See Bug#75712.  */
> +      value = value * font_size / 2.0;
> +#endif

This makes the code worse for librsvg versions before 2.58.  Why not
keep the old code for older versions?

Also, pointing to bug#75712 is not useful here: this bug had accrued
too many completely unrelated messages, so anyone who'd like to have
more details about this issue will curse us.  How about explaining the
main issues here in this very comment instead?

Thanks.