From 842daed2a30b8bbbfefbdfd0b097f354a9679e51 Mon Sep 17 00:00:00 2001 From: qiudejia Date: Sat, 11 Oct 2025 15:56:27 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=AE=BD=E5=BA=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a5dfaa8f16c2877dd951ae3322df18db5c8fd16c. --- src/qelmt/dynamictext.rs | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/qelmt/dynamictext.rs b/src/qelmt/dynamictext.rs index 8253799..c186e6f 100644 --- a/src/qelmt/dynamictext.rs +++ b/src/qelmt/dynamictext.rs @@ -169,8 +169,6 @@ impl ScaleEntity for DynamicText { self.y *= fact_y; self.align_x *= fact_x; self.align_y *= fact_y; - self.text_width *= fact_x.abs(); - self.text_height *= fact_y.abs(); self.font.scale(fact_y); } @@ -179,7 +177,8 @@ impl ScaleEntity for DynamicText { } fn right_bound(&self) -> f64 { - self.x + self.text_width + //todo!() + 1.0 } fn top_bound(&self) -> f64 { @@ -187,7 +186,8 @@ impl ScaleEntity for DynamicText { } fn bot_bound(&self) -> f64 { - self.y - self.text_height + //todo!() + 1.0 } } @@ -358,14 +358,8 @@ impl<'a> DTextBuilder<'a> { dbg!(&y); dbg!(&self.text);*/ let value = super::strip_mtext_control_sequences(&value); - // 将 DXF 中读取到的 text_height 放大 2 倍(用户要求) + // 将 DXF 中读取到的 text_height 放大 2 倍(用户要求) let text_height = text_height * 2.0; - let text_width = if reference_rectangle_width > 0.0 { - reference_rectangle_width - } else { - estimate_text_width(&value, text_height) - }; - DynamicText { //x: x - (calc_width as f64/2.0), x, @@ -393,7 +387,7 @@ impl<'a> DTextBuilder<'a> { text_from: "UserText".into(), frame: false, text_height, - text_width, + text_width: -1.0, // for now, until I figure out what this should be color: self.color.unwrap_or(HexColor::BLACK), text: value, @@ -488,21 +482,3 @@ pub fn adjust_mtext_coordinates( (adjusted_x, adjusted_y) } - -fn estimate_text_width(text: &str, line_height: f64) -> f64 { - let effective_height = line_height.abs(); - if effective_height == 0.0 { - return 0.0; - } - - let max_graphemes = text - .lines() - .map(|line| line.graphemes(true).count() as f64) - .fold(0.0, f64::max); - - if max_graphemes > 0.0 { - max_graphemes * effective_height * 0.75 - } else { - effective_height - } -}