Skip to content

Commit 4ae7a00

Browse files
committed
More test
1 parent b8e8216 commit 4ae7a00

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

core-text/src/font.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ fn maxPow2LessThanEqual(a: i32) -> i32 {
781781
}
782782

783783

784-
fn construct_font_data(font: CGFont) -> Vec<u8> {
784+
fn construct_font_data(font: &CGFont) -> Vec<u8> {
785785
struct TableRecord {
786786
tag: u32,
787787
checkSum: u32,
@@ -865,7 +865,7 @@ fn font_data() {
865865
)
866866
};
867867
println!("{:?}", (small.postscript_name(), small.url()));
868-
let data = construct_font_data( small.copy_to_CGFont());
868+
let data = construct_font_data( &small.copy_to_CGFont());
869869
let mut file = std::fs::File::create("test.ttf").unwrap();
870870
// Write a slice of bytes to the file
871871
use std::io::Write;
@@ -897,6 +897,22 @@ fn variations() {
897897
(10, 12, 0) => assert_eq!(ct_font.family_name(), ".LastResort"),
898898
(10, 11, 0) => assert_ne!(ct_font.family_name(), ".LastResort"),
899899
_ => assert_ne!(ct_font.family_name(), ".LastResort"),
900+
}
900901

902+
let data = construct_font_data(&font);
903+
let font = new_from_buffer(&data).unwrap();
904+
let font = font.copy_to_CGFont();
905+
vals_str.push((CFString::new("Weight"), (700.).into()) );
906+
let vars = CFDictionary::from_CFType_pairs(&vals_str);
907+
let var_font = CGFont::create_copy_from_variations(&font, &vars).unwrap();
908+
// Check if new_from_CGFont will work on our CGFont with variations applied
909+
let ct_font = new_from_CGFont(&var_font.clone(), 19.);
910+
match macos_version() {
911+
(10, 15, 0) => assert_ne!(ct_font.family_name(), ".LastResort"),
912+
(10, 14, 0) => assert_eq!(ct_font.family_name(), ".LastResort"),
913+
(10, 13, 0) => assert_eq!(ct_font.family_name(), ".LastResort"),
914+
(10, 12, 0) => assert_eq!(ct_font.family_name(), ".LastResort"),
915+
(10, 11, 0) => assert_ne!(ct_font.family_name(), ".LastResort"),
916+
_ => assert_ne!(ct_font.family_name(), ".LastResort"),
901917
}
902918
}

0 commit comments

Comments
 (0)