Skip to content

SVG DPI scaling issue with tiny-skia #2825

@njust

Description

@njust

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

When using an SVG on macOS with tiny-skia the layout is not correct:

pub const LOGO: &'static [u8] = include_bytes!("../res/circle.svg");

pub fn logo() -> Svg<'static> {
    svg(svg::Handle::from_memory(LOGO))
}

pub fn banner<'a, T: 'static>(title: &'static str) -> Element<'a, T> {
    let header_content = row![
        container(logo().height(64).width(64)).padding(Padding {
            right: 20.,
            ..Default::default()
        }),
        column![text("Header").size(24), text(title).size(20)]
    ];

    container(header_content)
        .padding(12)
        .width(Fill)
        .style(|_| container::Style {
            background: Some(Background::Color(Color::from_rgb8(246, 247, 250))),
            ..Default::default()
        })
        .into()
}
Image

It works fine using wgpu. I created a minimal repro for the issue here:
https://github.com/njust/iced-svg-issue.git

The issue exists on iced 0.13.1 and the current master (beddf49).

What is the expected behavior?

No layout issues. On Linux and Windows it's rendered as expected:

Linux

Image

Windows

Image

Version

crates.io release

Operating System

macOS

Do you have any log output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions