Skip to content

Commit 199badc

Browse files
authored
Fix support for macOS 14 (#668)
* core-text: define version variable and dbg!() it Note that this test already has a number of dbg!() calls, presumably to aid debugging when it fails in the future (for example due to OS changes). * core-text: extract helper function in test * core-text: improve assertion to make failure easier to diagnose * core-text: allow variations test to pass on 14.x.y * CI: test on macOS 14 * CI: only test old Rust on one version
1 parent 48d6bdf commit 199badc

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ jobs:
3131
runs-on: ${{ matrix.os }}
3232
strategy:
3333
matrix:
34-
os: [macos-11.0, macos-12, macos-13]
35-
toolchain: [stable, 1.56.1]
34+
os: [macos-11.0, macos-12, macos-13, macos-14]
35+
toolchain: [stable]
36+
include:
37+
- os: macos-14
38+
toolchain: 1.56.1
3639
steps:
3740
- uses: actions/checkout@v4
3841
- name: Install toolchain

core-text/src/font.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,13 @@ fn copy_system_font() {
940940
#[test]
941941
fn out_of_range_variations() {
942942
use crate::*;
943+
use core_foundation::base::ItemRef;
943944

944945
let small = new_ui_font_for_language(kCTFontSystemDetailFontType, 19., None);
945946

946947
let axes = small.get_variation_axes();
947-
if macos_version() < (10, 12, 0) {
948+
let version = dbg!(macos_version());
949+
if version < (10, 12, 0) {
948950
assert!(axes.is_none());
949951
return;
950952
}
@@ -980,10 +982,25 @@ fn out_of_range_variations() {
980982
let var_desc = variation_font.copy_descriptor();
981983
let var_attrs = var_desc.attributes();
982984
dbg!(&var_attrs);
983-
// attributes greater than max are dropped on macOS <= 11
984-
// on macOS 12 they seem to be preserved as is.
985+
986+
// Handling of attributes greater than max changed between versions
985987
let var_attrs = var_attrs.find(variation_attribute);
986-
if macos_version() >= (12, 0, 0) && macos_version() < (13, 0, 0) {
988+
if version >= (14, 0, 0) {
989+
check_attrs(0., var_attrs, axes);
990+
} else if version >= (12, 0, 0) && version < (13, 0, 0) {
991+
check_attrs(1., var_attrs, axes);
992+
} else if version >= (10, 15, 0) {
993+
assert!(var_attrs.is_none());
994+
} else {
995+
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();
996+
assert!(var_attrs.is_empty());
997+
}
998+
999+
fn check_attrs(
1000+
clamp_diff: f64,
1001+
var_attrs: Option<ItemRef<'_, CFType>>,
1002+
axes: CFArray<CFDictionary<CFString, CFType>>,
1003+
) {
9871004
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();
9881005
assert!(!var_attrs.is_empty());
9891006
let var_attrs: CFDictionary<CFType, CFType> = unsafe { std::mem::transmute(var_attrs) };
@@ -1006,13 +1023,14 @@ fn out_of_range_variations() {
10061023
.unwrap()
10071024
.to_f64()
10081025
.unwrap();
1009-
assert_eq!(val, max + 1.);
1026+
1027+
let expected = max + clamp_diff;
1028+
assert_eq!(
1029+
val, expected,
1030+
"axis {:?} = {:?} (expected {:?})",
1031+
tag, val, expected
1032+
);
10101033
}
1011-
} else if macos_version() >= (10, 15, 0) {
1012-
assert!(var_attrs.is_none());
1013-
} else {
1014-
let var_attrs = var_attrs.unwrap().downcast::<CFDictionary>().unwrap();
1015-
assert!(var_attrs.is_empty());
10161034
}
10171035
}
10181036

0 commit comments

Comments
 (0)