File tree 1 file changed +18
-5
lines changed
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;
2
2
use crate :: core:: { Color , Size } ;
3
3
use crate :: image:: atlas:: { self , Atlas } ;
4
4
5
+ use iced_graphics:: text;
5
6
use resvg:: tiny_skia;
6
- use resvg:: usvg;
7
+ use resvg:: usvg:: { self , TreeTextToPath } ;
7
8
use std:: collections:: { HashMap , HashSet } ;
8
9
use std:: fs;
9
10
@@ -51,11 +52,23 @@ impl Cache {
51
52
52
53
let svg = match handle. data ( ) {
53
54
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
+ )
56
61
. 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
+ }
59
72
tree. map ( Svg :: Loaded ) . unwrap_or ( Svg :: NotFound )
60
73
}
61
74
svg:: Data :: Bytes ( bytes) => {
You can’t perform that action at this time.
0 commit comments