diff --git a/src/main.rs b/src/main.rs index 4faaa4f..5725086 100644 --- a/src/main.rs +++ b/src/main.rs @@ -201,23 +201,23 @@ impl cosmic::Application for App { } }; - // let items: Vec = items - // .into_par_iter() - // .map(|mut item| { - // item.slides = item - // .slides - // .into_par_iter() - // .map(|mut slide| { - // text_svg::text_svg_generator( - // &mut slide, - // Arc::clone(&fontdb), - // ); - // slide - // }) - // .collect(); - // item - // }) - // .collect(); + let items: Vec = items + .into_par_iter() + .map(|mut item| { + item.slides = item + .slides + .into_par_iter() + .map(|mut slide| { + text_svg::text_svg_generator( + &mut slide, + Arc::clone(&fontdb), + ); + slide + }) + .collect(); + item + }) + .collect(); let presenter = Presenter::with_items(items.clone()); let song_editor = SongEditor::new(Arc::clone(&fontdb)); @@ -258,7 +258,7 @@ impl cosmic::Application for App { }; batch.push(app.add_library()); - batch.push(app.add_service(items, Arc::clone(&fontdb))); + // batch.push(app.add_service(items, Arc::clone(&fontdb))); let batch = Task::batch(batch); (app, batch) } diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 9dfa8b1..86d7bc7 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -812,10 +812,10 @@ pub(crate) fn slide_view( let text: Element = if let Some(text) = &slide.text_svg { if let Some(handle) = &text.handle { - Image::new(handle) + image(handle) .content_fit(ContentFit::Cover) - .width(Length::Fill) - .height(Length::Fill) + .width(width) + .height(size.height) .into() } else { Space::with_width(0).into() diff --git a/src/ui/text_svg.rs b/src/ui/text_svg.rs index 3d12330..3ac16ad 100644 --- a/src/ui/text_svg.rs +++ b/src/ui/text_svg.rs @@ -243,6 +243,21 @@ impl TextSvg { pub fn build(mut self) -> Self { debug!("starting..."); + + let mut path = dirs::data_local_dir().unwrap(); + path.push(PathBuf::from("lumina")); + path.push(PathBuf::from("temp")); + let file_title = + &self.text.lines().next().unwrap().trim_end(); + path.push(PathBuf::from(file_title)); + path.set_extension("png"); + + if path.exists() { + debug!("cached"); + let handle = Handle::from_path(path); + self.handle = Some(handle); + return self; + } let shadow = if let Some(shadow) = &self.shadow { format!("", shadow.offset_x, @@ -260,8 +275,8 @@ impl TextSvg { } else { "".into() }; - let size = Size::new(3840.0, 2160.0); - let font_size = self.font.size as f32 * (size.width / 960.0); + let size = Size::new(1920.0, 1080.0); + let font_size = self.font.size as f32; let total_lines = self.text.lines().count(); let half_lines = (total_lines / 2) as f32; let middle_position = size.height / 2.0; @@ -307,21 +322,10 @@ impl TextSvg { Pixmap::new(size.width as u32, size.height as u32) .expect("opops"); resvg::render(&resvg_tree, transform, &mut pixmap.as_mut()); - // debug!(?pixmap); - // let mut path = dirs::data_local_dir().unwrap(); - // path.push(PathBuf::from("lumina")); - // path.push(PathBuf::from("temp")); - // let file_title = - // &self.text.lines().next().unwrap().trim_end(); - // path.push(PathBuf::from(file_title)); - // path.set_extension("png"); - // let _ = pixmap.save_png(&path); + let _ = pixmap.save_png(&path); + debug!("rendered"); - let handle = Handle::from_rgba( - size.width as u32, - size.height as u32, - pixmap.take(), - ); + let handle = Handle::from_path(path); self.handle = Some(handle); debug!("stored"); self diff --git a/test_presentation.lisp b/test_presentation.lisp index 553f254..37919e7 100644 --- a/test_presentation.lisp +++ b/test_presentation.lisp @@ -1,10 +1,10 @@ (slide :background (image :source "~/pics/frodo.jpg" :fit fill) - (text "This is frodo" :font-size 90)) + (text "This is frodo" :font-size 140)) (slide (video :source "~/vids/test/camprules2024.mp4" :fit contain)) (slide (video :source "~/vids/never give up.mkv" :fit contain)) (slide (video :source "~/vids/The promise of Rust.mkv" :fit contain)) (song :id 7 :author "North Point Worship" - :font "Quicksand Bold" :font-size 60 + :font "Quicksand" :font-size 140 :shadow "" :stroke "" :title "Death Was Arrested" :background (image :source "file:///home/chris/nc/tfc/openlp/CMG - Bright Mountains 01.jpg" :fit cover) diff --git a/test_song.lisp b/test_song.lisp index ccee693..a0705c8 100644 --- a/test_song.lisp +++ b/test_song.lisp @@ -1,5 +1,5 @@ (song :id 7 :author "North Point Worship" - :font "Quicksand Bold" :font-size 60 + :font "Quicksand" :font-size 140 :title "Death Was Arrested" :background (image :source "~/nc/tfc/openlp/CMG - Bright Mountains 01.jpg" :fit cover) :text-alignment center