diff options
author | 2023-11-11 04:16:17 +0100 | |
---|---|---|
committer | 2023-11-11 04:16:17 +0100 | |
commit | 3408ab111f8f925b5e404e547c97a3e6c4f00fbf (patch) | |
tree | fb4ceeea917a9f0f1c91bd60598483b4ffc4fd51 /tiny_skia | |
parent | 53f5f935e493cce3c041f8d0a635ab4c24a8f7e0 (diff) | |
parent | 2aaaf2cd0cb56f9efc946159a0232270f8d37eeb (diff) | |
download | iced-3408ab111f8f925b5e404e547c97a3e6c4f00fbf.tar.gz iced-3408ab111f8f925b5e404e547c97a3e6c4f00fbf.tar.bz2 iced-3408ab111f8f925b5e404e547c97a3e6c4f00fbf.zip |
Merge pull request #1908 from alec-deason/bug/convert_text
Run convert_text on svg trees so text renders correctly
Diffstat (limited to 'tiny_skia')
-rw-r--r-- | tiny_skia/src/vector.rs | 14 |
1 files changed, 12 insertions, 2 deletions
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); } |