diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 723181f56..7ce38d8a6 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -213,9 +213,9 @@ fn xmain() -> ! { TextBounds::GrowableFromBl(bl, width) => blitstr2::Pt::new(width as usize - tv.margin.x as usize * 2, bl.y as usize - tv.margin.y as usize * 2), TextBounds::GrowableFromTl(tl, width) => - blitstr2::Pt::new(width as usize - tv.margin.x as usize * 2, (clip_rect.br().y - tl.y) as usize - tv.margin.y as usize * 2), + blitstr2::Pt::new(width as usize - tv.margin.x as usize * 2, (clip_rect.br().y - clip_rect.tl().y - tl.y) as usize - tv.margin.y as usize * 2), TextBounds::GrowableFromTr(tr, width) => - blitstr2::Pt::new(width as usize - tv.margin.x as usize * 2, (clip_rect.br().y - tr.y) as usize - tv.margin.y as usize * 2), + blitstr2::Pt::new(width as usize - tv.margin.x as usize * 2, (clip_rect.br().y - clip_rect.tl().y - tr.y) as usize - tv.margin.y as usize * 2), }; let mut typesetter = Typesetter::setup( tv.to_str(), diff --git a/services/graphics-server/src/testing.rs b/services/graphics-server/src/testing.rs index 2518c1360..1438ee0c4 100644 --- a/services/graphics-server/src/testing.rs +++ b/services/graphics-server/src/testing.rs @@ -13,7 +13,7 @@ enum TestType { Overflow = 5, End = 6, } -const TEST_STYLE: GlyphStyle = GlyphStyle::Large; +const TEST_STYLE: GlyphStyle = GlyphStyle::Regular; pub fn tests() { let _ = std::thread::spawn({ move || { @@ -58,8 +58,8 @@ pub fn tests() { tv.style = TEST_STYLE; tv.ellipsis = true; tv.rounded_border = Some(4); - write!(tv, "This is a test of basic word wrapping inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); - write!(tv, "Let's add more text until it overflows this is just another test with https://github.com/samblenny/blitstr2/commit/bb7d4ab6a2d8913dcb520895a3c242c933413aae more words and words and words and whatever.").unwrap(); + write!(tv, "This is a test of basic word wrapping 自动换行 inside a 😃 bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); + write!(tv, "Let's add more text😃 until it overflows this is just another test with https://github.com/samblenny/blitstr2/commit/bb7d4ab6a2d8913dcb520895a3c242c933413aae more words and words and words and whatever.").unwrap(); log::info!("rendering: {:?}", tv); tv.insertion = None; gfx.draw_textview(&mut tv).unwrap(); @@ -77,7 +77,7 @@ pub fn tests() { tv.style = TEST_STYLE; tv.ellipsis = true; tv.rounded_border = Some(8); - write!(tv, "This is a test of basic word wrapping inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); + write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); tv.insertion = Some(8); gfx.draw_textview(&mut tv).unwrap(); @@ -96,7 +96,7 @@ pub fn tests() { tv.ellipsis = true; tv.rounded_border = None; tv.invert = true; - write!(tv, "This is a test of basic word wrapping inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); + write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); tv.insertion = Some(0); gfx.draw_textview(&mut tv).unwrap(); @@ -114,7 +114,7 @@ pub fn tests() { tv.style = TEST_STYLE; tv.ellipsis = false; tv.rounded_border = Some(12); - write!(tv, "This is a test of basic word wrapping inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); + write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); tv.insertion = Some(20); gfx.draw_textview(&mut tv).unwrap(); @@ -132,7 +132,7 @@ pub fn tests() { tv.style = TEST_STYLE; tv.ellipsis = false; tv.rounded_border = None; - write!(tv, "This is a test of basic word wrapping inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); + write!(tv, "This is a test of basic word😃 wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); tv.insertion = Some(21); gfx.draw_textview(&mut tv).unwrap(); @@ -162,7 +162,7 @@ pub fn tests() { tv.style = TEST_STYLE; tv.ellipsis = false; tv.rounded_border = None; - write!(tv, "This is a test of basic word wrapping inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); + write!(tv, "This is a test of basic word wrapping 自动换行 inside a bounding box.\nThis should be a new line.\n\nTwo new lines.\nNew line\n with a leading space.\nDone.").unwrap(); log::info!("rendering: {:?}", tv); tv.insertion = Some(21); gfx.draw_textview(&mut tv).unwrap(); diff --git a/services/graphics-server/src/wordwrap.rs b/services/graphics-server/src/wordwrap.rs index 7a01b2923..e0b589603 100644 --- a/services/graphics-server/src/wordwrap.rs +++ b/services/graphics-server/src/wordwrap.rs @@ -442,7 +442,6 @@ impl Typesetter { // other states "start where they left off" } } - log::info!("bb: {:?}", ret.bounding_box); ret } fn is_newline_available(&self) -> bool { @@ -452,7 +451,7 @@ impl Typesetter { } else { self.candidate.height }; - log::info!("{} < {}", corrected_height + self.cursor.pt.y + self.cursor.line_height, self.bb.max.y); + log::trace!("{} < {}", corrected_height + self.cursor.pt.y + self.cursor.line_height, self.bb.max.y); corrected_height + self.cursor.pt.y + self.cursor.line_height < self.bb.max.y } fn does_word_fit_on_line(&self) -> bool { @@ -479,7 +478,7 @@ impl Typesetter { self.cursor.line_height = self.cursor.line_height.max(self.candidate.height); self.last_line_height = self.cursor.line_height; } - tsw_debug(&self.candidate); + if false {tsw_debug(&self.candidate)}; self.charpos += 1; composition.push( std::mem::replace(