testing out svg as a text option instead of using the text element
The text element has little options for heavily styling the text. I think I'll start to build a dedicated text element from SVGs instead. This will ensure that I can add strokes and drop-shadows.
This commit is contained in:
parent
53791162b1
commit
6fcabad45c
|
@ -7,12 +7,13 @@ use cosmic::{
|
||||||
Font, Length,
|
Font, Length,
|
||||||
},
|
},
|
||||||
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
||||||
iced_widget::row,
|
iced_widget::{row, stack},
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
button, column, combo_box, container, dropdown,
|
button, column, combo_box, container, dropdown,
|
||||||
horizontal_space, icon, scrollable, text, text_editor,
|
horizontal_space, icon, scrollable,
|
||||||
text_input,
|
svg::{self, Handle},
|
||||||
|
text, text_editor, text_input, Svg,
|
||||||
},
|
},
|
||||||
Element, Task,
|
Element, Task,
|
||||||
};
|
};
|
||||||
|
@ -305,25 +306,36 @@ impl SongEditor {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(index, slide)| {
|
.map(|(index, slide)| {
|
||||||
container(
|
let svg = Handle::from_memory(r#"<svg viewBox="0 0 240 100" xmlns="http://www.w3.org/2000/svg">
|
||||||
slide_view(
|
<defs>
|
||||||
slide,
|
<filter id="shadow2">
|
||||||
if index == 0 {
|
<feDropShadow dx="0" dy="0" stdDeviation="5.5" flood-color="cyan" />
|
||||||
&self.video
|
</filter>
|
||||||
} else {
|
</defs>
|
||||||
&None
|
<text x="0" y="50" font-weight="bold" font-family="Quicksand" font-size="40" fill="white" stroke="black" stroke-width="2" style="filter:url(#shadow2);">
|
||||||
},
|
Hello World
|
||||||
self.current_font,
|
</text></svg>"#.as_bytes());
|
||||||
false,
|
stack!(
|
||||||
false,
|
container(
|
||||||
|
slide_view(
|
||||||
|
slide,
|
||||||
|
if index == 0 {
|
||||||
|
&self.video
|
||||||
|
} else {
|
||||||
|
&None
|
||||||
|
},
|
||||||
|
self.current_font,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.map(|_| Message::None),
|
||||||
)
|
)
|
||||||
.map(|_| Message::None),
|
.height(250)
|
||||||
)
|
.center_x(Length::Fill)
|
||||||
.height(250)
|
.padding([0, 20])
|
||||||
.center_x(Length::Fill)
|
.clip(true),
|
||||||
.padding([0, 20])
|
Svg::new(svg),
|
||||||
.clip(true)
|
).into()
|
||||||
.into()
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
scrollable(
|
scrollable(
|
||||||
|
|
Loading…
Reference in a new issue