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 44//! Model for a font.
55
66use crate :: CharmapIndex ;
7+ use crate :: matching:: FontMatchingInfo ;
78
89use super :: attributes:: { FontStyle , FontWeight , FontWidth } ;
910use super :: source:: { SourceInfo , SourceKind } ;
@@ -27,6 +28,17 @@ pub struct FontInfo {
2728 charmap_index : CharmapIndex ,
2829}
2930
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+
3042impl FontInfo {
3143 /// Creates a new font object from the given source and index.
3244 pub fn from_source ( source : SourceInfo , index : u32 ) -> Option < Self > {
Original file line number Diff line number Diff line change 66use core:: ops:: Deref ;
77
88use super :: attributes:: { DEFAULT_OBLIQUE_ANGLE , FontStyle , FontWeight , FontWidth } ;
9- use super :: font:: FontInfo ;
109use core:: cmp:: Ordering ;
1110use smallvec:: SmallVec ;
1211
1312// Public API
1413
1514#[ derive( Copy , Clone ) ]
1615pub 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 ,
2120}
2221
2322pub fn match_font (
@@ -33,17 +32,6 @@ pub fn match_font(
3332
3433// Private implementation details
3534
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-
4735#[ derive( Copy , Clone ) ]
4836struct CandidateFont {
4937 index : usize ,
You can’t perform that action at this time.
0 commit comments