Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Make CTFontDescriptor::font_path() return filesystem path, not URL #85

Merged
merged 1 commit into from
Jan 31, 2018
Merged
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
8 changes: 6 additions & 2 deletions src/font_descriptor.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ use core_foundation::dictionary::{CFDictionary, CFDictionaryRef};
use core_foundation::number::{CFNumber, CFNumberRef};
use core_foundation::set::CFSetRef;
use core_foundation::string::{CFString, CFStringRef};
use core_foundation::url::CFURL;
use core_foundation::url::{CFURLCopyFileSystemPath, kCFURLPOSIXPathStyle, CFURL};
use core_graphics::base::CGFloat;

use libc::c_void;
@@ -250,7 +250,11 @@ impl CTFontDescriptor {
let value = CFType::wrap_under_create_rule(value);
assert!(value.instance_of::<CFURL>());
let url = CFURL::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
Some(format!("{:?}", url))
let path = CFString::wrap_under_create_rule(CFURLCopyFileSystemPath(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we made this return Option<PathBuf> and called url.to_path() instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, deja vu. I understand better now.

url.as_concrete_TypeRef(),
kCFURLPOSIXPathStyle,
)).to_string();
Some(path)
}
}