CTFontDescriptor

Struct CTFontDescriptor 

Source
#[repr(C)]
pub struct CTFontDescriptor { /* private fields */ }
Available on crate feature CTFontDescriptor only.
Expand description

Implementations§

Source§

impl CTFontDescriptor

Source

pub unsafe fn with_name_and_size( name: &CFString, size: CGFloat, ) -> CFRetained<CTFontDescriptor>

Creates a new font descriptor with the provided PostScript name and size.

Parameter name: The PostScript name to be used for the font descriptor as a CFStringRef. Any font name beginning with a “.” is reserved for the system and should not be used here.

Parameter size: The point size. If 0.0, the kCTFontSizeAttribute will be omitted from the font descriptor.

Returns: This function creates a new font descriptor reference with the given PostScript name and point size.

If you are trying to create a system UI font descriptor (with name beginning with a “.”), you should create a font with CTFontCreateUIFontForLanguage() or appropriate AppKit/UIKit APIs instead, then use CTFontCopyFontDescriptor() to get its font descriptor.

Source

pub unsafe fn with_attributes( attributes: &CFDictionary, ) -> CFRetained<CTFontDescriptor>

Creates a new font descriptor reference from a dictionary of attributes.

Parameter attributes: A CFDictionaryRef of arbitrary attributes.

Returns: This function creates a new font descriptor with the attributes specified. This dictionary can contain arbitrary attributes that will be preserved, however unrecognized attributes will be ignored on font creation and and may not be preserved over the round trip (descriptor -> font -> descriptor).

Source

pub unsafe fn copy_with_attributes( self: &CTFontDescriptor, attributes: &CFDictionary, ) -> CFRetained<CTFontDescriptor>

Creates a copy of the original font descriptor with new attributes.

Parameter original: The original font descriptor reference.

Parameter attributes: A CFDictionaryRef of arbitrary attributes.

Returns: This function creates a new copy of the original font descriptor with attributes augmented by those specified. If there are conflicts between attributes, the new attributes will replace existing ones, except for kCTFontVariationAttribute and kCTFontFeatureSettingsAttribute which will be merged.

Starting with macOS 10.12 and iOS 10.0, setting the value of kCTFontFeatureSettingsAttribute to kCFNull will clear the feature settings of the original font descriptor. Setting the value of any individual feature settings pair in the kCTFontFeatureSettingsAttribute value array to kCFNull will clear that feature setting alone. For example, an element like @ { (id)kCTFontFeatureTypeIdentifierKey: @ (kLigaturesType), (id)kCTFontFeatureSelectorIdentifierKey: (id)kCFNull } means clear the kLigatureType feature set in the original font descriptor. An element like @ [ “ liga“, (id)kCFNull ] will have the same effect.

Source

pub unsafe fn copy_with_family( self: &CTFontDescriptor, family: &CFString, ) -> Option<CFRetained<CTFontDescriptor>>

Returns a new font descriptor in the specified family based on the traits of the original descriptor.

Parameter original: The original font descriptor reference.

Parameter family: The name of the desired family.

Returns: Returns a new font reference with the original traits in the given family, or NULL if none found in the system.

Source

pub unsafe fn copy_with_symbolic_traits( self: &CTFontDescriptor, sym_trait_value: CTFontSymbolicTraits, sym_trait_mask: CTFontSymbolicTraits, ) -> Option<CFRetained<CTFontDescriptor>>

Available on crate feature CTFontTraits only.

Returns a new font descriptor based on the original descriptor having the specified symbolic traits.

Parameter original: The original font descriptor reference.

Parameter symTraitValue: The value of the symbolic traits. This bitfield is used to indicate the desired value for the traits specified by the symTraitMask parameter. Used in conjunction, they can allow for trait removal as well as addition.

Parameter symTraitMask: The mask bits of the symbolic traits. This bitfield is used to indicate the traits that should be changed.

Returns: Returns a new font descriptor reference in the same family with the given symbolic traits, or NULL if none found in the system.

Source

pub unsafe fn copy_with_variation( self: &CTFontDescriptor, variation_identifier: &CFNumber, variation_value: CGFloat, ) -> CFRetained<CTFontDescriptor>

Creates a copy of the original font descriptor with a new variation instance.

Parameter original: The original font descriptor reference.

Parameter variationIdentifier: The variation axis identifier. This is the four character code of the variation axis as a CFNumberRef.

Parameter variationValue: The value corresponding with the variation instance.

Returns: This function returns a copy of the original font descriptor with a new variation instance. This is a convenience method for easily creating new variation font instances.

Source

pub unsafe fn copy_with_feature( self: &CTFontDescriptor, feature_type_identifier: &CFNumber, feature_selector_identifier: &CFNumber, ) -> CFRetained<CTFontDescriptor>

Copies a font descriptor with new feature setting.

This is a convenience method to more easily toggle the state of individual features.

Parameter original: The original font descriptor reference.

Parameter featureTypeIdentifier: The feature type identifier.

Parameter featureSelectorIdentifier: The feature selector identifier.

Returns: A copy of the original font descriptor modified with the given feature settings.

Source

pub unsafe fn matching_font_descriptors( self: &CTFontDescriptor, mandatory_attributes: Option<&CFSet>, ) -> Option<CFRetained<CFArray>>

Returns an array of font normalized font descriptors matching the provided descriptor.

Parameter descriptor: The font descriptor reference.

Parameter mandatoryAttributes: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.

Returns: This function returns a retained array of normalized font descriptors matching the attributes present in descriptor. If descriptor itself is normalized then the array will contain only one item, the original descriptor.

Source

pub unsafe fn matching_font_descriptor( self: &CTFontDescriptor, mandatory_attributes: Option<&CFSet>, ) -> Option<CFRetained<CTFontDescriptor>>

Returns an the single preferred matching font descriptor based on the original descriptor and system precedence.

Parameter descriptor: The font descriptor reference.

Parameter mandatoryAttributes: A set of attribute keys which are required to be identically matched in any returned font descriptors. Optional.

Returns: This function returns a retained normalized font descriptor matching the attributes present in descriptor. The original descriptor may be returned in normalized form.

Source§

impl CTFontDescriptor

Source

pub unsafe fn match_font_descriptors_with_progress_handler( descriptors: &CFArray, mandatory_attributes: Option<&CFSet>, progress_block: CTFontDescriptorProgressHandler, ) -> bool

Available on crate feature block2 only.
Source

pub unsafe fn attributes(self: &CTFontDescriptor) -> CFRetained<CFDictionary>

Returns the attributes dictionary of the font descriptor.

Parameter descriptor: The font descriptor reference.

Returns: A retained reference to the font descriptor attributes dictionary. This dictionary will contain the minimum number of attributes to fully specify this particular font descriptor.

Source

pub unsafe fn attribute( self: &CTFontDescriptor, attribute: &CFString, ) -> Option<CFRetained<CFType>>

Returns the value associated with an arbitrary attribute.

Parameter descriptor: The font descriptor.

Parameter attribute: The requested attribute.

Returns: A retained reference to the requested attribute, or NULL if the requested attribute is not present. Refer to the attribute definitions for documentation as to how each attribute is packaged as a CFType.

Source

pub unsafe fn localized_attribute( self: &CTFontDescriptor, attribute: &CFString, language: *mut *const CFString, ) -> Option<CFRetained<CFType>>

function CTFontDescriptorCopyLocalizedAttribute

Returns a localized value for the requested attribute if available.

This function returns a localized attribute based on the global language list. If localization is not possible for the attribute the behavior matches CTFontDescriptorCopyAttribute(). Generally, localization of attributes is only applicable to name attributes of a normalized font descriptor.

Parameter descriptor: The font descriptor reference.

Parameter attribute: The requested font attribute.

Parameter language: If non-NULL, this will be receive a retained reference to the matched language. The language identifier will conform to UTS #35. If CoreText can supply its own localized string where the font cannot, this value will be NULL.

Returns: A retained reference to the requested attribute, or NULL if the requested attribute is not present. Refer to the attribute definitions for documentation as to how each attribute is packaged as a CFType.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AnyObject> for CTFontDescriptor

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for CTFontDescriptor

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CTFontDescriptor> for CTFontDescriptor

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for CTFontDescriptor

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for CTFontDescriptor

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for CTFontDescriptor

Source§

fn type_id() -> CFTypeID

Returns the type identifier for Core Text font descriptor references.

Returns: The identifier for the opaque type CTFontDescriptorRef.

Source§

impl Debug for CTFontDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for CTFontDescriptor

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for CTFontDescriptor

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for CTFontDescriptor

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for CTFontDescriptor

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for CTFontDescriptor

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for CTFontDescriptor

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for CTFontDescriptor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,