-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Is your feature request related to a problem? Please describe.
I have a egui::TextEdit::multiline
where like to configure paragraph spacing (how many pixels are after a \n
in text). There doesn't seem to be a way to do this independently of line_height
, which is entirely different.
Describe the solution you'd like
epaint::text::text_layout_types::TextFormat
also getting a line_height option that specifically controls the height of newlines.
Describe alternatives you've considered
I tried to implement this manually in application code, so far unsuccessfully. I attempted to patch it in by setting line spacing at the start of every line (or to the newline character):
I've tried to add something like:
job.append(
"\n",
0.0,
TextFormat {
line_height: Some(40.0),
..Default::default()
},
);
here
egui/crates/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs
Lines 117 to 121 in fdcaff8
job.append( | |
&text[..line_end], | |
0.0, | |
format_from_style(egui_style, &style), | |
); |
but a newline or empty string does nothing, and non-printable characters (i.e., \u200b
) are printed as spaces anyway.
I think that I can make it work (mostly) by adjusting the line_height
of the first actual character of every line. This will still be hacky with empty lines and the cursor UI, and will make application parsing code more complex to work around this, but it should be entirely possible.
Additional context
Originally opened #7357, before being increasingly confident that this doesn't exist, so this is being opened as a feature request.
I think the answer probably is somewhere in https://github.com/emilk/egui/blob/main/crates/epaint/src/text/text_layout.rs, but I'm not familiar enough with the code to find it.
I'm trying to work with code that's substantially similar to https://github.com/emilk/egui/blob/main/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs, none of the differences are relevant here.
I've looked for similar issues, discussions, and even egui code that implements this, but I couldn't find anything. A pointer to somewhere else that implements this would be great too. I found a few commits referencing paragraph spacing such as 7336df5, but this was before the text layouting was rewritten in de1a1ba, so that was a dead end.