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

Upgrade core foundation #75

Merged
merged 3 commits into from
Jan 27, 2018
Merged
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core-text"
version = "8.0.0"
version = "9.0.0"
authors = ["The Servo Project Developers"]
description = "Bindings to the Core Text framework."
license = "MIT/Apache-2.0"
Expand All @@ -15,5 +15,5 @@ mountainlion = []
[dependencies]
foreign-types = "0.3"
libc = "0.2"
core-foundation = "0.4"
core-graphics = "0.12.1"
core-foundation = "0.5"
core-graphics = "0.13"
4 changes: 3 additions & 1 deletion src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ impl Clone for CTFont {
}
}

impl TCFType<CTFontRef> for CTFont {
impl TCFType for CTFont {
type Ref = CTFontRef;

#[inline]
fn as_concrete_TypeRef(&self) -> CTFontRef {
self.obj
Expand Down
8 changes: 5 additions & 3 deletions src/font_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ impl Drop for CTFontCollection {
}
}

impl TCFType<CTFontCollectionRef> for CTFontCollection {
impl TCFType for CTFontCollection {
type Ref = CTFontCollectionRef;

#[inline]
fn as_concrete_TypeRef(&self) -> CTFontCollectionRef {
self.obj
Expand Down Expand Up @@ -87,7 +89,7 @@ impl CTFontCollection {
pub fn new_from_descriptors(descs: &CFArray) -> CTFontCollection {
unsafe {
let key: CFString = TCFType::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
let value = CFNumber::from_i64(1);
let value = CFNumber::from(1i64);
let options = CFDictionary::from_CFType_pairs(&[ (key.as_CFType(), value.as_CFType()) ]);
let font_collection_ref =
CTFontCollectionCreateWithFontDescriptors(descs.as_concrete_TypeRef(),
Expand All @@ -99,7 +101,7 @@ pub fn new_from_descriptors(descs: &CFArray) -> CTFontCollection {
pub fn create_for_all_families() -> CTFontCollection {
unsafe {
let key: CFString = TCFType::wrap_under_get_rule(kCTFontCollectionRemoveDuplicatesOption);
let value = CFNumber::from_i64(1);
let value = CFNumber::from(1i64);
let options = CFDictionary::from_CFType_pairs(&[ (key.as_CFType(), value.as_CFType()) ]);
let font_collection_ref =
CTFontCollectionCreateFromAvailableFonts(options.as_concrete_TypeRef());
Expand Down
12 changes: 7 additions & 5 deletions src/font_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, CFURLRef};
use core_foundation::url::CFURL;
use core_graphics::base::CGFloat;

use libc::c_void;
Expand Down Expand Up @@ -130,7 +130,7 @@ trait TraitAccessorPrivate {
impl TraitAccessorPrivate for CTFontTraits {
unsafe fn extract_number_for_key(&self, key: CFStringRef) -> CFNumber {
let cftype = self.get_CFType(mem::transmute(key));
assert!(cftype.instance_of::<CFNumberRef,CFNumber>());
assert!(cftype.instance_of::<CFNumber>());
TCFType::wrap_under_get_rule(mem::transmute(cftype.as_CFTypeRef()))
}

Expand Down Expand Up @@ -200,7 +200,9 @@ impl Drop for CTFontDescriptor {
}
}

impl TCFType<CTFontDescriptorRef> for CTFontDescriptor {
impl TCFType for CTFontDescriptor {
type Ref = CTFontDescriptorRef;

#[inline]
fn as_concrete_TypeRef(&self) -> CTFontDescriptorRef {
self.obj
Expand Down Expand Up @@ -243,7 +245,7 @@ impl CTFontDescriptor {
}

let value: CFType = TCFType::wrap_under_get_rule(value);
assert!(value.instance_of::<CFStringRef,CFString>());
assert!(value.instance_of::<CFString>());
let s: CFString = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
Some(s.to_string())
}
Expand Down Expand Up @@ -288,7 +290,7 @@ impl CTFontDescriptor {
}

let value: CFType = TCFType::wrap_under_get_rule(value);
assert!(value.instance_of::<CFURLRef,CFURL>());
assert!(value.instance_of::<CFURL>());
let url: CFURL = TCFType::wrap_under_get_rule(mem::transmute(value.as_CFTypeRef()));
Some(format!("{:?}", url))
}
Expand Down