Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text rendering cuts off whole words in some cases #782

Closed
Kaiden42 opened this issue Mar 17, 2021 · 5 comments
Closed

Text rendering cuts off whole words in some cases #782

Kaiden42 opened this issue Mar 17, 2021 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed layout rendering text
Milestone

Comments

@Kaiden42
Copy link
Contributor

Hello, I noticed that the text rendering cuts off whole words. It seems that the width of the characters is not calculated correctly. Maybe a rounding mistake?

text_bug

Here is a small example, using the latest master, to reproduce this behavior:

use iced::{Column, Container, Length, Sandbox, Settings, Text};

fn main() -> iced::Result {
    TextBug::run(Settings::default())
}

struct TextBug {}

#[derive(Debug)]
enum Message {}

impl Sandbox for TextBug {
    type Message = Message;
    fn new() -> Self { TextBug {} }
    fn title(&self) -> String { "TextBug".into() }
    fn update(&mut self, _message: Self::Message) {}
    fn view(&mut self) -> iced::Element<'_, Self::Message> {
        Container::new(
            Column::new()
                .push(Text::new("Toggle Word Wrap"))
                .push(Text::new("Toggle Word wrap"))
                .push(Text::new("Toggle Wörd Wräp"))
                .push(Text::new("Toggle Wird Wrap"))
                .push(Text::new("Toggle Word Wrip"))
                .push(Text::new("Toggle Word? Wrap"))
                .push(Text::new("Toggle Word Wrap?"))
        )
        .width(Length::Fill)
        .height(Length::Fill)
        .center_x()
        .center_y()
        .into()
    }
}
@hecrj hecrj added bug Something isn't working help wanted Extra attention is needed labels Mar 17, 2021
@hecrj hecrj added this to the 0.3.0 milestone Mar 17, 2021
@hecrj
Copy link
Member

hecrj commented Mar 19, 2021

I can reproduce the issue on Linux if I manually set a WINIT_SCALE_FACTOR of 2.0 and use the default system font.

Most likely, this is related to this TODO:

https://github.com/hecrj/iced/blob/0333a8daff6db989adc6035a4c09df171a86f6fe/wgpu/src/backend.rs#L176-L184

@lufte
Copy link
Contributor

lufte commented Mar 14, 2022

I'm hitting this issue when using an italic font on linux, with everything else set on default values. Any workaround you know of?

@hecrj hecrj modified the milestones: 0.4.0, 0.5.0 Apr 12, 2022
@hecrj hecrj modified the milestones: 0.5.0, 0.6.0 Nov 9, 2022
@hecrj hecrj modified the milestones: 0.6.0, 0.7.0 Dec 7, 2022
@IohannRabeson
Copy link

IohannRabeson commented Jan 11, 2023

Hi, I'm hitting this issue on OSX and Windows as well.
You can see it does not happen with any text. In the following screenshot, the second file name only file2.txt is missing.
Screenshot 2023-01-11 at 18 05 22
I can confirm I get the same behavior with this code on OSX (Catalina) and on Windows.

https://gist.github.com/IohannRabeson/d3f6ed5436e392da8a4f730573c8aeb3

@hecrj hecrj modified the milestones: 0.7.0, 0.8.0 Jan 14, 2023
@GyulyVGC
Copy link
Contributor

GyulyVGC commented Feb 3, 2023

I had this problem when using a font different from the default one. Setting the font used as default font solved the issue in my case. I think this could be due to iced calculating the width basing on the default font width (maybe?).

I'll leave this comment here in case it can be of any help.

@hecrj hecrj modified the milestones: 0.8.0, 0.9.0 Feb 18, 2023
@hecrj hecrj modified the milestones: 0.9.0, 0.10.0 Apr 13, 2023
@hecrj
Copy link
Member

hecrj commented Jul 3, 2023

Fixed by #1921.

@hecrj hecrj closed this as completed Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed layout rendering text
Projects
None yet
Development

No branches or pull requests

5 participants