mirror of
https://github.com/penpot/penpot.git
synced 2026-07-03 04:45:28 +00:00
🐛 Fix SVG Raw not being saved (#10492)
This commit is contained in:
parent
665e8e018e
commit
851fde01c1
@ -733,7 +733,11 @@ pub extern "C" fn set_shape_svg_raw_content() -> Result<()> {
|
||||
.map_err(|e| Error::RecoverableError(e.to_string()))?
|
||||
.trim_end_matches('\0')
|
||||
.to_string();
|
||||
|
||||
let render_state = get_render_state();
|
||||
let font_manager = skia::FontMgr::from(render_state.fonts().font_provider().clone());
|
||||
shape.set_svg_raw_content(svg_raw_content);
|
||||
shape.update_svg_raw_content(font_manager);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
||||
@ -1398,7 +1398,7 @@ impl RenderState {
|
||||
}
|
||||
|
||||
match &shape.shape_type {
|
||||
Type::SVGRaw(sr) => {
|
||||
Type::SVGRaw(_) => {
|
||||
if let Some(svg_transform) = shape.svg_transform() {
|
||||
matrix.pre_concat(&svg_transform);
|
||||
}
|
||||
@ -1410,17 +1410,7 @@ impl RenderState {
|
||||
if let Some(svg) = shape.svg.as_ref() {
|
||||
svg.render(self.surfaces.canvas_and_mark_dirty(fills_surface_id));
|
||||
} else {
|
||||
let font_manager = skia::FontMgr::from(self.fonts().font_provider().clone());
|
||||
let dom_result = skia::svg::Dom::from_str(&sr.content, font_manager);
|
||||
match dom_result {
|
||||
Ok(dom) => {
|
||||
dom.render(self.surfaces.canvas_and_mark_dirty(fills_surface_id));
|
||||
shape.to_mut().set_svg(dom);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error parsing SVG. Error: {}", e);
|
||||
}
|
||||
}
|
||||
panic!("SVG should be available");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -722,6 +722,23 @@ impl Shape {
|
||||
self.invalidate_extrect();
|
||||
}
|
||||
|
||||
pub fn update_svg_raw_content(&mut self, font_manager: skia::FontMgr) {
|
||||
match &self.shape_type {
|
||||
Type::SVGRaw(sr) => {
|
||||
let dom_result = skia::svg::Dom::from_str(&sr.content, font_manager);
|
||||
match dom_result {
|
||||
Ok(dom) => {
|
||||
self.set_svg(dom);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error parsing SVG. Error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => panic!("Updating SVG raw content on non SVG Raw shape"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_svg_raw_content(&mut self, content: String) {
|
||||
self.shape_type = Type::SVGRaw(SVGRaw::from_content(content));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user