File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 4
4
//! Model for a font.
5
5
6
6
use crate :: CharmapIndex ;
7
+ use crate :: matching:: FontMatchingInfo ;
7
8
8
9
use super :: attributes:: { FontStyle , FontWeight , FontWidth } ;
9
10
use super :: source:: { SourceInfo , SourceKind } ;
@@ -27,6 +28,17 @@ pub struct FontInfo {
27
28
charmap_index : CharmapIndex ,
28
29
}
29
30
31
+ impl Into < FontMatchingInfo > for & FontInfo {
32
+ fn into ( & self ) -> FontMatchingInfo {
33
+ FontMatchingInfo {
34
+ width : ( self . width ( ) . ratio ( ) * 100.0 ) as i32 ,
35
+ style : self . style ( ) ,
36
+ weight : self . weight ( ) . value ( ) ,
37
+ has_slnt : self . has_slant_axis ( ) ,
38
+ }
39
+ }
40
+ }
41
+
30
42
impl FontInfo {
31
43
/// Creates a new font object from the given source and index.
32
44
pub fn from_source ( source : SourceInfo , index : u32 ) -> Option < Self > {
Original file line number Diff line number Diff line change 6
6
use core:: ops:: Deref ;
7
7
8
8
use super :: attributes:: { DEFAULT_OBLIQUE_ANGLE , FontStyle , FontWeight , FontWidth } ;
9
- use super :: font:: FontInfo ;
10
9
use core:: cmp:: Ordering ;
11
10
use smallvec:: SmallVec ;
12
11
13
12
// Public API
14
13
15
14
#[ derive( Copy , Clone ) ]
16
15
pub struct FontMatchingInfo {
17
- width : i32 ,
18
- style : FontStyle ,
19
- weight : f32 ,
20
- has_slnt : bool ,
16
+ pub width : i32 ,
17
+ pub style : FontStyle ,
18
+ pub weight : f32 ,
19
+ pub has_slnt : bool ,
21
20
}
22
21
23
22
pub fn match_font (
@@ -33,17 +32,6 @@ pub fn match_font(
33
32
34
33
// Private implementation details
35
34
36
- impl From < & FontInfo > for FontMatchingInfo {
37
- fn from ( info : & FontInfo ) -> Self {
38
- Self {
39
- width : ( info. width ( ) . ratio ( ) * 100.0 ) as i32 ,
40
- style : info. style ( ) ,
41
- weight : info. weight ( ) . value ( ) ,
42
- has_slnt : info. has_slant_axis ( ) ,
43
- }
44
- }
45
- }
46
-
47
35
#[ derive( Copy , Clone ) ]
48
36
struct CandidateFont {
49
37
index : usize ,
You can’t perform that action at this time.
0 commit comments