CTFont

Struct CTFont 

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

Implementations§

Source§

impl CTFont

Source

pub unsafe fn with_name( name: &CFString, size: CGFloat, matrix: *const CGAffineTransform, ) -> CFRetained<CTFont>

Returns a new font reference for the given name.

This function uses font descriptor matching so only registered fonts can be returned; see CTFontManager.h for more information. If you are trying to create a system UI font (with name beginning with a “.”), you should use CTFontCreateUIFontForLanguage() or appropriate AppKit/UIKit APIs instead.

Parameter name: The font name for which you wish to create a new font reference. A valid PostScript name is preferred, although other font name types will be matched in a fallback manner. Any font name beginning with a “.” is reserved for the system and should not be used here.

Parameter size: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.

Parameter matrix: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.

Returns: This function will return a CTFontRef that best matches the name provided with size and matrix attributes. The name parameter is the only required parameters, and default values will be used for unspecified parameters. A best match will be found if all parameters cannot be matched identically.

Source

pub unsafe fn with_font_descriptor( descriptor: &CTFontDescriptor, size: CGFloat, matrix: *const CGAffineTransform, ) -> CFRetained<CTFont>

Available on crate feature CTFontDescriptor only.

Returns a new font reference that best matches the font descriptor.

Parameter descriptor: A font descriptor containing attributes that specify the requested font.

Parameter size: The point size for the font reference. If 0.0 is specified and the font descriptor does not specify the size, the default font size of 12.0 will be used.

Parameter matrix: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.

Returns: This function will return a CTFontRef that best matches the attributes provided with the font descriptor. The size and matrix parameters will override any specified in the font descriptor, unless they are unspecified. A best match font will always be returned, and default values will be used for any unspecified.

Source§

impl CTFont

Source

pub unsafe fn with_name_and_options( name: &CFString, size: CGFloat, matrix: *const CGAffineTransform, options: CTFontOptions, ) -> CFRetained<CTFont>

Returns a new font reference for the given name.

This function uses font descriptor matching so only registered fonts can be returned; see CTFontManager.h for more information. If you are trying to create a system UI font (with name beginning with a “.”), you should use CTFontCreateUIFontForLanguage() or appropriate AppKit/UIKit APIs instead.

Parameter name: The font name for which you wish to create a new font reference. A valid PostScript name is preferred, although other font name types will be matched in a fallback manner. Any font name beginning with a “.” is reserved for the system and should not be used here.

Parameter size: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.

Parameter matrix: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.

Parameter options: Options flags.

Returns: This function will return a CTFontRef that best matches the name provided with size and matrix attributes. The name parameter is the only required parameters, and default values will be used for unspecified parameters. A best match will be found if all parameters cannot be matched identically.

Source

pub unsafe fn with_font_descriptor_and_options( descriptor: &CTFontDescriptor, size: CGFloat, matrix: *const CGAffineTransform, options: CTFontOptions, ) -> CFRetained<CTFont>

Available on crate feature CTFontDescriptor only.

Returns a new font reference that best matches the font descriptor.

Parameter descriptor: A font descriptor containing attributes that specify the requested font.

Parameter size: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.

Parameter matrix: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.

Parameter options: Options flags.

Returns: This function will return a CTFontRef that best matches the attributes provided with the font descriptor. The size and matrix parameters will override any specified in the font descriptor, unless they are unspecified. A best match font will always be returned, and default values will be used for any unspecified.

Source§

impl CTFont

Source

pub unsafe fn new_ui_font_for_language( ui_type: CTFontUIFontType, size: CGFloat, language: Option<&CFString>, ) -> Option<CFRetained<CTFont>>

Returns the special UI font for the given language and UI type.

Parameter uiType: A uiType constant specifying the intended UI use for the requested font reference.

Parameter size: The point size for the font reference. If 0.0 is specified, the default size for the requested uiType is used.

Parameter language: Language identifier to select a font for a particular localization. If unspecified, the current system language is used. The format of the language identifier should conform to UTS #35.

Returns: This function returns the correct font for various UI uses. The only required parameter is the uiType selector, unspecified optional parameters will use default values.

Source

pub unsafe fn copy_with_attributes( self: &CTFont, size: CGFloat, matrix: *const CGAffineTransform, attributes: Option<&CTFontDescriptor>, ) -> CFRetained<CTFont>

Available on crate feature CTFontDescriptor only.

Returns a new font with additional attributes based on the original font.

This function provides a mechanism to quickly change attributes on a given font reference in response to user actions. For instance, the size can be changed in response to a user manipulating a size slider.

Parameter font: Original font reference to base new font on.

Parameter size: The point size for the font reference. If 0.0 is specified, the original font’s size will be preserved.

Parameter matrix: The transformation matrix for the font. If unspecified, the original font matrix will be preserved. Optional.

Parameter attributes: A font descriptor containing additional attributes that the new font should contain.

Returns: Returns a new font reference converted from the original with the specified attributes.

Source

pub unsafe fn copy_with_symbolic_traits( self: &CTFont, size: CGFloat, matrix: *const CGAffineTransform, sym_trait_value: CTFontSymbolicTraits, sym_trait_mask: CTFontSymbolicTraits, ) -> Option<CFRetained<CTFont>>

Available on crate feature CTFontTraits only.

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

Parameter font: Original font reference on which to base the new font.

Parameter size: The point size for the font reference. If 0.0 is specified, the original font’s size will be preserved.

Parameter matrix: The transformation matrix for the font. If unspecified, the original font matrix will be preserved. Optional.

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 reference in the same family with the given symbolic traits, or NULL if none found in the system.

Source

pub unsafe fn copy_with_family( self: &CTFont, size: CGFloat, matrix: *const CGAffineTransform, family: &CFString, ) -> Option<CFRetained<CTFont>>

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

Parameter font: Original font reference to base new font on.

Parameter size: The point size for the font reference. If 0.0 is specified, the original font’s size will be preserved.

Parameter matrix: The transformation matrix for the font. If unspecified, the original font matrix will be preserved. Optional.

Parameter family: The name of the desired family.

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

Source

pub unsafe fn for_string( self: &CTFont, string: &CFString, range: CFRange, ) -> CFRetained<CTFont>

Returns a new font reference that can best map the given string range based on the current font.

This function is to be used when the current font does not cover the given range of the string. The current font itself will not be returned, but preference is given to fonts in its cascade list.

Parameter currentFont: The current font that contains a valid cascade list.

Parameter string: A unicode string containing characters that cannot be encoded by the current font.

Parameter range: A CFRange specifying the range of the string that needs to be mapped.

Returns: This function returns the best substitute font that can encode the specified string range.

See also: CTFontCopyCharacterSet

See also: CTFontGetGlyphsForCharacters

See also: kCTFontCascadeListAttribute

Source

pub unsafe fn for_string_with_language( self: &CTFont, string: &CFString, range: CFRange, language: Option<&CFString>, ) -> CFRetained<CTFont>

Returns a new font reference that can best map the given string range based on the current font and language specified.

The current font itself can be returned if it covers the string provided.

Parameter currentFont: The current font that contains a valid cascade list.

Parameter string: A unicode string containing characters that cannot be encoded by the current font.

Parameter range: A CFRange specifying the range of the string that needs to be mapped.

Parameter language: Language identifier to select a font for a particular localization. If unspecified, the current system language is used. The format of the language identifier should conform to UTS #35.

Returns: This function returns the best substitute font that can encode the specified string range.

See also: CTFontCopyCharacterSet

See also: CTFontGetGlyphsForCharacters

See also: kCTFontCascadeListAttribute

Source

pub unsafe fn font_descriptor(self: &CTFont) -> CFRetained<CTFontDescriptor>

Available on crate feature CTFontDescriptor only.

Returns the normalized font descriptors for the given font reference.

Parameter font: The font reference.

Returns: This function returns a normalized font descriptor for a font. The font descriptor contains enough information to recreate this font at a later time.

Source

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

Returns the value associated with an arbitrary attribute.

Parameter font: The font reference.

Parameter attribute: The requested attribute.

Returns: This function returns a retained reference to an arbitrary attribute. If the requested attribute is not present, NULL is returned. Refer to the attribute definitions for documentation as to how each attribute is packaged as a CFType.

Source

pub unsafe fn size(self: &CTFont) -> CGFloat

Returns the point size of the font reference.

Parameter font: The font reference.

Returns: This function returns the point size of the given font reference. This is the point size provided when the font was created.

Source

pub unsafe fn matrix(self: &CTFont) -> CGAffineTransform

Returns the transformation matrix of the font.

Parameter font: The font reference.

Returns: This function returns the transformation matrix for this given font reference. This is the matrix that was provided when the font was created.

Source

pub unsafe fn symbolic_traits(self: &CTFont) -> CTFontSymbolicTraits

Available on crate feature CTFontTraits only.

Returns the symbolic font traits.

Parameter font: The font reference.

Returns: This function returns the symbolic traits of the font. This is equivalent to the kCTFontSymbolicTrait of traits dictionary. See CTFontTraits.h for a definition of the font traits.

Source

pub unsafe fn traits(self: &CTFont) -> CFRetained<CFDictionary>

Returns the font traits dictionary.

Parameter font: The font reference.

Returns: This function returns a retained reference to the font traits dictionary. Individual traits can be accessed with the trait key constants. See CTFontTraits.h for a definition of the font traits.

Source

pub unsafe fn default_cascade_list_for_languages( self: &CTFont, language_pref_list: Option<&CFArray>, ) -> Option<CFRetained<CFArray>>

Return an ordered list of CTFontDescriptorRef’s for font fallback derived from the system default fallback according to the given language preferences, making a reasonable attempt to match the given font’s style, weight, and width.

Parameter font: The font reference.

Parameter languagePrefList: An array of language identifiers as CFString values, in decreasing order of preference.

Returns: The ordered list of fallback fonts - ordered array of CTFontDescriptors.

Source

pub unsafe fn post_script_name(self: &CTFont) -> CFRetained<CFString>

Returns the PostScript name.

Parameter font: The font reference.

Returns: This function returns a retained reference to the PostScript name of the font.

Source

pub unsafe fn family_name(self: &CTFont) -> CFRetained<CFString>

Returns the family name.

Parameter font: The font reference.

Returns: This function returns a retained reference to the family name of the font.

Source

pub unsafe fn full_name(self: &CTFont) -> CFRetained<CFString>

Returns the display name.

Parameter font: The font reference.

Returns: This function returns a retained reference to the full name of the font.

Source

pub unsafe fn display_name(self: &CTFont) -> CFRetained<CFString>

Returns the display name.

Parameter font: The font reference.

Returns: This function returns a retained reference to the localized display name of the font.

Source

pub unsafe fn name( self: &CTFont, name_key: &CFString, ) -> Option<CFRetained<CFString>>

Returns a reference to the requested name.

Parameter font: The font reference.

Parameter nameKey: The name specifier. See name specifier constants.

Returns: This function creates the requested name for the font, or NULL if the font does not have an entry for the requested name. The Unicode version of the name will be preferred, otherwise the first available will be used.

Source

pub unsafe fn localized_name( self: &CTFont, name_key: &CFString, actual_language: *mut *const CFString, ) -> Option<CFRetained<CFString>>

Returns a reference to a localized font name.

Parameter font: The font reference.

Parameter nameKey: The name specifier. See name specifier constants.

Parameter actualLanguage: Pointer to a CFStringRef to receive the language identifier of the returned name string. The format of 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: This function returns a specific localized name from the font reference. The name is localized based on the user’s global language precedence. If the font does not have an entry for the requested name, NULL will be returned. The matched language will be returned in the caller’s buffer.

Source

pub unsafe fn character_set(self: &CTFont) -> CFRetained<CFCharacterSet>

Returns the Unicode character set of the font.

Parameter font: The font reference.

Returns: This function returns a retained reference to the font’s character set. This character set covers the nominal referenced by the font’s Unicode cmap table (or equivalent).

Source

pub unsafe fn string_encoding(self: &CTFont) -> CFStringEncoding

Returns the best string encoding for legacy format support.

Parameter font: The font reference.

Returns: This function returns the best string encoding for the font.

Source

pub unsafe fn supported_languages(self: &CTFont) -> CFRetained<CFArray>

Returns an array of languages supported by the font.

Parameter font: The font reference.

Returns: This function returns a retained reference to an array of languages supported by the font. The array contains language identifier strings as CFStringRefs. The format of the language identifier will conform to UTS #35.

Source

pub unsafe fn glyphs_for_characters( self: &CTFont, characters: NonNull<u16>, glyphs: NonNull<CGGlyph>, count: CFIndex, ) -> bool

Available on crate feature objc2-core-graphics only.

Performs basic character-to-glyph mapping.

This function only provides the nominal mapping as specified by the font’s Unicode cmap (or equivalent); such mapping does not constitute proper Unicode layout: it is the caller’s responsibility to handle the Unicode properties of the characters.

Parameter font: The font reference.

Parameter characters: An array of characters (UTF-16 code units). Non-BMP characters must be encoded as surrogate pairs.

Parameter glyphs: A pointer to a buffer to receive the glyphs. Glyphs for non-BMP characters are sparse: the first glyph corresponds to the full character and the second glyph will be 0.

Parameter count: The capacity of both the characters and glyphs arrays.

Returns: The return value indicates whether all provided characters were successfully mapped. A return value of true indicates that the font mapped all characters. A return value of false indicates that some or all of the characters were not mapped; glyphs for unmapped characters will be 0 (with the exception of those corresponding non-BMP characters as described above).

See also: CTFontCopyCharacterSet

Source

pub unsafe fn ascent(self: &CTFont) -> CGFloat

Returns the scaled font ascent metric.

Parameter font: The font reference.

Returns: This function returns the font ascent metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn descent(self: &CTFont) -> CGFloat

Returns the scaled font descent metric.

Parameter font: The font reference.

Returns: This function returns the font descent metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn leading(self: &CTFont) -> CGFloat

Returns the scaled font leading metric.

Parameter font: The font reference.

Returns: This function returns the font leading metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn units_per_em(self: &CTFont) -> c_uint

Returns the units per em metric.

Parameter font: The font reference.

Returns: This function returns the units per em of the font.

Source

pub unsafe fn glyph_count(self: &CTFont) -> CFIndex

Returns the number of glyphs.

Parameter font: The font reference.

Returns: This function returns the number of glyphs in the font.

Source

pub unsafe fn bounding_box(self: &CTFont) -> CGRect

Returns the scaled bounding box.

Parameter font: The font reference.

Returns: This will return the design bounding box of the font, which is the rectangle defined by xMin, yMin, xMax, and yMax values for the font.

Source

pub unsafe fn underline_position(self: &CTFont) -> CGFloat

Returns the scaled underline position.

Parameter font: The font reference.

Returns: This function returns the font underline position metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn underline_thickness(self: &CTFont) -> CGFloat

Returns the scaled underline thickness metric.

Parameter font: The font reference.

Returns: This function returns the font underline thickness metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn slant_angle(self: &CTFont) -> CGFloat

Returns the slant angle of the font.

Parameter font: The font reference.

Returns: This function returns the transformed slant angle of the font. This is equivalent to the italic or caret angle with any skew from the transformation matrix applied.

Source

pub unsafe fn cap_height(self: &CTFont) -> CGFloat

Returns the cap height metric.

Parameter font: The font reference.

Returns: This function returns the font cap height metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn x_height(self: &CTFont) -> CGFloat

Returns the X height metric.

Parameter font: The font reference.

Returns: This function returns the font X height metric scaled based on the point size and matrix of the font reference.

Source

pub unsafe fn glyph_with_name(self: &CTFont, glyph_name: &CFString) -> CGGlyph

Available on crate feature objc2-core-graphics only.

Returns the CGGlyph for the specified glyph name.

Parameter font: The font reference.

Parameter glyphName: The glyph name as a CFString.

Returns: The glyph with the specified name or 0 if the name is not recognized; this glyph can be used with other Core Text glyph data accessors or with Quartz.

Source

pub unsafe fn name_for_glyph( self: &CTFont, glyph: CGGlyph, ) -> Option<CFRetained<CFString>>

Available on crate feature objc2-core-graphics only.

Returns the name for the specified glyph.

Parameter font: The font reference.

Parameter glyph: The glyph.

Returns: The glyph name as a CFString or NULL if the glyph is invalid.

See also: CTFontGetGlyphWithName

Source

pub unsafe fn bounding_rects_for_glyphs( self: &CTFont, orientation: CTFontOrientation, glyphs: NonNull<CGGlyph>, bounding_rects: *mut CGRect, count: CFIndex, ) -> CGRect

Available on crate features CTFontDescriptor and objc2-core-graphics only.

Calculates the bounding rects for an array of glyphs and returns the overall bounding rect for the run.

Parameter font: The font reference.

Parameter orientation: The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.

Parameter glyphs: An array of count number of glyphs.

Parameter boundingRects: An array of count number of CGRects to receive the computed glyph rects. Can be NULL, in which case only the overall bounding rect is calculated.

Parameter count: The capacity of the glyphs and boundingRects buffers.

Returns: This function returns the overall bounding rectangle for an array or run of glyphs. The bounding rects of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.

Source

pub unsafe fn optical_bounds_for_glyphs( self: &CTFont, glyphs: NonNull<CGGlyph>, bounding_rects: *mut CGRect, count: CFIndex, options: CFOptionFlags, ) -> CGRect

Available on crate feature objc2-core-graphics only.

Calculates the optical bounding rects for an array of glyphs and returns the overall optical bounding rect for the run.

Fonts may specify the optical edges of glyphs that can be used to make the edges of lines of text line up in a more visually pleasing way. This function returns bounding rects corresponding to this information if present in a font, otherwise it returns typographic bounding rects (composed of the font’s ascent and descent and a glyph’s advance width).

Parameter font: The font reference.

Parameter glyphs: An array of count number of glyphs.

Parameter boundingRects: An array of count number of CGRects to receive the computed glyph rects. Can be NULL, in which case only the overall bounding rect is calculated.

Parameter count: The capacity of the glyphs and boundingRects buffers.

Parameter options: Reserved, set to zero.

Returns: This function returns the overall bounding rectangle for an array or run of glyphs. The bounding rects of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.

Source

pub unsafe fn advances_for_glyphs( self: &CTFont, orientation: CTFontOrientation, glyphs: NonNull<CGGlyph>, advances: *mut CGSize, count: CFIndex, ) -> c_double

Available on crate features CTFontDescriptor and objc2-core-graphics only.

Calculates the advances for an array of glyphs and returns the summed advance.

Parameter font: The font reference.

Parameter orientation: The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.

Parameter glyphs: An array of count number of glyphs.

Parameter advances: An array of count number of CGSize to receive the computed glyph advances. Can be NULL, in which case only the overall advance is calculated.

Parameter count: The capacity of the glyphs and advances buffers.

Returns: This function returns the summed glyph advance of an array of glyphs. Individual glyph advances are passed back via the advances parameter. These are the ideal metrics for each glyph scaled and transformed in font space.

Source

pub unsafe fn vertical_translations_for_glyphs( self: &CTFont, glyphs: NonNull<CGGlyph>, translations: NonNull<CGSize>, count: CFIndex, )

Available on crate feature objc2-core-graphics only.

Calculates the offset from the default (horizontal) origin to the vertical origin for an array of glyphs.

Parameter font: The font reference.

Parameter glyphs: An array of count number of glyphs.

Parameter translations: An array of count number of CGSize to receive the computed origin offsets.

Parameter count: The capacity of the glyphs and translations buffers.

Source

pub unsafe fn path_for_glyph( self: &CTFont, glyph: CGGlyph, matrix: *const CGAffineTransform, ) -> Option<CFRetained<CGPath>>

Available on crate feature objc2-core-graphics only.

Creates a path for the specified glyph.

Creates a path from the outlines of the glyph for the specified font. The path will reflect the font point size, matrix, and transform parameter, in that order. The transform parameter will most commonly be used to provide a translation to the desired glyph origin.

Parameter font: The font reference.

Parameter glyph: The glyph.

Parameter matrix: An affine transform applied to the path. Can be NULL, in which case CGAffineTransformIdentity will be used.

Returns: A retained CGPath reference containing the glyph outlines or NULL if there is no such glyph or it has no outline.

Source§

impl CTFont

Source

pub unsafe fn variation_axes(self: &CTFont) -> Option<CFRetained<CFArray>>

Returns an array of variation axis dictionaries.

Each variation axis dictionary contains the five kCTFontVariationAxis* keys above, and kCTFontVariationAxisNameKey values will be localized when supported by the font.

Parameter font: The font reference.

Returns: An array of variation axis dictionaries or null if the font does not support variations.

Source

pub unsafe fn variation(self: &CTFont) -> Option<CFRetained<CFDictionary>>

Returns a variation dictionary.

This function describes the current configuration of a variation font: a dictionary of number values with variation identifier number keys. As of macOS 10.12 and iOS 10.0, only non-default values (as determined by the variation axis) are returned.

Parameter font: The font reference.

Returns: This function returns a variation dictionary or null if the font does not support variations.

See also: kCTFontVariationAxisIdentifierKey

See also: kCTFontVariationAxisDefaultValueKey

Source§

impl CTFont

Source

pub unsafe fn features(self: &CTFont) -> Option<CFRetained<CFArray>>

Returns an array of font features

Parameter font: The font reference.

Returns: This function returns an array of font feature dictionaries for the font reference.

Source

pub unsafe fn feature_settings(self: &CTFont) -> Option<CFRetained<CFArray>>

Returns an array of font feature setting tuples

A setting tuple is a dictionary of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair. Each tuple corresponds to an enabled non-default setting. It is the caller’s responsibility to handle exclusive and non-exclusive settings as necessary.

Parameter font: The font reference.

Returns: This function returns a normalized array of font feature setting dictionaries. The array will only contain the non-default settings that should be applied to the font, or NULL if the default settings should be used.

Source

pub unsafe fn graphics_font( self: &CTFont, attributes: *mut *const CTFontDescriptor, ) -> CFRetained<CGFont>

Available on crate features CTFontDescriptor and objc2-core-graphics only.

Returns a CGFontRef and attributes.

Parameter font: The font reference.

Parameter attributes: A pointer to a CTFontDescriptorRef to receive a font descriptor containing additional attributes. Can be NULL. Must be released by caller.

Returns: This function returns a CGFontRef for the given font reference. Additional attributes from the font will be passed back as a font descriptor via the attributes parameter. The result must be released by the caller.

Source

pub unsafe fn with_graphics_font( graphics_font: &CGFont, size: CGFloat, matrix: *const CGAffineTransform, attributes: Option<&CTFontDescriptor>, ) -> CFRetained<CTFont>

Available on crate features CTFontDescriptor and objc2-core-graphics only.

Creates a new font reference from a CGFontRef.

Parameter graphicsFont: A valid CGFontRef.

Parameter size: The point size for the font reference. If 0.0 is specified, the default font size of 12.0 will be used.

Parameter matrix: The transformation matrix for the font. If unspecified, the identity matrix will be used. Optional.

Parameter attributes: A CTFontDescriptorRef containing additional attributes that should be matched. Optional.

Returns: This function returns a new font reference for an existing CGFontRef with the specified size, matrix, and additional attributes.

Source§

impl CTFont

Source

pub unsafe fn with_quickdraw_instance( name: *const c_char, identifier: i16, style: u8, size: CGFloat, ) -> CFRetained<CTFont>

👎Deprecated: Quickdraw font references are deprecated

Returns a font reference for the given Quickdraw instance.

This function is provided for compatibility support between Core Text and clients needing to support Quickdraw font references.

Parameter name: The Quickdraw font name. If NULL or zero length, an identifier must be specified instead.

Parameter identifier: The Quickdraw font identifier. If 0, a name must be specified instead.

Parameter style: The Quickdraw font style.

Parameter size: The point size for the font reference. If 0.0 is specified, the default size of 12.0 is used.

Returns: This function returns the best font instance matching the Quickdraw instance information.

Source§

impl CTFont

Source

pub unsafe fn available_tables( self: &CTFont, options: CTFontTableOptions, ) -> Option<CFRetained<CFArray>>

Returns an array of font table tags.

Parameter font: The font reference.

Parameter options: The options used when copying font tables.

Returns: This function returns an array of CTFontTableTag values for the given font and the supplied options. The returned set will contain unboxed values, which may be extracted like so: CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tags, index);

Source

pub unsafe fn has_table(self: &CTFont, tag: CTFontTableTag) -> bool

Determine whether a table is present in a font.

This is a convenience function to avoid requesting an array of table tags or any table data. It behaves according as if using kCTFontTableOptionNoOptions.

Parameter font: The font reference.

Parameter tag: The font table identifier as a CTFontTableTag.

Returns: Returns true if the call was successful and the requested table is present.

Source

pub unsafe fn table( self: &CTFont, table: CTFontTableTag, options: CTFontTableOptions, ) -> Option<CFRetained<CFData>>

Returns a reference to the font table data.

Parameter font: The font reference.

Parameter table: The font table identifier as a CTFontTableTag.

Parameter options: The options used when copying font table.

Returns: This function returns a retained reference to the font table data as CFDataRef or NULL if the table is not present.

Source

pub unsafe fn draw_glyphs( self: &CTFont, glyphs: NonNull<CGGlyph>, positions: NonNull<CGPoint>, count: usize, context: &CGContext, )

Available on crate feature objc2-core-graphics only.

Renders the given glyphs from the CTFont at the given positions in the CGContext.

This function will modify the CGContext’s font, text size, and text matrix if specified in the CTFont. These attributes will not be restored. The given glyphs should be the result of proper Unicode text layout operations (such as CTLine). Results from CTFontGetGlyphsForCharacters (or similar APIs) do not perform any Unicode text layout.

Parameter font: The font to render glyphs from. If the font has a size or matrix attribute, the CGContext will be set with these values.

Parameter glyphs: The glyphs to be rendered. See above discussion of how the glyphs should be derived.

Parameter positions: The positions (origins) for each glyph. The positions are in user space. The number of positions passed in must be equivalent to the number of glyphs.

Parameter count: The number of glyphs to be rendered from the glyphs array.

Parameter context: CGContext used to render the glyphs.

Source

pub unsafe fn ligature_caret_positions( self: &CTFont, glyph: CGGlyph, positions: *mut CGFloat, max_positions: CFIndex, ) -> CFIndex

Available on crate feature objc2-core-graphics only.

Returns caret positions within a glyph.

This function is used to obtain caret positions for a specific glyph. The return value is the max number of positions possible, and the function will populate the caller’s positions buffer with available positions if possible. This function may not be able to produce positions if the font does not have the appropriate data, in which case it will return 0.

Parameter font: The font reference.

Parameter glyph: The glyph.

Parameter positions: A buffer of at least maxPositions to receive the ligature caret positions for the glyph.

Parameter maxPositions: The maximum number of positions to return.

Returns: Returns the number of caret positions for the specified glyph.

Source§

impl CTFont

Source

pub unsafe fn typographic_bounds_for_adaptive_image_provider( self: &CTFont, provider: Option<&ProtocolObject<dyn CTAdaptiveImageProviding>>, ) -> CGRect

Available on crate features CTRunDelegate and objc2 only.
Source

pub unsafe fn draw_image_from_adaptive_image_provider_at_point( self: &CTFont, provider: &ProtocolObject<dyn CTAdaptiveImageProviding>, point: CGPoint, context: &CGContext, )

Available on crate features CTRunDelegate and objc2 and objc2-core-graphics only.

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 CTFont

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<CFType> for CTFont

Source§

fn as_ref(&self) -> &CFType

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

impl AsRef<CTFont> for CTFont

Source§

fn as_ref(&self) -> &Self

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

impl Borrow<AnyObject> for CTFont

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for CTFont

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for CTFont

Source§

fn type_id() -> CFTypeID

Returns the type identifier for Core Text font references.

Returns: The identifier for the opaque type CTFontRef.

Source§

impl Debug for CTFont

Source§

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

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

impl Deref for CTFont

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Hash for CTFont

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 CTFont

Source§

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

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

impl PartialEq for CTFont

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 CTFont

Source§

const ENCODING_REF: Encoding

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

impl Type for CTFont

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 CTFont

Auto Trait Implementations§

§

impl !Freeze for CTFont

§

impl !RefUnwindSafe for CTFont

§

impl !Send for CTFont

§

impl !Sync for CTFont

§

impl !Unpin for CTFont

§

impl !UnwindSafe for CTFont

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,