From 4ae7a004fd80e6c4dc7b4d0f2014c1d369e5c642 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 9 Feb 2021 13:57:30 -0500 Subject: [PATCH] More test --- core-text/src/font.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core-text/src/font.rs b/core-text/src/font.rs index 095b15cfd..70ab07458 100644 --- a/core-text/src/font.rs +++ b/core-text/src/font.rs @@ -781,7 +781,7 @@ fn maxPow2LessThanEqual(a: i32) -> i32 { } -fn construct_font_data(font: CGFont) -> Vec { +fn construct_font_data(font: &CGFont) -> Vec { struct TableRecord { tag: u32, checkSum: u32, @@ -865,7 +865,7 @@ fn font_data() { ) }; println!("{:?}", (small.postscript_name(), small.url())); - let data = construct_font_data( small.copy_to_CGFont()); + let data = construct_font_data( &small.copy_to_CGFont()); let mut file = std::fs::File::create("test.ttf").unwrap(); // Write a slice of bytes to the file use std::io::Write; @@ -897,6 +897,22 @@ fn variations() { (10, 12, 0) => assert_eq!(ct_font.family_name(), ".LastResort"), (10, 11, 0) => assert_ne!(ct_font.family_name(), ".LastResort"), _ => assert_ne!(ct_font.family_name(), ".LastResort"), + } + let data = construct_font_data(&font); + let font = new_from_buffer(&data).unwrap(); + let font = font.copy_to_CGFont(); + vals_str.push((CFString::new("Weight"), (700.).into()) ); + let vars = CFDictionary::from_CFType_pairs(&vals_str); + let var_font = CGFont::create_copy_from_variations(&font, &vars).unwrap(); + // Check if new_from_CGFont will work on our CGFont with variations applied + let ct_font = new_from_CGFont(&var_font.clone(), 19.); + match macos_version() { + (10, 15, 0) => assert_ne!(ct_font.family_name(), ".LastResort"), + (10, 14, 0) => assert_eq!(ct_font.family_name(), ".LastResort"), + (10, 13, 0) => assert_eq!(ct_font.family_name(), ".LastResort"), + (10, 12, 0) => assert_eq!(ct_font.family_name(), ".LastResort"), + (10, 11, 0) => assert_ne!(ct_font.family_name(), ".LastResort"), + _ => assert_ne!(ct_font.family_name(), ".LastResort"), } } \ No newline at end of file