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:
Chris Cochrun 2025-03-17 07:26:44 -05:00
parent 53791162b1
commit 6fcabad45c

View file

@ -7,12 +7,13 @@ use cosmic::{
Font, Length,
},
iced_wgpu::graphics::text::cosmic_text::fontdb,
iced_widget::row,
iced_widget::{row, stack},
theme,
widget::{
button, column, combo_box, container, dropdown,
horizontal_space, icon, scrollable, text, text_editor,
text_input,
horizontal_space, icon, scrollable,
svg::{self, Handle},
text, text_editor, text_input, Svg,
},
Element, Task,
};
@ -305,6 +306,16 @@ impl SongEditor {
.into_iter()
.enumerate()
.map(|(index, slide)| {
let svg = Handle::from_memory(r#"<svg viewBox="0 0 240 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="shadow2">
<feDropShadow dx="0" dy="0" stdDeviation="5.5" flood-color="cyan" />
</filter>
</defs>
<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
</text></svg>"#.as_bytes());
stack!(
container(
slide_view(
slide,
@ -322,8 +333,9 @@ impl SongEditor {
.height(250)
.center_x(Length::Fill)
.padding([0, 20])
.clip(true)
.into()
.clip(true),
Svg::new(svg),
).into()
})
.collect();
scrollable(