@@ -879,23 +879,24 @@ fn font_data() {
879879#[ test]
880880fn variations ( ) {
881881 let mut vals_str: Vec < ( CFString , CFNumber ) > = Vec :: new ( ) ;
882- let small = unsafe {
882+ let system_font = unsafe {
883883 CTFont :: wrap_under_create_rule (
884884 CTFontCreateUIFontForLanguage ( kCTFontEmphasizedSystemDetailFontType, 19. , std:: ptr:: null ( ) )
885885 )
886886 } ;
887- dbg ! ( & small) ;
888- //let font = CGFont::from_name(&CFString::new(".SFNSText-Bold")).unwrap();
889- let font= small. copy_to_CGFont ( ) ;
887+ let font = system_font. copy_to_CGFont ( ) ;
890888 vals_str. push ( ( CFString :: new ( "Weight" ) , ( 700. ) . into ( ) ) ) ;
891889 let vars = CFDictionary :: from_CFType_pairs ( & vals_str) ;
892890 let var_font = CGFont :: create_copy_from_variations ( & font, & vars) . unwrap ( ) ;
893- extern {
894- pub fn CFCopyDescription ( obj : usize ) -> usize ;
895- }
896- let s: CFString = unsafe { std:: mem:: transmute ( CFCopyDescription ( std:: mem:: transmute ( var_font. clone ( ) ) ) ) } ;
897- println ! ( "{:}" , s) ;
891+ // Check if new_from_CGFont will work on our CGFont with variations applied
898892 let ct_font = new_from_CGFont ( & var_font. clone ( ) , 19. ) ;
899- dbg ! ( ct_font. family_name( ) ) ;
900- assert ! ( false ) ;
893+ match macos_version ( ) {
894+ ( 10 , 15 , 0 ) => assert_ne ! ( ct_font. family_name( ) , ".LastResort" ) ,
895+ ( 10 , 14 , 0 ) => assert_eq ! ( ct_font. family_name( ) , ".LastResort" ) ,
896+ ( 10 , 13 , 0 ) => assert_eq ! ( ct_font. family_name( ) , ".LastResort" ) ,
897+ ( 10 , 12 , 0 ) => assert_eq ! ( ct_font. family_name( ) , ".LastResort" ) ,
898+ ( 10 , 11 , 0 ) => assert_ne ! ( ct_font. family_name( ) , ".LastResort" ) ,
899+ _ => assert_ne ! ( ct_font. family_name( ) , ".LastResort" ) ,
900+
901+ }
901902}
0 commit comments