#[repr(C)]pub struct CTFont { /* private fields */ }CTFont only.Expand description
Implementations§
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn with_name(
name: &CFString,
size: CGFloat,
matrix: *const CGAffineTransform,
) -> CFRetained<CTFont>
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.
Sourcepub unsafe fn with_font_descriptor(
descriptor: &CTFontDescriptor,
size: CGFloat,
matrix: *const CGAffineTransform,
) -> CFRetained<CTFont>
Available on crate feature CTFontDescriptor only.
pub unsafe fn with_font_descriptor( descriptor: &CTFontDescriptor, size: CGFloat, matrix: *const CGAffineTransform, ) -> CFRetained<CTFont>
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
impl CTFont
Sourcepub unsafe fn with_name_and_options(
name: &CFString,
size: CGFloat,
matrix: *const CGAffineTransform,
options: CTFontOptions,
) -> CFRetained<CTFont>
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.
Sourcepub unsafe fn with_font_descriptor_and_options(
descriptor: &CTFontDescriptor,
size: CGFloat,
matrix: *const CGAffineTransform,
options: CTFontOptions,
) -> CFRetained<CTFont>
Available on crate feature CTFontDescriptor only.
pub unsafe fn with_font_descriptor_and_options( descriptor: &CTFontDescriptor, size: CGFloat, matrix: *const CGAffineTransform, options: CTFontOptions, ) -> CFRetained<CTFont>
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
impl CTFont
Sourcepub unsafe fn new_ui_font_for_language(
ui_type: CTFontUIFontType,
size: CGFloat,
language: Option<&CFString>,
) -> Option<CFRetained<CTFont>>
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.
Sourcepub unsafe fn copy_with_attributes(
self: &CTFont,
size: CGFloat,
matrix: *const CGAffineTransform,
attributes: Option<&CTFontDescriptor>,
) -> CFRetained<CTFont>
Available on crate feature CTFontDescriptor only.
pub unsafe fn copy_with_attributes( self: &CTFont, size: CGFloat, matrix: *const CGAffineTransform, attributes: Option<&CTFontDescriptor>, ) -> CFRetained<CTFont>
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.
Sourcepub 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.
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>>
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.
Sourcepub unsafe fn copy_with_family(
self: &CTFont,
size: CGFloat,
matrix: *const CGAffineTransform,
family: &CFString,
) -> Option<CFRetained<CTFont>>
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.
Sourcepub unsafe fn for_string(
self: &CTFont,
string: &CFString,
range: CFRange,
) -> CFRetained<CTFont>
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
Sourcepub unsafe fn for_string_with_language(
self: &CTFont,
string: &CFString,
range: CFRange,
language: Option<&CFString>,
) -> CFRetained<CTFont>
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
Sourcepub unsafe fn font_descriptor(self: &CTFont) -> CFRetained<CTFontDescriptor>
Available on crate feature CTFontDescriptor only.
pub unsafe fn font_descriptor(self: &CTFont) -> CFRetained<CTFontDescriptor>
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.
Sourcepub unsafe fn attribute(
self: &CTFont,
attribute: &CFString,
) -> Option<CFRetained<CFType>>
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.
Sourcepub unsafe fn size(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn matrix(self: &CTFont) -> CGAffineTransform
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.
Sourcepub unsafe fn symbolic_traits(self: &CTFont) -> CTFontSymbolicTraits
Available on crate feature CTFontTraits only.
pub unsafe fn symbolic_traits(self: &CTFont) -> CTFontSymbolicTraits
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.
Sourcepub unsafe fn traits(self: &CTFont) -> CFRetained<CFDictionary>
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.
Sourcepub unsafe fn default_cascade_list_for_languages(
self: &CTFont,
language_pref_list: Option<&CFArray>,
) -> Option<CFRetained<CFArray>>
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.
Sourcepub unsafe fn post_script_name(self: &CTFont) -> CFRetained<CFString>
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.
Sourcepub unsafe fn family_name(self: &CTFont) -> CFRetained<CFString>
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.
Sourcepub unsafe fn full_name(self: &CTFont) -> CFRetained<CFString>
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.
Sourcepub unsafe fn display_name(self: &CTFont) -> CFRetained<CFString>
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.
Sourcepub unsafe fn name(
self: &CTFont,
name_key: &CFString,
) -> Option<CFRetained<CFString>>
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.
Sourcepub unsafe fn localized_name(
self: &CTFont,
name_key: &CFString,
actual_language: *mut *const CFString,
) -> Option<CFRetained<CFString>>
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.
Sourcepub unsafe fn character_set(self: &CTFont) -> CFRetained<CFCharacterSet>
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).
Sourcepub unsafe fn string_encoding(self: &CTFont) -> CFStringEncoding
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.
Sourcepub unsafe fn supported_languages(self: &CTFont) -> CFRetained<CFArray>
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.
Sourcepub unsafe fn glyphs_for_characters(
self: &CTFont,
characters: NonNull<u16>,
glyphs: NonNull<CGGlyph>,
count: CFIndex,
) -> bool
Available on crate feature objc2-core-graphics only.
pub unsafe fn glyphs_for_characters( self: &CTFont, characters: NonNull<u16>, glyphs: NonNull<CGGlyph>, count: CFIndex, ) -> bool
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
Sourcepub unsafe fn ascent(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn descent(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn leading(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn units_per_em(self: &CTFont) -> c_uint
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.
Sourcepub unsafe fn glyph_count(self: &CTFont) -> CFIndex
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.
Sourcepub unsafe fn bounding_box(self: &CTFont) -> CGRect
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.
Sourcepub unsafe fn underline_position(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn underline_thickness(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn slant_angle(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn cap_height(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn x_height(self: &CTFont) -> CGFloat
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.
Sourcepub unsafe fn glyph_with_name(self: &CTFont, glyph_name: &CFString) -> CGGlyph
Available on crate feature objc2-core-graphics only.
pub unsafe fn glyph_with_name(self: &CTFont, glyph_name: &CFString) -> CGGlyph
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.
Sourcepub unsafe fn name_for_glyph(
self: &CTFont,
glyph: CGGlyph,
) -> Option<CFRetained<CFString>>
Available on crate feature objc2-core-graphics only.
pub unsafe fn name_for_glyph( self: &CTFont, glyph: CGGlyph, ) -> Option<CFRetained<CFString>>
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
Sourcepub 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.
pub unsafe fn bounding_rects_for_glyphs( self: &CTFont, orientation: CTFontOrientation, glyphs: NonNull<CGGlyph>, bounding_rects: *mut CGRect, count: CFIndex, ) -> CGRect
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.
Sourcepub 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.
pub unsafe fn optical_bounds_for_glyphs( self: &CTFont, glyphs: NonNull<CGGlyph>, bounding_rects: *mut CGRect, count: CFIndex, options: CFOptionFlags, ) -> CGRect
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.
Sourcepub 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.
pub unsafe fn advances_for_glyphs( self: &CTFont, orientation: CTFontOrientation, glyphs: NonNull<CGGlyph>, advances: *mut CGSize, count: CFIndex, ) -> c_double
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.
Sourcepub unsafe fn vertical_translations_for_glyphs(
self: &CTFont,
glyphs: NonNull<CGGlyph>,
translations: NonNull<CGSize>,
count: CFIndex,
)
Available on crate feature objc2-core-graphics only.
pub unsafe fn vertical_translations_for_glyphs( self: &CTFont, glyphs: NonNull<CGGlyph>, translations: NonNull<CGSize>, count: CFIndex, )
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.
Sourcepub unsafe fn path_for_glyph(
self: &CTFont,
glyph: CGGlyph,
matrix: *const CGAffineTransform,
) -> Option<CFRetained<CGPath>>
Available on crate feature objc2-core-graphics only.
pub unsafe fn path_for_glyph( self: &CTFont, glyph: CGGlyph, matrix: *const CGAffineTransform, ) -> Option<CFRetained<CGPath>>
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
impl CTFont
Sourcepub unsafe fn variation_axes(self: &CTFont) -> Option<CFRetained<CFArray>>
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.
Sourcepub unsafe fn variation(self: &CTFont) -> Option<CFRetained<CFDictionary>>
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
impl CTFont
Sourcepub unsafe fn features(self: &CTFont) -> Option<CFRetained<CFArray>>
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.
Sourcepub unsafe fn feature_settings(self: &CTFont) -> Option<CFRetained<CFArray>>
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.
Sourcepub unsafe fn graphics_font(
self: &CTFont,
attributes: *mut *const CTFontDescriptor,
) -> CFRetained<CGFont>
Available on crate features CTFontDescriptor and objc2-core-graphics only.
pub unsafe fn graphics_font( self: &CTFont, attributes: *mut *const CTFontDescriptor, ) -> CFRetained<CGFont>
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.
Sourcepub 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.
pub unsafe fn with_graphics_font( graphics_font: &CGFont, size: CGFloat, matrix: *const CGAffineTransform, attributes: Option<&CTFontDescriptor>, ) -> CFRetained<CTFont>
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
impl CTFont
Sourcepub unsafe fn with_quickdraw_instance(
name: *const c_char,
identifier: i16,
style: u8,
size: CGFloat,
) -> CFRetained<CTFont>
👎Deprecated: Quickdraw font references are deprecated
pub unsafe fn with_quickdraw_instance( name: *const c_char, identifier: i16, style: u8, size: CGFloat, ) -> CFRetained<CTFont>
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
impl CTFont
Sourcepub unsafe fn available_tables(
self: &CTFont,
options: CTFontTableOptions,
) -> Option<CFRetained<CFArray>>
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);
Sourcepub unsafe fn has_table(self: &CTFont, tag: CTFontTableTag) -> bool
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.
Sourcepub unsafe fn table(
self: &CTFont,
table: CTFontTableTag,
options: CTFontTableOptions,
) -> Option<CFRetained<CFData>>
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.
Sourcepub unsafe fn draw_glyphs(
self: &CTFont,
glyphs: NonNull<CGGlyph>,
positions: NonNull<CGPoint>,
count: usize,
context: &CGContext,
)
Available on crate feature objc2-core-graphics only.
pub unsafe fn draw_glyphs( self: &CTFont, glyphs: NonNull<CGGlyph>, positions: NonNull<CGPoint>, count: usize, context: &CGContext, )
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.
Sourcepub unsafe fn ligature_caret_positions(
self: &CTFont,
glyph: CGGlyph,
positions: *mut CGFloat,
max_positions: CFIndex,
) -> CFIndex
Available on crate feature objc2-core-graphics only.
pub unsafe fn ligature_caret_positions( self: &CTFont, glyph: CGGlyph, positions: *mut CGFloat, max_positions: CFIndex, ) -> CFIndex
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
impl CTFont
pub unsafe fn typographic_bounds_for_adaptive_image_provider( self: &CTFont, provider: Option<&ProtocolObject<dyn CTAdaptiveImageProviding>>, ) -> CGRect
CTRunDelegate and objc2 only.pub unsafe fn draw_image_from_adaptive_image_provider_at_point( self: &CTFont, provider: &ProtocolObject<dyn CTAdaptiveImageProviding>, point: CGPoint, context: &CGContext, )
CTRunDelegate and objc2 and objc2-core-graphics only.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 ConcreteType for CTFont
impl ConcreteType for CTFont
Source§impl RefEncode for CTFont
impl RefEncode for CTFont
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CTFont
impl Type for CTFont
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