making some text_svg changes

This commit is contained in:
Chris Cochrun 2025-05-04 22:40:18 -05:00
parent 44e8bc4683
commit 1a2ff0a4bc
3 changed files with 69 additions and 35 deletions

View file

@ -29,6 +29,7 @@ use url::Url;
use crate::{
core::{service_items::ServiceItemModel, slide::Slide},
ui::text_svg::{self, Font as SvgFont},
BackgroundKind,
};
@ -542,33 +543,39 @@ pub(crate) fn slide_view(
responsive(move |size| {
let width = size.height * 16.0 / 9.0;
let font_size = scale_font(slide.font_size() as f32, width);
// let font = SvgFont::from(font).size(font_size.floor() as u8);
let font = SvgFont::from(font).size(font_size.floor() as u8);
let slide_text = slide.text();
// let text = text_svg::TextSvg::new()
// .text(&slide_text)
// .fill("#fff")
// .shadow(shadow(2, 2, 5, "#000000"))
// .stroke(stroke(1, "#000"))
// .font(font)
// .view()
// .map(|m| Message::None);
// SVG based
let text = text_svg::TextSvg::new()
.text(&slide_text)
.fill("#fff")
.shadow(text_svg::shadow(2, 2, 5, "#000000"))
.stroke(text_svg::stroke(1, "#000"))
.font(font)
.view()
.map(|m| Message::None);
// let text = text!("{}", &slide_text);
let lines = slide_text.lines();
let text: Vec<Element<Message>> = lines
.map(|t| {
rich_text([span(format!("{}\n", t))
.background(
Background::Color(Color::BLACK)
.scale_alpha(0.4),
)
.padding(1)])
.size(font_size)
.font(font)
.center()
.into()
})
.collect();
let text = Column::with_children(text).spacing(6);
// text widget based
// let lines = slide_text.lines();
// let text: Vec<Element<Message>> = lines
// .map(|t| {
// rich_text([span(format!("{}\n", t))
// .background(
// Background::Color(Color::BLACK)
// .scale_alpha(0.4),
// )
// .padding(1)])
// .size(font_size)
// .font(font)
// .center()
// .into()
// })
// .collect();
// let text = Column::with_children(text).spacing(6);
//Next
let text_container = Container::new(text)
.center(Length::Fill)
.align_x(Horizontal::Left);