mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Fix crash in text layout (#1468)
Fix text layout bug added in https://github.com/emilk/egui/pull/1291
This commit is contained in:
@@ -249,7 +249,7 @@ fn line_break(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if row_start_idx < paragraph.glyphs.len() {
|
if row_start_idx < paragraph.glyphs.len() {
|
||||||
if non_empty_rows == job.wrap.max_rows {
|
if job.wrap.max_rows > 0 && non_empty_rows == job.wrap.max_rows {
|
||||||
if let Some(last_row) = out_rows.last_mut() {
|
if let Some(last_row) = out_rows.last_mut() {
|
||||||
replace_last_glyph_with_overflow_character(fonts, job, last_row);
|
replace_last_glyph_with_overflow_character(fonts, job, last_row);
|
||||||
}
|
}
|
||||||
@@ -773,3 +773,14 @@ fn is_chinese(c: char) -> bool {
|
|||||||
|| ('\u{3400}' <= c && c <= '\u{4DBF}')
|
|| ('\u{3400}' <= c && c <= '\u{4DBF}')
|
||||||
|| ('\u{2B740}' <= c && c <= '\u{2B81F}')
|
|| ('\u{2B740}' <= c && c <= '\u{2B81F}')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_zero_max_width() {
|
||||||
|
let mut fonts = FontsImpl::new(1.0, 1024, super::FontDefinitions::default());
|
||||||
|
let mut layout_job = LayoutJob::single_section("W".into(), super::TextFormat::default());
|
||||||
|
layout_job.wrap.max_width = 0.0;
|
||||||
|
let galley = super::layout(&mut fonts, layout_job.into());
|
||||||
|
assert_eq!(galley.rows.len(), 1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user