diff --git a/font.rs b/font.rs index 308d806..1859cfd 100644 --- a/font.rs +++ b/font.rs @@ -1,62 +1,19 @@ extern mod core_foundation; extern mod core_graphics; -use libc::c_uint; +use font_descriptor::{CTFontDescriptor, CTFontDescriptorRef, CTFontOrientation}; +use font_descriptor::{CTFontSymbolicTraits, CTFontTraits, SymbolicTraitAccessors, TraitAccessors}; -use font_descriptor::{ - CTFontDescriptorRef, - CTFontOrientation, - CTFontSymbolicTraits, - CTFontTraits, - SymbolicTraitAccessors, - TraitAccessors, -}; - -use cf = core_foundation; -use cf::array::{ - CFArrayRef, -}; -use cf::base::{ - AbstractCFTypeRef, - CFIndex, - CFOptionFlags, - CFTypeID, - CFTypeRef, - CFWrapper, -}; -use cf::data::{ - CFData, - CFDataRef, -}; -use cf::dictionary::{ - CFDictionaryRef, - UntypedCFDictionary, -}; -use cf::string::{ - CFStringGetTypeID, - CFString, - CFStringRef, - UniChar -}; - -use cg = core_graphics; -use cg::base::{ - CGAffineTransform, - CGFloat, -}; -use cg::font::{ - CGGlyph, - CGFont, - CGFontRef, -}; -use cg::geometry::{ - CGRect, - CGSize, -}; - -use font_descriptor::{ - CTFontDescriptor -}; +use core::libc::c_uint; +use core_foundation::array::{CFArrayRef}; +use core_foundation::base::{AbstractCFTypeRef, CFIndex, CFOptionFlags, CFTypeID, CFTypeRef}; +use core_foundation::base::{CFWrapper}; +use core_foundation::data::{CFData, CFDataRef}; +use core_foundation::dictionary::{CFDictionaryRef, UntypedCFDictionary}; +use core_foundation::string::{CFStringGetTypeID, CFString, CFStringRef, UniChar}; +use core_graphics::base::{CGAffineTransform, CGFloat}; +use core_graphics::font::{CGGlyph, CGFont, CGFontRef}; +use core_graphics::geometry::{CGRect, CGSize}; pub type CTFontUIFontType = u32; // kCTFontNoFontType: CTFontUIFontType = -1; diff --git a/font_collection.rs b/font_collection.rs index 95e6b46..cbea144 100644 --- a/font_collection.rs +++ b/font_collection.rs @@ -1,29 +1,15 @@ -use cf = core_foundation; -use cf::array::{CFArray, CFArrayRef}; -use cf::base::{ - AbstractCFTypeRef, - CFAllocatorRef, - CFIndex, - CFRange, - CFTypeID, - CFTypeRef, - CFWrapper, - kCFAllocatorDefault, -}; -use cf::dictionary::{CFDictionary, CFDictionaryRef, UntypedCFDictionary}; -use cf::number::CFNumber; -use cf::set::CFSet; -use cf::string::{CFString, CFStringRef}; - -use font_descriptor::{ - CTFontAttributes, - CTFontDescriptor, - CTFontDescriptorCreateMatchingFontDescriptors, - CTFontDescriptorRef, -}; +use font_descriptor::{CTFontAttributes, CTFontDescriptor}; +use font_descriptor::{CTFontDescriptorCreateMatchingFontDescriptors, CTFontDescriptorRef}; use font_manager::CTFontManagerCopyAvailableFontFamilyNames; -use libc::c_void; +use core::libc::c_void; +use core_foundation::array::{CFArray, CFArrayRef}; +use core_foundation::base::{AbstractCFTypeRef, CFAllocatorRef, CFIndex, CFRange, CFTypeID}; +use core_foundation::base::{CFTypeRef, CFWrapper, kCFAllocatorDefault}; +use core_foundation::dictionary::{CFDictionary, CFDictionaryRef, UntypedCFDictionary}; +use core_foundation::number::CFNumber; +use core_foundation::set::CFSet; +use core_foundation::string::{CFString, CFStringRef}; struct __CTFontCollection { private: () } pub type CTFontCollectionRef = *__CTFontCollection; @@ -41,7 +27,7 @@ pub trait CTFontCollectionMethods { pub impl CTFontCollection : CTFontCollectionMethods { pure fn get_descriptors() -> CFArray unsafe { - use cf::base::CFRetain; + use core_foundation::base::CFRetain; // surprise! this function follows the Get rule, despite being named *Create*. // So we have to addRef it to avoid CTFontCollection from double freeing it later. @@ -110,4 +96,4 @@ extern { options: CFDictionaryRef) -> CTFontCollectionRef; //fn CTFontCollectionCreateMatchingFontDescriptorsSortedWithCallback; fn CTFontCollectionGetTypeID() -> CFTypeID; -} \ No newline at end of file +} diff --git a/font_descriptor.rs b/font_descriptor.rs index b7ff666..4264cf1 100644 --- a/font_descriptor.rs +++ b/font_descriptor.rs @@ -1,38 +1,12 @@ -use cf = core_foundation; -use cf::array::CFArrayRef; -use cf::base::{ - AbstractCFTypeRef, - CFAllocatorRef, - CFIndex, - CFGetTypeID, - CFRange, - CFType, - CFTypeID, - CFTypeRef, - CFWrapper, - kCFAllocatorDefault, -}; -use cf::dictionary::{ - CFDictionary, - CFDictionaryRef, - UntypedCFDictionary, -}; -use cf::number::{CFNumber, CFNumberRef}; -use cf::set::CFSetRef; -use cf::string::{ - CFString, - CFStringRef, - CFStringGetTypeID, -}; -use cf::url::{ - CFURL, - CFURLRef, - CFURLGetTypeID, -}; - -use cg = core_graphics; -use cg::base::CGFloat; - +use core_foundation::array::CFArrayRef; +use core_foundation::base::{AbstractCFTypeRef, CFAllocatorRef, CFIndex, CFGetTypeID, CFRange}; +use core_foundation::base::{CFType, CFTypeID, CFTypeRef, CFWrapper, kCFAllocatorDefault}; +use core_foundation::dictionary::{CFDictionary, CFDictionaryRef, UntypedCFDictionary}; +use core_foundation::number::{CFNumber, CFNumberRef}; +use core_foundation::set::CFSetRef; +use core_foundation::string::{CFString, CFStringRef, CFStringGetTypeID}; +use core_foundation::url::{CFURL, CFURLRef, CFURLGetTypeID}; +use core_graphics::base::CGFloat; use libc::c_void; /* @@ -142,7 +116,7 @@ priv trait TraitAccessorPrivate { impl CTFontTraits: TraitAccessorPrivate { priv fn extract_number_for_key(key: CFStringRef) -> CFNumber { let value = self.get(&key); - CFWrapper::wrap_shared(cf::base::downcast::(value)) + CFWrapper::wrap_shared(core_foundation::base::downcast::(value)) } } @@ -212,7 +186,8 @@ impl CTFontDescriptor: CTFontDescriptorMethodsPrivate { let value = CTFontDescriptorCopyAttribute(self.obj, attribute); if value.is_null() { return None; } - Some(CFWrapper::wrap_owned(cf::base::downcast::(value)).to_str()) + Some(CFWrapper::wrap_owned(core_foundation::base::downcast::( + value)).to_str()) } } @@ -242,12 +217,14 @@ pub impl CTFontDescriptor : CTFontDescriptorMethods { let value = CTFontDescriptorCopyAttribute(self.obj, kCTFontURLAttribute); assert value.is_not_null(); - CFWrapper::wrap_owned(cf::base::downcast::(value)).to_str() + CFWrapper::wrap_owned(core_foundation::base::downcast::(value)).to_str() } } -pub fn new_from_attributes(attributes: &CFWrapper) -> CTFontDescriptor { - let result : CTFontDescriptorRef = CTFontDescriptorCreateWithAttributes(*attributes.borrow_ref()); +pub fn new_from_attributes(attributes: &CFWrapper) + -> CTFontDescriptor { + let result: CTFontDescriptorRef = + CTFontDescriptorCreateWithAttributes(*attributes.borrow_ref()); CFWrapper::wrap_owned(result) } @@ -322,4 +299,4 @@ extern { fn CTFontDescriptorCreateWithAttributes(attributes: CFDictionaryRef) -> CTFontDescriptorRef; fn CTFontDescriptorCreateWithNameAndSize(name: CFStringRef, size: CGFloat) -> CTFontDescriptorRef; fn CTFontDescriptorGetTypeID() -> CFTypeID; -} \ No newline at end of file +} diff --git a/font_manager.rs b/font_manager.rs index 98f1a38..8538d95 100644 --- a/font_manager.rs +++ b/font_manager.rs @@ -1,6 +1,5 @@ -use cf = core_foundation; -use cf::array::CFArrayRef; -use cf::url::CFURLRef; +use core_foundation::array::CFArrayRef; +use core_foundation::url::CFURLRef; extern { /* @@ -29,4 +28,4 @@ extern { //fn CTFontManagerUnregisterFontsForURL //fn CTFontManagerUnregisterFontsForURLs //fn CTFontManagerUnregisterGraphicsFont -} \ No newline at end of file +}