iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
26.34k stars 1.28k forks source link

RTL Text Centering Issues #2816

Open mariinkys opened 1 month ago

mariinkys commented 1 month ago

Is your issue REALLY a bug?

Is there an existing issue for this?

Is this issue related to iced?

What happened?

Centering of RTL text not working properly inside of a button. In order to reproduce:

pub fn view(&self) -> iced::Element<'_, Message> {
        widget::Button::new(
            widget::Text::new("مرحبًا")
                .width(Length::Fill)
                .height(Length::Fill)
                .align_x(Alignment::Center)
                .align_y(Alignment::Center),
        )
        .width(Length::Fill)
        .height(Length::Fill)
        .into()
    }

Image

What is the expected behavior?

The text should be properly centered, as it happens with nor RTL text, for example:

pub fn view(&self) -> iced::Element<'_, Message> {
        widget::Button::new(
            widget::Text::new("Hello!")
                .width(Length::Fill)
                .height(Length::Fill)
                .align_x(Alignment::Center)
                .align_y(Alignment::Center),
        )
        .width(Length::Fill)
        .height(Length::Fill)
        .into()
    }

Image

Version

crates.io release

Operating System

Linux

Do you have any log output?

mariinkys commented 1 month ago

Wanted to add that this also happens when using the git version of iced.