updating text_svg to perhaps contain the handle

This commit is contained in:
Chris Cochrun 2025-05-05 10:37:51 -05:00
parent 1a2ff0a4bc
commit b95e76eff4
3 changed files with 29 additions and 25 deletions

View file

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

View file

@ -24,6 +24,7 @@ pub struct TextSvg {
stroke: Option<Stroke>, stroke: Option<Stroke>,
fill: Color, fill: Color,
alignment: TextAlignment, alignment: TextAlignment,
handle: Option<Handle>,
} }
impl Hash for TextSvg { impl Hash for TextSvg {
@ -173,6 +174,8 @@ impl TextSvg {
} }
} }
pub fn build(self)
pub fn fill(mut self, color: impl Into<Color>) -> Self { pub fn fill(mut self, color: impl Into<Color>) -> Self {
self.fill = color.into(); self.fill = color.into();
self self

View file

@ -1,6 +1,7 @@
#+TITLE: The Task list for Lumina #+TITLE: The Task list for Lumina
* TODO Check into =mupdf-rs= for loading PDF's.
* TODO [#A] Text could be built by using SVG instead of the text element. Maybe I could construct my own text element even * TODO [#A] Text could be built by using SVG instead of the text element. Maybe I could construct my own text element even
This does almost work. There is a clear amount of lag or rather hang up since switching to the =text_svg= element. I think I may only keep it till I can figure out how to do strokes and shadows in iced's normal text element. This does almost work. There is a clear amount of lag or rather hang up since switching to the =text_svg= element. I think I may only keep it till I can figure out how to do strokes and shadows in iced's normal text element.