bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44655: 28.0.50; Oversized SVG margin


From: Alan Third
Subject: bug#44655: 28.0.50; Oversized SVG margin
Date: Sat, 6 Nov 2021 12:55:49 +0000

On Fri, Nov 05, 2021 at 12:28:37PM -0700, Paul Eggert wrote:
> I ran into a problem building Emacs with Fedora 35 (released 3 days ago)
> related to the fix for bug#44655, and installed the attached to try to work
> around the issue (which is due to the deprecation of
> rsvg_handle_get_dimensions in librsvg 2.52.0 (2021-09-15)).

There seems to be a lot of churn in the librsvg API at the moment, and
their documentation isn't keeping up as it still doesn't mark
rsvg_handle_get_dimensions as deprecated.

It appears they've introduced rsvg_handle_get_intrinsic_size_in_pixels
which does the same thing (but better) than my sizing code, but anyone
using librsvg 2.46-2.52, which is probably most people for now, can't
use it and probably don't want to use the old scheme, so I expect
there's no point replacing my code at the moment.

> -  if (viewbox_width == 0 || viewbox_height == 0)
> +#else
> +  /* In librsvg before 2.46.0, guess the viewbox from the image dimensions.  
> */
> +  RsvgDimensionData dimension_data;
> +  rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
> +  viewbox_width = dimension_data.width;
> +  viewbox_height = dimension_data.height;
>  #endif
> -  {
> -    /* The functions used above to get the geometry of the visible
> -       area of the SVG are only available in librsvg 2.46 and above,
> -       so in certain circumstances this code path can result in some
> -       parts of the SVG being cropped.  */
> -    RsvgDimensionData dimension_data;
> -
> -    rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
> -
> -    viewbox_width = dimension_data.width;
> -    viewbox_height = dimension_data.height;
> -  }
>  
>    compute_image_size (viewbox_width, viewbox_height, img,
>                        &width, &height);

The fall through is in place because if the image size is defined in
units we don't know (e.g. % or ex) then we end up with no idea what
size it should be.

Perhaps what we should do is move the final "else" section of the
previous code block (where rsvg_handle_get_geometry_for_layer is
called) into its own block which is executed

  if (viewbox_width == 0 || viewbox_height == 0)

instead of only in the case where rsvg_handle_get_intrinsic_dimensions
fails to return any dimensions. That way we should have *some*
dimensions without having to call rsvg_handle_get_dimensions.
-- 
Alan Third





reply via email to

[Prev in Thread] Current Thread [Next in Thread]