diff --git a/src/ui/text_svg.rs b/src/ui/text_svg.rs index 0edf35f..64e0043 100644 --- a/src/ui/text_svg.rs +++ b/src/ui/text_svg.rs @@ -279,20 +279,20 @@ impl TextSvg { let line_spacing = 10.0; let text_and_line_spacing = font_size + line_spacing; - let (text_anchor, starting_y_position, x_position) = + let (text_anchor, starting_y_position, text_x_position) = match self.alignment { - TextAlignment::TopLeft => ("start", font_size, "0"), + TextAlignment::TopLeft => ("start", font_size, "10"), TextAlignment::TopCenter => { - ("middle", font_size, "50%") + ("middle", font_size, "990") } - TextAlignment::TopRight => ("end", font_size, "100%"), + TextAlignment::TopRight => ("end", font_size, "1910"), TextAlignment::MiddleLeft => { let middle_position = size.height / 2.0; let position = half_lines.mul_add( -text_and_line_spacing, middle_position, ); - ("start", position, "0") + ("start", position, "10") } TextAlignment::MiddleCenter => { let middle_position = size.height / 2.0; @@ -300,7 +300,7 @@ impl TextSvg { -text_and_line_spacing, middle_position, ); - ("middle", position, "50%") + ("middle", position, "990") } TextAlignment::MiddleRight => { let middle_position = size.height / 2.0; @@ -308,29 +308,29 @@ impl TextSvg { -text_and_line_spacing, middle_position, ); - ("end", position, "100%") + ("end", position, "1910") } TextAlignment::BottomLeft => { let position = size.height - (total_lines as f32 * text_and_line_spacing); - ("start", position, "0") + ("start", position, "10") } TextAlignment::BottomCenter => { let position = size.height - (total_lines as f32 * text_and_line_spacing); - ("middle", position, "50%") + ("middle", position, "990") } TextAlignment::BottomRight => { let position = size.height - (total_lines as f32 * text_and_line_spacing); - ("end", position, "100%") + ("end", position, "1910") } }; - final_svg.push_str(&format!("", size.width, size.height)); + final_svg.push_str(&format!("", size.width, size.height, size.width, size.height)); if let Some(shadow) = &self.shadow { final_svg.push_str(&format!( @@ -348,7 +348,7 @@ impl TextSvg { // "", // ); - final_svg.push_str(&format!(""); - let text_pieces: Vec = self + let text: String = self .text .lines() .enumerate() .map(|(index, text)| { format!( - "{}", + "{}", (index as f32).mul_add( text_and_line_spacing, starting_y_position @@ -373,7 +373,6 @@ impl TextSvg { ) }) .collect(); - let text: String = text_pieces.join("\n"); final_svg.push_str(&text); final_svg.push_str("");