Skip to content

RichText span colors can be incorrect because of ligatures #3166

@e-matteson

Description

@e-matteson

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?

I can't use RichText to write "fish" with the "f" and "i" in different font colors. I assume that's because a single ligature glyph is used for "fi". It's not that big a problem and I'm not sure if there's a good solution, but I figured I'd report it because RichText is not behaving as expected or documented.

Example that shows "fi" in red and "sh" in green, instead of "f" in red and "ish" in green:

use iced::{color, widget::{rich_text, text}};
struct S;
impl S {
    fn new() -> S {
        S {}
    }

    fn update(&mut self, _msg: ()) {}

    fn view(&self) -> text::Rich<'_, (), ()> {
        let red = color!(0xff0000);
        let green = color!(0x00ff00);
        let mut spans = Vec::new();
        spans.push(text::Span::new('f').color(red));
        spans.push(text::Span::new('i').color(green));
        spans.push(text::Span::new('s').color(green));
        spans.push(text::Span::new('h').color(green));
        rich_text(spans)
    }
}

fn main() {
    iced::application(S::new, S::update, S::view).run();
}

What is the expected behavior?

"f" in red and "ish" in green

Version

crates.io release

Operating System

Linux

Do you have any log output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions