pub struct CTFont { /* private fields */ }Expand description
This is toll-free bridged with NSFont.
Implementations§
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn with_name(
name: &CFString,
size: f64,
matrix: *const CGAffineTransform,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn with_name( name: &CFString, size: f64, 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.
§Safety
matrix must be a valid pointer or null.
Sourcepub unsafe fn with_font_descriptor(
descriptor: &CTFontDescriptor,
size: f64,
matrix: *const CGAffineTransform,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn with_font_descriptor( descriptor: &CTFontDescriptor, size: f64, matrix: *const CGAffineTransform, ) -> CFRetained<CTFont> ⓘ
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.
§Safety
matrix must be a valid pointer or null.
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn with_name_and_options(
name: &CFString,
size: f64,
matrix: *const CGAffineTransform,
options: CTFontOptions,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn with_name_and_options( name: &CFString, size: f64, 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.
§Safety
matrix must be a valid pointer or null.
Sourcepub unsafe fn with_font_descriptor_and_options(
descriptor: &CTFontDescriptor,
size: f64,
matrix: *const CGAffineTransform,
options: CTFontOptions,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn with_font_descriptor_and_options( descriptor: &CTFontDescriptor, size: f64, matrix: *const CGAffineTransform, options: CTFontOptions, ) -> CFRetained<CTFont> ⓘ
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.
§Safety
matrix must be a valid pointer or null.
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn new_ui_font_for_language(
ui_type: CTFontUIFontType,
size: f64,
language: Option<&CFString>,
) -> Option<CFRetained<CTFont>>
pub unsafe fn new_ui_font_for_language( ui_type: CTFontUIFontType, size: f64, 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,
size: f64,
matrix: *const CGAffineTransform,
attributes: Option<&CTFontDescriptor>,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn copy_with_attributes( &self, size: f64, matrix: *const CGAffineTransform, attributes: Option<&CTFontDescriptor>, ) -> CFRetained<CTFont> ⓘ
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.
§Safety
matrix must be a valid pointer or null.
Sourcepub unsafe fn copy_with_symbolic_traits(
&self,
size: f64,
matrix: *const CGAffineTransform,
sym_trait_value: CTFontSymbolicTraits,
sym_trait_mask: CTFontSymbolicTraits,
) -> Option<CFRetained<CTFont>>
pub unsafe fn copy_with_symbolic_traits( &self, size: f64, matrix: *const CGAffineTransform, sym_trait_value: CTFontSymbolicTraits, sym_trait_mask: CTFontSymbolicTraits, ) -> Option<CFRetained<CTFont>>
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.
§Safety
matrix must be a valid pointer or null.
Sourcepub unsafe fn copy_with_family(
&self,
size: f64,
matrix: *const CGAffineTransform,
family: &CFString,
) -> Option<CFRetained<CTFont>>
pub unsafe fn copy_with_family( &self, size: f64, 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.
§Safety
matrix must be a valid pointer or null.
Sourcepub unsafe fn for_string(
&self,
string: &CFString,
range: CFRange,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn for_string( &self, 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,
string: &CFString,
range: CFRange,
language: Option<&CFString>,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn for_string_with_language( &self, 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) -> CFRetained<CTFontDescriptor> ⓘ
pub unsafe fn font_descriptor(&self) -> CFRetained<CTFontDescriptor> ⓘ
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,
attribute: &CFString,
) -> Option<CFRetained<CFType>>
pub unsafe fn attribute( &self, 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) -> f64
pub unsafe fn size(&self) -> f64
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) -> CGAffineTransform
pub unsafe fn matrix(&self) -> 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) -> CTFontSymbolicTraits
pub unsafe fn symbolic_traits(&self) -> CTFontSymbolicTraits
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) -> CFRetained<CFDictionary> ⓘ
pub unsafe fn traits(&self) -> 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,
language_pref_list: Option<&CFArray>,
) -> Option<CFRetained<CFArray>>
pub unsafe fn default_cascade_list_for_languages( &self, 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.
§Safety
language_pref_list generic must be of the correct type.
Sourcepub unsafe fn post_script_name(&self) -> CFRetained<CFString> ⓘ
pub unsafe fn post_script_name(&self) -> 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) -> CFRetained<CFString> ⓘ
pub unsafe fn family_name(&self) -> 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) -> CFRetained<CFString> ⓘ
pub unsafe fn full_name(&self) -> 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) -> CFRetained<CFString> ⓘ
pub unsafe fn display_name(&self) -> 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, name_key: &CFString) -> Option<CFRetained<CFString>>
pub unsafe fn name(&self, 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,
name_key: &CFString,
actual_language: *mut *const CFString,
) -> Option<CFRetained<CFString>>
pub unsafe fn localized_name( &self, name_key: &CFString, actual_language: *mut *const CFString, ) -> Option<CFRetained<CFString>>
Returns a reference to a localized font name.
Localized names are necessary for presentation to a human but are rarely appropriate for programmatic use. CoreText provides localizations for common names but will not attempt any sort of automated translation.
Parameter font: The font reference.
Parameter nameKey: A name specifier listed in “Font Constants”, for example kCTFontStyleNameKey. Name keys present in dictionaries (such as those for axes or features) are handled not by this function but by the functions returning those dictionaries.
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.
See also: CTFontCopyVariationAxes
See also: CTFontCopyFeatures
§Safety
actual_language must be a valid pointer or null.
Sourcepub unsafe fn character_set(&self) -> CFRetained<CFCharacterSet> ⓘ
pub unsafe fn character_set(&self) -> 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) -> u32
pub unsafe fn string_encoding(&self) -> u32
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) -> CFRetained<CFArray> ⓘ
pub unsafe fn supported_languages(&self) -> 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,
characters: NonNull<u16>,
glyphs: NonNull<u16>,
count: isize,
) -> bool
pub unsafe fn glyphs_for_characters( &self, characters: NonNull<u16>, glyphs: NonNull<u16>, count: isize, ) -> bool
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
§Safety
charactersmust be a valid pointer.glyphsmust be a valid pointer.
Sourcepub unsafe fn ascent(&self) -> f64
pub unsafe fn ascent(&self) -> f64
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) -> f64
pub unsafe fn descent(&self) -> f64
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) -> f64
pub unsafe fn leading(&self) -> f64
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) -> u32
pub unsafe fn units_per_em(&self) -> u32
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) -> isize
pub unsafe fn glyph_count(&self) -> isize
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) -> CGRect
pub unsafe fn bounding_box(&self) -> 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) -> f64
pub unsafe fn underline_position(&self) -> f64
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) -> f64
pub unsafe fn underline_thickness(&self) -> f64
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) -> f64
pub unsafe fn slant_angle(&self) -> f64
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) -> f64
pub unsafe fn cap_height(&self) -> f64
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) -> f64
pub unsafe fn x_height(&self) -> f64
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, glyph_name: &CFString) -> u16
pub unsafe fn glyph_with_name(&self, glyph_name: &CFString) -> u16
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, glyph: u16) -> Option<CFRetained<CFString>>
pub unsafe fn name_for_glyph(&self, glyph: u16) -> Option<CFRetained<CFString>>
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,
orientation: CTFontOrientation,
glyphs: NonNull<u16>,
bounding_rects: *mut CGRect,
count: isize,
) -> CGRect
pub unsafe fn bounding_rects_for_glyphs( &self, orientation: CTFontOrientation, glyphs: NonNull<u16>, bounding_rects: *mut CGRect, count: isize, ) -> CGRect
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.
§Safety
glyphsmust be a valid pointer.bounding_rectsmust be a valid pointer or null.
Sourcepub unsafe fn optical_bounds_for_glyphs(
&self,
glyphs: NonNull<u16>,
bounding_rects: *mut CGRect,
count: isize,
options: usize,
) -> CGRect
pub unsafe fn optical_bounds_for_glyphs( &self, glyphs: NonNull<u16>, bounding_rects: *mut CGRect, count: isize, options: usize, ) -> CGRect
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.
§Safety
glyphsmust be a valid pointer.bounding_rectsmust be a valid pointer or null.
Sourcepub unsafe fn advances_for_glyphs(
&self,
orientation: CTFontOrientation,
glyphs: NonNull<u16>,
advances: *mut CGSize,
count: isize,
) -> f64
pub unsafe fn advances_for_glyphs( &self, orientation: CTFontOrientation, glyphs: NonNull<u16>, advances: *mut CGSize, count: isize, ) -> f64
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.
§Safety
glyphsmust be a valid pointer.advancesmust be a valid pointer or null.
Sourcepub unsafe fn vertical_translations_for_glyphs(
&self,
glyphs: NonNull<u16>,
translations: NonNull<CGSize>,
count: isize,
)
pub unsafe fn vertical_translations_for_glyphs( &self, glyphs: NonNull<u16>, translations: NonNull<CGSize>, count: isize, )
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.
§Safety
glyphsmust be a valid pointer.translationsmust be a valid pointer.
Sourcepub unsafe fn path_for_glyph(
&self,
glyph: u16,
matrix: *const CGAffineTransform,
) -> Option<CFRetained<CGPath>>
pub unsafe fn path_for_glyph( &self, glyph: u16, matrix: *const CGAffineTransform, ) -> Option<CFRetained<CGPath>>
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.
§Safety
matrix must be a valid pointer or null.
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn variation_axes(&self) -> Option<CFRetained<CFArray>>
pub unsafe fn variation_axes(&self) -> 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; for programmatic uses kCTFontVariationAxesAttribute may be used instead.
Parameter font: The font reference.
Returns: An array of variation axis dictionaries or null if the font does not support variations.
See also: kCTFontVariationAxesAttribute
Sourcepub unsafe fn variation(&self) -> Option<CFRetained<CFDictionary>>
pub unsafe fn variation(&self) -> 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) -> Option<CFRetained<CFArray>>
pub unsafe fn features(&self) -> Option<CFRetained<CFArray>>
Returns an array of font features
The returned value describes the features available for the provided font. Each array value is a feature dictionary describing a feature type, with related selector dictionaries in an array under the kCTFontFeatureTypeSelectorsKey. While CoreText supports AAT and OpenType font features, they are preferentially represented as AAT features owing to their more formal structure: individual feature types can be either exclusive or non-exclusive, which indicates whether one or more of its selectors can be simultaneously enabled. Where possible features are elaborated with their OpenType feature tag and value, which can occur within both type or selector dictionaries depending on the feature’s mapping to an AAT type and selector pair. Names are localized according to the preferred langauges of the caller and therefore are not appropriate for programmatically identifying 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) -> Option<CFRetained<CFArray>>
pub unsafe fn feature_settings(&self) -> 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,
attributes: *mut *const CTFontDescriptor,
) -> CFRetained<CGFont> ⓘ
pub unsafe fn graphics_font( &self, attributes: *mut *const CTFontDescriptor, ) -> CFRetained<CGFont> ⓘ
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.
§Safety
attributes must be a valid pointer or null.
Sourcepub unsafe fn with_graphics_font(
graphics_font: &CGFont,
size: f64,
matrix: *const CGAffineTransform,
attributes: Option<&CTFontDescriptor>,
) -> CFRetained<CTFont> ⓘ
pub unsafe fn with_graphics_font( graphics_font: &CGFont, size: f64, matrix: *const CGAffineTransform, attributes: Option<&CTFontDescriptor>, ) -> CFRetained<CTFont> ⓘ
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.
§Safety
matrix must be a valid pointer or null.
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn with_quickdraw_instance(
name: *const i8,
identifier: i16,
style: u8,
size: f64,
) -> CFRetained<CTFont> ⓘ
👎Deprecated: Quickdraw font references are deprecated
pub unsafe fn with_quickdraw_instance( name: *const i8, identifier: i16, style: u8, size: f64, ) -> 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.
§Safety
name must be a valid pointer or null.
Source§impl CTFont
impl CTFont
Sourcepub unsafe fn available_tables(
&self,
options: CTFontTableOptions,
) -> Option<CFRetained<CFArray>>
pub unsafe fn available_tables( &self, 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, tag: u32) -> bool
pub unsafe fn has_table(&self, tag: u32) -> 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,
table: u32,
options: CTFontTableOptions,
) -> Option<CFRetained<CFData>>
pub unsafe fn table( &self, table: u32, 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,
glyphs: NonNull<u16>,
positions: NonNull<CGPoint>,
count: usize,
context: &CGContext,
)
pub unsafe fn draw_glyphs( &self, glyphs: NonNull<u16>, positions: NonNull<CGPoint>, count: usize, context: &CGContext, )
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.
§Safety
glyphsmust be a valid pointer.positionsmust be a valid pointer.
Sourcepub unsafe fn ligature_caret_positions(
&self,
glyph: u16,
positions: *mut f64,
max_positions: isize,
) -> isize
pub unsafe fn ligature_caret_positions( &self, glyph: u16, positions: *mut f64, max_positions: isize, ) -> isize
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.
§Safety
positions must be a valid pointer or null.
Source§impl CTFont
impl CTFont
pub unsafe fn typographic_bounds_for_adaptive_image_provider( &self, provider: Option<&ProtocolObject<dyn CTAdaptiveImageProviding>>, ) -> CGRect
pub unsafe fn draw_image_from_adaptive_image_provider_at_point( &self, provider: &ProtocolObject<dyn CTAdaptiveImageProviding>, point: CGPoint, context: &CGContext, )
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