summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tiny_skia/src/vector.rs2
-rw-r--r--wgpu/src/image/vector.rs26
2 files changed, 19 insertions, 9 deletions
diff --git a/tiny_skia/src/vector.rs b/tiny_skia/src/vector.rs
index 9c2893a2..fd1ab3de 100644
--- a/tiny_skia/src/vector.rs
+++ b/tiny_skia/src/vector.rs
@@ -96,7 +96,7 @@ impl Cache {
if let Some(svg) = &mut svg {
if svg.has_text_nodes() {
let mut font_system =
- text::font_system().write().expect("Read font system");
+ text::font_system().write().expect("Write font system");
svg.convert_text(font_system.raw().db_mut());
}
diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs
index 6582bb82..d9be50d7 100644
--- a/wgpu/src/image/vector.rs
+++ b/wgpu/src/image/vector.rs
@@ -1,9 +1,10 @@
use crate::core::svg;
use crate::core::{Color, Size};
+use crate::graphics::text;
use crate::image::atlas::{self, Atlas};
use resvg::tiny_skia;
-use resvg::usvg;
+use resvg::usvg::{self, TreeTextToPath};
use std::collections::{HashMap, HashSet};
use std::fs;
@@ -49,15 +50,15 @@ impl Cache {
return self.svgs.get(&handle.id()).unwrap();
}
- let svg = match handle.data() {
- svg::Data::Path(path) => {
- let tree = fs::read_to_string(path).ok().and_then(|contents| {
+ let mut svg = match handle.data() {
+ svg::Data::Path(path) => fs::read_to_string(path)
+ .ok()
+ .and_then(|contents| {
usvg::Tree::from_str(&contents, &usvg::Options::default())
.ok()
- });
-
- tree.map(Svg::Loaded).unwrap_or(Svg::NotFound)
- }
+ })
+ .map(Svg::Loaded)
+ .unwrap_or(Svg::NotFound),
svg::Data::Bytes(bytes) => {
match usvg::Tree::from_data(bytes, &usvg::Options::default()) {
Ok(tree) => Svg::Loaded(tree),
@@ -66,6 +67,15 @@ impl Cache {
}
};
+ if let Svg::Loaded(svg) = &mut svg {
+ if svg.has_text_nodes() {
+ let mut font_system =
+ text::font_system().write().expect("Write font system");
+
+ svg.convert_text(font_system.raw().db_mut());
+ }
+ }
+
let _ = self.svgs.insert(handle.id(), svg);
self.svgs.get(&handle.id()).unwrap()
}