pub struct CTFontDescriptor { /* private fields */ }CTFontDescriptor only.Expand description
This is toll-free bridged with NSFontDescriptor.
Implementations§
Source§impl CTFontDescriptor
impl CTFontDescriptor
Sourcepub unsafe fn with_name_and_size(
name: &CFString,
size: CGFloat,
) -> CFRetained<CTFontDescriptor>
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.
Sourcepub unsafe fn with_attributes(
attributes: &CFDictionary,
) -> CFRetained<CTFontDescriptor>
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).
§Safety
attributes generics must be of the correct type.
Sourcepub unsafe fn copy_with_attributes(
&self,
attributes: &CFDictionary,
) -> CFRetained<CTFontDescriptor>
pub unsafe fn copy_with_attributes( &self, 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.
See also: kCTFontFeatureSettingsAttribute
§Safety
attributes generics must be of the correct type.
Sourcepub unsafe fn copy_with_family(
&self,
family: &CFString,
) -> Option<CFRetained<CTFontDescriptor>>
pub unsafe fn copy_with_family( &self, 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.
Sourcepub unsafe fn copy_with_symbolic_traits(
&self,
sym_trait_value: CTFontSymbolicTraits,
sym_trait_mask: CTFontSymbolicTraits,
) -> Option<CFRetained<CTFontDescriptor>>
Available on crate feature CTFontTraits only.
pub unsafe fn copy_with_symbolic_traits( &self, sym_trait_value: CTFontSymbolicTraits, sym_trait_mask: CTFontSymbolicTraits, ) -> Option<CFRetained<CTFontDescriptor>>
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.
Sourcepub unsafe fn copy_with_variation(
&self,
variation_identifier: &CFNumber,
variation_value: CGFloat,
) -> CFRetained<CTFontDescriptor>
pub unsafe fn copy_with_variation( &self, 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.
Sourcepub unsafe fn copy_with_feature(
&self,
feature_type_identifier: &CFNumber,
feature_selector_identifier: &CFNumber,
) -> CFRetained<CTFontDescriptor>
pub unsafe fn copy_with_feature( &self, 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.
See also: CTFontDescriptorCreateCopyWithAttributes
See also: kCTFontFeatureSettingsAttribute
Sourcepub unsafe fn matching_font_descriptors(
&self,
mandatory_attributes: Option<&CFSet>,
) -> Option<CFRetained<CFArray>>
pub unsafe fn matching_font_descriptors( &self, 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.
§Safety
mandatory_attributes generic must be of the correct type.
Sourcepub unsafe fn matching_font_descriptor(
&self,
mandatory_attributes: Option<&CFSet>,
) -> Option<CFRetained<CTFontDescriptor>>
pub unsafe fn matching_font_descriptor( &self, 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.
§Safety
mandatory_attributes generic must be of the correct type.
Source§impl CTFontDescriptor
impl CTFontDescriptor
Sourcepub unsafe fn match_font_descriptors_with_progress_handler(
descriptors: &CFArray,
mandatory_attributes: Option<&CFSet>,
progress_block: CTFontDescriptorProgressHandler,
) -> bool
Available on crate feature block2 only.
pub unsafe fn match_font_descriptors_with_progress_handler( descriptors: &CFArray, mandatory_attributes: Option<&CFSet>, progress_block: CTFontDescriptorProgressHandler, ) -> bool
block2 only.§Safety
descriptorsgeneric must be of the correct type.mandatory_attributesgeneric must be of the correct type.progress_blockmust be a valid pointer.
Sourcepub unsafe fn attributes(&self) -> CFRetained<CFDictionary>
pub unsafe fn attributes(&self) -> 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.
Sourcepub unsafe fn attribute(
&self,
attribute: &CFString,
) -> Option<CFRetained<CFType>>
pub unsafe fn attribute( &self, 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.
Sourcepub unsafe fn localized_attribute(
&self,
attribute: &CFString,
language: *mut *const CFString,
) -> Option<CFRetained<CFType>>
pub unsafe fn localized_attribute( &self, 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.
§Safety
language must be a valid pointer or null.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
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.
Sourcepub fn retain_count(&self) -> usize
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
impl AsRef<AnyObject> for CTFontDescriptor
Source§impl AsRef<CFType> for CTFontDescriptor
impl AsRef<CFType> for CTFontDescriptor
Source§impl AsRef<CTFontDescriptor> for CTFontDescriptor
impl AsRef<CTFontDescriptor> for CTFontDescriptor
Source§impl Borrow<AnyObject> for CTFontDescriptor
impl Borrow<AnyObject> for CTFontDescriptor
Source§impl Borrow<CFType> for CTFontDescriptor
impl Borrow<CFType> for CTFontDescriptor
Source§impl ConcreteType for CTFontDescriptor
impl ConcreteType for CTFontDescriptor
Source§impl Debug for CTFontDescriptor
impl Debug for CTFontDescriptor
Source§impl Deref for CTFontDescriptor
impl Deref for CTFontDescriptor
Source§impl Hash for CTFontDescriptor
impl Hash for CTFontDescriptor
Source§impl Message for CTFontDescriptor
impl Message for CTFontDescriptor
Source§impl PartialEq for CTFontDescriptor
impl PartialEq for CTFontDescriptor
Source§impl RefEncode for CTFontDescriptor
impl RefEncode for CTFontDescriptor
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CTFontDescriptor
impl Type for CTFontDescriptor
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more