summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-11 04:03:25 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-11 04:03:25 +0100
commit2aaaf2cd0cb56f9efc946159a0232270f8d37eeb (patch)
treed375c5fce3953403475a483fef747469eb65cb15
parent751ea77c29f6eb3d00f45f0a04c833a1d03a425c (diff)
downloadiced-2aaaf2cd0cb56f9efc946159a0232270f8d37eeb.tar.gz
iced-2aaaf2cd0cb56f9efc946159a0232270f8d37eeb.tar.bz2
iced-2aaaf2cd0cb56f9efc946159a0232270f8d37eeb.zip
Call `convert_text` on `svg` node before rendering
`tiny-skia` does not support text rendering, so we convert the text nodes to path nodes prior to that.
-rw-r--r--Cargo.toml4
-rw-r--r--tiny_skia/src/vector.rs14
2 files changed, 14 insertions, 4 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1a286b9b..18dd8d3e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -140,14 +140,14 @@ ouroboros = "0.17"
palette = "0.7"
qrcode = { version = "0.12", default-features = false }
raw-window-handle = "0.5"
-resvg = "0.35"
+resvg = "0.36"
rustc-hash = "1.0"
smol = "1.0"
softbuffer = "0.2"
syntect = "5.1"
sysinfo = "0.28"
thiserror = "1.0"
-tiny-skia = "0.10"
+tiny-skia = "0.11"
tokio = "1.0"
tracing = "0.1"
twox-hash = { version = "1.0", default-features = false }
diff --git a/tiny_skia/src/vector.rs b/tiny_skia/src/vector.rs
index a1cd269d..9c2893a2 100644
--- a/tiny_skia/src/vector.rs
+++ b/tiny_skia/src/vector.rs
@@ -1,7 +1,8 @@
use crate::core::svg::{Data, Handle};
use crate::core::{Color, Rectangle, Size};
+use crate::graphics::text;
-use resvg::usvg;
+use resvg::usvg::{self, TreeTextToPath};
use rustc_hash::{FxHashMap, FxHashSet};
use std::cell::RefCell;
@@ -77,7 +78,7 @@ impl Cache {
let id = handle.id();
if let hash_map::Entry::Vacant(entry) = self.trees.entry(id) {
- let svg = match handle.data() {
+ let mut svg = match handle.data() {
Data::Path(path) => {
fs::read_to_string(path).ok().and_then(|contents| {
usvg::Tree::from_str(
@@ -92,6 +93,15 @@ 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");
+
+ svg.convert_text(font_system.raw().db_mut());
+ }
+ }
+
let _ = entry.insert(svg);
}