diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a8619fa1..10bf9066 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -31,8 +31,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-11.0, macos-12, macos-13] - toolchain: [stable, 1.56.1] + os: [macos-11.0, macos-12, macos-13, macos-14] + toolchain: [stable] + include: + - os: macos-14 + toolchain: 1.56.1 steps: - uses: actions/checkout@v4 - name: Install toolchain diff --git a/core-text/src/font.rs b/core-text/src/font.rs index f4379f3b..efe9e321 100644 --- a/core-text/src/font.rs +++ b/core-text/src/font.rs @@ -940,11 +940,13 @@ fn copy_system_font() { #[test] fn out_of_range_variations() { use crate::*; + use core_foundation::base::ItemRef; let small = new_ui_font_for_language(kCTFontSystemDetailFontType, 19., None); let axes = small.get_variation_axes(); - if macos_version() < (10, 12, 0) { + let version = dbg!(macos_version()); + if version < (10, 12, 0) { assert!(axes.is_none()); return; } @@ -980,10 +982,25 @@ fn out_of_range_variations() { let var_desc = variation_font.copy_descriptor(); let var_attrs = var_desc.attributes(); dbg!(&var_attrs); - // attributes greater than max are dropped on macOS <= 11 - // on macOS 12 they seem to be preserved as is. + + // Handling of attributes greater than max changed between versions let var_attrs = var_attrs.find(variation_attribute); - if macos_version() >= (12, 0, 0) && macos_version() < (13, 0, 0) { + if version >= (14, 0, 0) { + check_attrs(0., var_attrs, axes); + } else if version >= (12, 0, 0) && version < (13, 0, 0) { + check_attrs(1., var_attrs, axes); + } else if version >= (10, 15, 0) { + assert!(var_attrs.is_none()); + } else { + let var_attrs = var_attrs.unwrap().downcast::().unwrap(); + assert!(var_attrs.is_empty()); + } + + fn check_attrs( + clamp_diff: f64, + var_attrs: Option>, + axes: CFArray>, + ) { let var_attrs = var_attrs.unwrap().downcast::().unwrap(); assert!(!var_attrs.is_empty()); let var_attrs: CFDictionary = unsafe { std::mem::transmute(var_attrs) }; @@ -1006,13 +1023,14 @@ fn out_of_range_variations() { .unwrap() .to_f64() .unwrap(); - assert_eq!(val, max + 1.); + + let expected = max + clamp_diff; + assert_eq!( + val, expected, + "axis {:?} = {:?} (expected {:?})", + tag, val, expected + ); } - } else if macos_version() >= (10, 15, 0) { - assert!(var_attrs.is_none()); - } else { - let var_attrs = var_attrs.unwrap().downcast::().unwrap(); - assert!(var_attrs.is_empty()); } }