Skip to content

Commit

Permalink
More test
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmuizel committed Feb 9, 2021
1 parent b8e8216 commit 4ae7a00
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core-text/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ fn maxPow2LessThanEqual(a: i32) -> i32 {
}


fn construct_font_data(font: CGFont) -> Vec<u8> {
fn construct_font_data(font: &CGFont) -> Vec<u8> {
struct TableRecord {
tag: u32,
checkSum: u32,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
}
}

0 comments on commit 4ae7a00

Please sign in to comment.