@@ -2,10 +2,10 @@ use std::borrow::{Borrow, Cow};
2
2
use std:: collections:: HashMap ;
3
3
use std:: i32;
4
4
use std:: io:: Read ;
5
- use std:: sync:: { Arc , RwLock } ;
5
+ use std:: sync:: RwLock ;
6
6
7
7
use lazy_static:: lazy_static;
8
- use rusttype:: { point, Error , Font , FontCollection , Scale , SharedBytes } ;
8
+ use rusttype:: { point, Font , Scale } ;
9
9
10
10
use font_kit:: family_name:: FamilyName ;
11
11
use font_kit:: handle:: Handle ;
@@ -20,7 +20,7 @@ type FontResult<T> = Result<T, FontError>;
20
20
pub enum FontError {
21
21
LockError ,
22
22
NoSuchFont ( String , String ) ,
23
- FontLoadError ( Arc < Error > ) ,
23
+ FontLoadError ,
24
24
}
25
25
26
26
impl std:: fmt:: Display for FontError {
@@ -30,7 +30,7 @@ impl std::fmt::Display for FontError {
30
30
FontError :: NoSuchFont ( family, style) => {
31
31
write ! ( fmt, "No such font: {} {}" , family, style)
32
32
}
33
- FontError :: FontLoadError ( e ) => write ! ( fmt, "Font loading error: {}" , e ) ,
33
+ FontError :: FontLoadError => write ! ( fmt, "Font loading error" ) ,
34
34
}
35
35
}
36
36
}
@@ -100,10 +100,8 @@ fn load_font_data(face: FontFamily, style: FontStyle) -> FontResult<Font<'static
100
100
} ;
101
101
// TODO: font-kit actually have rasterizer, so consider remove dependency for rusttype as
102
102
// well
103
- let result = FontCollection :: from_bytes ( Into :: < SharedBytes > :: into ( data) )
104
- . map_err ( |err| FontError :: FontLoadError ( Arc :: new ( err) ) ) ?
105
- . font_at ( id. max ( 0 ) as usize )
106
- . map_err ( |err| FontError :: FontLoadError ( Arc :: new ( err) ) ) ;
103
+ let result = Font :: try_from_vec_and_index ( data, id. max ( 0 ) )
104
+ . ok_or ( FontError :: FontLoadError ) ;
107
105
108
106
CACHE
109
107
. write ( )
0 commit comments