Skip to content

Underline too low #5855

Open
Open
@barries

Description

@barries

Describe the bug

Text underlines are drawn a pixel or two too low--which is both odd looking and outside the galley's bounding box, so it collides with neighboring text.

To Reproduce
Steps to reproduce the behavior:

  1. Run code like the below
  2. Observe that the "Shortcuts" underline is visually too low, and the "Filters" underline is drawn over by the next row.

Screenshots

Image

Expected behavior
An underline that's in the galley's bounding box; meaning at or above the font descender line and below the baseline, something like:

Image

Desktop (please complete the following information):
egui: 0.31

Code

fn display_help_row(ui: &mut Ui, keys: impl Into<WidgetText>, desc: impl Into<WidgetText>) {
    ui.label(keys);                                                                                        
    ui.label(desc);                                                                                        
    ui.end_row();                                                                                          
}                                                                                                          
                                                                                                           
fn display_filter_help_row(ui: &mut Ui, code: &str, desc: impl Into<WidgetText>) {                         
    ui.label(RichText::new(code).background_color(CODE_BG_COLOR).color(CODE_COLOR));                       
    ui.label(desc);                                                                                        
    ui.end_row();                                                                                          
}
                                                                                                           
Grid::new("help")                                                                                          
    .spacing(vec2(3.0, 1.0))                                                                               
    .show(ui, |ui| {                                                                                       
        ui.heading(RichText::new("Shortcuts").underline());
        ui.end_row();                                                                                      
        display_help_row(ui, "Ctrl+N",              "[N]ew filter");                                       
        ...                                                                                                           
        ui.end_row(); // spacer                                                                            
        ui.heading(RichText::new("Filters").underline());                                                  
        ui.end_row();                                                                                      
                                                                                                           
        display_filter_help_row(ui, "/foo|bar/",            "Match regular expression"                 );
        ...                                                                                                           
    });                                                                                                    

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