Skip to content

Commit cc53ab5

Browse files
authored
Auto merge of #486 - jrmuizel:oor-var-mac12, r=mstange
core-text: out_of_range_variations: Add support for macOS 12 None
2 parents 57d00a3 + 77ffcfe commit cc53ab5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

core-text/src/font.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,23 @@ fn out_of_range_variations() {
788788
let var_desc = variation_font.copy_descriptor();
789789
let var_attrs = var_desc.attributes();
790790
dbg!(&var_attrs);
791-
// attributes greater than max are dropped
791+
// attributes greater than max are dropped on macOS <= 11
792+
// on macOS 12 they seem to be preserved as is.
792793
let var_attrs = var_attrs.find(variation_attribute);
793-
if macos_version() >= (10, 15, 0) {
794+
if macos_version() >= (12, 0, 0) {
795+
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();
796+
assert!(!var_attrs.is_empty());
797+
let var_attrs: CFDictionary<CFType, CFType> = unsafe { std::mem::transmute(var_attrs) };
798+
// attributes greater than max remain
799+
for axis in axes.iter() {
800+
let tag = axis.find(unsafe { kCTFontVariationAxisIdentifierKey } )
801+
.unwrap();
802+
let max = axis.find(unsafe { kCTFontVariationAxisMaximumValueKey } )
803+
.unwrap().downcast::<CFNumber>().unwrap().to_f64().unwrap();
804+
let val = var_attrs.find(tag.clone()).unwrap().downcast::<CFNumber>().unwrap().to_f64().unwrap();
805+
assert_eq!(val, max + 1.);
806+
}
807+
} else if macos_version() >= (10, 15, 0) {
794808
assert!(var_attrs.is_none());
795809
} else {
796810
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();

0 commit comments

Comments
 (0)