Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core-text/src/font_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,8 @@ impl CTFontDescriptor {
unsafe {
let value = CTFontDescriptorCopyAttribute(self.0, kCTFontTraitsAttribute);
assert!(!value.is_null());
let value = CFType::wrap_under_create_rule(value);
assert!(value.instance_of::<CFDictionary>());
CFDictionary::wrap_under_get_rule(value.as_CFTypeRef() as CFDictionaryRef)
// Use wrap_under_create_rule for the dictionary directly to maintain ownership
CFDictionary::wrap_under_create_rule(value as CFDictionaryRef)
}
}

Expand Down
5 changes: 3 additions & 2 deletions core-text/src/font_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ pub fn copy_available_font_family_names() -> CFArray<CFString> {
pub fn create_font_descriptor(buffer: &[u8]) -> Result<CTFontDescriptor, ()> {
let cf_data = CFData::from_buffer(buffer);
unsafe {
let ct_font_descriptor_ref =
CTFontManagerCreateFontDescriptorFromData(cf_data.as_concrete_TypeRef());
// Keep cf_data alive by getting the raw pointer within the unsafe block
let data_ref = cf_data.as_concrete_TypeRef();
let ct_font_descriptor_ref = CTFontManagerCreateFontDescriptorFromData(data_ref);
if ct_font_descriptor_ref.is_null() {
return Err(());
}
Expand Down