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

Have font_path() return a PathBuf instead of a String #78

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core-text"
version = "9.0.0"
version = "10.0.0"
authors = ["The Servo Project Developers"]
description = "Bindings to the Core Text framework."
license = "MIT/Apache-2.0"
Expand Down
5 changes: 3 additions & 2 deletions src/font_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use core_graphics::base::CGFloat;

use libc::c_void;
use std::mem;
use std::path::PathBuf;

/*
* CTFontTraits.h
Expand Down Expand Up @@ -282,7 +283,7 @@ impl CTFontDescriptor {
}
}

pub fn font_path(&self) -> Option<String> {
pub fn font_path(&self) -> Option<PathBuf> {
unsafe {
let value = CTFontDescriptorCopyAttribute(self.obj, kCTFontURLAttribute);
if value.is_null() {
Expand All @@ -292,7 +293,7 @@ impl CTFontDescriptor {
let value: CFType = TCFType::wrap_under_get_rule(value);
assert!(value.instance_of::<CFURL>());
let url: CFURL = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
Some(format!("{:?}", url))
url.to_path()
}
}
}
Expand Down