File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,9 @@ use crate::core::svg;
22use crate :: core:: { Color , Size } ;
33use crate :: image:: atlas:: { self , Atlas } ;
44
5+ use iced_graphics:: text;
56use resvg:: tiny_skia;
6- use resvg:: usvg;
7+ use resvg:: usvg:: { self , TreeTextToPath } ;
78use std:: collections:: { HashMap , HashSet } ;
89use std:: fs;
910
@@ -51,11 +52,23 @@ impl Cache {
5152
5253 let svg = match handle. data ( ) {
5354 svg:: Data :: Path ( path) => {
54- let tree = fs:: read_to_string ( path) . ok ( ) . and_then ( |contents| {
55- usvg:: Tree :: from_str ( & contents, & usvg:: Options :: default ( ) )
55+ let mut tree =
56+ fs:: read_to_string ( path) . ok ( ) . and_then ( |contents| {
57+ usvg:: Tree :: from_str (
58+ & contents,
59+ & usvg:: Options :: default ( ) ,
60+ )
5661 . ok ( )
57- } ) ;
58-
62+ } ) ;
63+ // If there are text nodes in the tree load fonts and convert the text to paths
64+ if let Some ( svg_tree) = & mut tree {
65+ if svg_tree. has_text_nodes ( ) {
66+ let mut font_system = text:: font_system ( )
67+ . write ( )
68+ . expect ( "Read font system" ) ;
69+ svg_tree. convert_text ( font_system. raw ( ) . db_mut ( ) ) ;
70+ }
71+ }
5972 tree. map ( Svg :: Loaded ) . unwrap_or ( Svg :: NotFound )
6073 }
6174 svg:: Data :: Bytes ( bytes) => {
You can’t perform that action at this time.
0 commit comments