Skip to content

Commit e4d2fe6

Browse files
committed
Check the preservation of variable fonts
1 parent 9be2a05 commit e4d2fe6

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

core-text/src/font.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ fn variations_dict() {
757757
let var_font = CGFont::create_copy_from_variations(&font, &vars).unwrap();
758758
match macos_version() {
759759
(10, 11, _) => {
760-
assert!(font.copy_variation_axis().is_none());
760+
assert!(font.copy_variation_axes().is_none());
761761
return;
762762
}
763763
_ => {}
@@ -778,3 +778,27 @@ fn variations_dict() {
778778
_ => assert!(var.find(CFNumber::from(0x77676874)).is_some()),
779779
}
780780
}
781+
782+
#[test]
783+
fn variations_copy() {
784+
use std::io::Read;
785+
let mut f = std::fs::File::open("variabletest_box.ttf").unwrap();
786+
let mut buffer = Vec::new();
787+
// read the whole file
788+
f.read_to_end(&mut buffer).unwrap();
789+
790+
let font = new_from_buffer(&buffer).unwrap();
791+
dbg!(&font);
792+
let cg_font = font.copy_to_CGFont();
793+
dbg!(cg_font.copy_variation_axes());
794+
let mut vals_str: Vec<(CFString, CFNumber)> = Vec::new();
795+
vals_str.push((CFString::new("Optical Sizing"), (100.).into()));
796+
vals_str.push((CFString::new("Upward"), (350).into()));
797+
let vars = CFDictionary::from_CFType_pairs(&vals_str);
798+
let var_font = CGFont::create_copy_from_variations(&cg_font, &vars).unwrap();
799+
let var_ct_font = new_from_CGFont(&var_font, 19.);
800+
dbg!(&var_ct_font);
801+
dbg!(var_ct_font.copy_descriptor().attributes().find(CFString::from_static_string("NSCTFontVariationAttribute")));
802+
dbg!(var_ct_font.copy_to_CGFont().copy_variations());
803+
assert!(false);
804+
}

core-text/variabletest_box.ttf

3.94 KB
Binary file not shown.

0 commit comments

Comments
 (0)