Skip to content

Conversation

@robinduckett
Copy link

SVG images failed to load with the error "loading svg: invalid size" because hyprlock was not passing the configured size to hyprgraphics' CImage constructor.

Unlike raster formats, SVG requires a target render size since it's vector-based. The CImage class has a two-argument constructor CImage(path, size) for this, but getCairoSurfaceFromImageFile() was only using the single-argument constructor, resulting in a 0x0 render target.

This fix passes the image widget's configured size parameter through the preload request props to renderImage(), which then forwards it to getCairoSurfaceFromImageFile().

Caveats

This PR probably should not be merged for the following reasons:

  1. The current size option is not well-suited for SVG rendering - SVGs are rendered as square (size × size), ignoring intrinsic aspect ratio
  2. A proper fix would require separate width/height options and querying intrinsic SVG dimensions from librsvg
  3. Given the ongoing port to hyprtoolkit (core: add a greetd login backend #731), this may be better addressed there with a more complete implementation

Submitting this as a reference for the issue and as a potential stopgap if needed.

Fixes #940

SVG images require a target size to be rendered, but hyprlock was
creating CImage without passing the size parameter. This caused
hyprgraphics to fail with "loading svg: invalid size" error.

This fix passes the image widget's configured size through the
preload request props to getCairoSurfaceFromImageFile(), which
then uses the two-argument CImage constructor for SVG files.

Fixes hyprwm#940
@vaxerski
Copy link
Member

looks like it needs a rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loading svg: invalid size

2 participants