Skip to content

No longer able to use Galley for custom text layout in label #7882

@wsalmonct

Description

@wsalmonct

I am assuming that I'm doing something silly and there is a good way todo this.

If thats true can this Issue be closed with a PR to https://docs.rs/egui/latest/egui/struct.Galley.html with a example of how to render a Galley? I can write this if some one points me in the right direction.

Describe the bug

When updating from 0.32 to 0.33 I can no longer render a Galley into a Label

        let mut truncated = LayoutJob {
            wrap: TextWrapping::truncate_at_width(width),
            ..LayoutJob::default()
        };
        truncated.append(self.0, 0.0, TextFormat::default());
        let galley = ui.fonts(|f| *f.layout_job(truncated));
        ui.label(galley);

gives

error[E0277]: the trait bound `WidgetText: From<eframe::egui::Galley>` is not satisfied
    --> crates/gui/src/panels/components.rs:132:18
     |
 132 |         ui.label(galley);
     |            ----- ^^^^^^ unsatisfied trait bound
     |            |
     |            required by a bound introduced by this call
     |
     = help: the trait `From<eframe::egui::Galley>` is not implemented for `WidgetText`
     = help: the following other types implement trait `From<T>`:
               `WidgetText` implements `From<&Box<str>>`
[...]
             and 3 others
     = note: required for `eframe::egui::Galley` to implement `Into<WidgetText>`
note: required by a bound in `Ui::label`
    --> /home/will/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/egui-0.33.3/src/ui.rs:1988:40
     |
1988 | ...lf, text: impl Into<WidgetText>) -> Response {
     |                   ^^^^^^^^^^^^^^^^ required by this bound in `Ui::label`

The working code at 0.32 is https://gitlab.com/CodethinkLabs/trustable/stpa-tools/-/blob/767d29dfdb59480044ce2499c6d565a756b1eac3/crates/gui/src/panels/components.rs#L132

To Reproduce

update https://gitlab.com/CodethinkLabs/trustable/stpa-tools from egui 0.32 to 0.33

Expected behavior

There should be a easy way to use a Galley as input to a ui.label()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions