CTRun

Struct CTRun 

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

Implementations§

Source§

impl CTRun

Source

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

Gets the glyph count for the run.

Parameter run: The run whose glyph count you wish to access.

Returns: The number of glyphs that the run contains. It is totally possible that this function could return a value of zero, indicating that there are no glyphs in this run.

Source

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

Returns the attribute dictionary that was used to create the glyph run.

This dictionary returned is either the same exact one that was set as an attribute dictionary on the original attributed string or a dictionary that has been manufactured by the layout engine. Attribute dictionaries can be manufactured in the case of font substitution or if they are missing critical attributes.

Parameter run: The run whose attributes you wish to access.

Returns: The attribute dictionary.

Source

pub unsafe fn status(self: &CTRun) -> CTRunStatus

Returns the run’s status.

In addition to attributes, runs also have status that can be used to expedite certain operations. Knowing the direction and ordering of a run’s glyphs can aid in string index analysis, whereas knowing whether the positions reference the identity text matrix can avoid expensive comparisons. Note that this status is provided as a convenience, since this information is not strictly necessary but can certainly be helpful.

Parameter run: The run whose status you wish to access.

Returns: The run’s status.

Source

pub unsafe fn glyphs_ptr(self: &CTRun) -> *const CGGlyph

Available on crate feature objc2-core-graphics only.

Returns a direct pointer for the glyph array stored in the run.

The glyph array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. Should this function return NULL, the caller will need to allocate their own buffer and call CTRunGetGlyphs to fetch the glyphs.

Parameter run: The run whose glyphs you wish to access.

Returns: A valid pointer to an array of CGGlyph structures or NULL.

Source

pub unsafe fn glyphs(self: &CTRun, range: CFRange, buffer: NonNull<CGGlyph>)

Available on crate feature objc2-core-graphics only.

Copies a range of glyphs into user-provided buffer.

Parameter run: The run whose glyphs you wish to copy.

Parameter range: The range of glyphs to be copied, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

Parameter buffer: The buffer where the glyphs will be copied to. The buffer must be allocated to at least the value specified by the range’s length.

Source

pub unsafe fn positions_ptr(self: &CTRun) -> *const CGPoint

Returns a direct pointer for the glyph position array stored in the run.

The glyph positions in a run are relative to the origin of the line containing the run. The position array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. Should this function return NULL, the caller will need to allocate their own buffer and call CTRunGetPositions to fetch the positions.

Parameter run: The run whose positions you wish to access.

Returns: A valid pointer to an array of CGPoint structures or NULL.

Source

pub unsafe fn positions(self: &CTRun, range: CFRange, buffer: NonNull<CGPoint>)

Copies a range of glyph positions into a user-provided buffer.

The glyph positions in a run are relative to the origin of the line containing the run.

Parameter run: The run whose positions you wish to copy.

Parameter range: The range of glyph positions to be copied, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

Parameter buffer: The buffer where the glyph positions will be copied to. The buffer must be allocated to at least the value specified by the range’s length.

Source

pub unsafe fn advances_ptr(self: &CTRun) -> *const CGSize

Returns a direct pointer for the glyph advance array stored in the run.

The advance array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. Should this function return NULL, the caller will need to allocate their own buffer and call CTRunGetAdvances to fetch the advances. Note that advances alone are not sufficient for correctly positioning glyphs in a line, as a run may have a non-identity matrix or the initial glyph in a line may have a non-zero origin; callers should consider using positions instead.

Parameter run: The run whose advances you wish to access.

Returns: A valid pointer to an array of CGSize structures or NULL.

Source

pub unsafe fn advances(self: &CTRun, range: CFRange, buffer: NonNull<CGSize>)

Copies a range of glyph advances into a user-provided buffer.

Parameter run: The run whose advances you wish to copy.

Parameter range: The range of glyph advances to be copied, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

Parameter buffer: The buffer where the glyph advances will be copied to. The buffer must be allocated to at least the value specified by the range’s length.

Source

pub unsafe fn string_indices_ptr(self: &CTRun) -> *const CFIndex

Returns a direct pointer for the string indices stored in the run.

The indices are the character indices that originally spawned the glyphs that make up the run. They can be used to map the glyphs in the run back to the characters in the backing store. The string indices array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. Should this function return NULL, the caller will need to allocate their own buffer and call CTRunGetStringIndices to fetch the indices.

Parameter run: The run whose string indices you wish to access.

Returns: A valid pointer to an array of CFIndex structures or NULL.

Source

pub unsafe fn string_indices( self: &CTRun, range: CFRange, buffer: NonNull<CFIndex>, )

Copies a range of string indices into a user-provided buffer.

The indices are the character indices that originally spawned the glyphs that make up the run. They can be used to map the glyphs in the run back to the characters in the backing store.

Parameter run: The run whose string indices you wish to copy.

Parameter range: The range of string indices to be copied, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

Parameter buffer: The buffer where the string indices will be copied to. The buffer must be allocated to at least the value specified by the range’s length.

Source

pub unsafe fn string_range(self: &CTRun) -> CFRange

Gets the range of characters that originally spawned the glyphs in the run.

Parameter run: The run whose string range you wish to access.

Returns: Returns the range of characters that originally spawned the glyphs. If run is invalid, this will return an empty range.

Source

pub unsafe fn typographic_bounds( self: &CTRun, range: CFRange, ascent: *mut CGFloat, descent: *mut CGFloat, leading: *mut CGFloat, ) -> c_double

Gets the typographic bounds of the run.

Parameter run: The run that you want to calculate the typographic bounds for.

Parameter range: The range of glyphs to be measured, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

Parameter ascent: Upon return, this parameter will contain the ascent of the run. This may be set to NULL if not needed.

Parameter descent: Upon return, this parameter will contain the descent of the run. This may be set to NULL if not needed.

Parameter leading: Upon return, this parameter will contain the leading of the run. This may be set to NULL if not needed.

Returns: The typographic width of the run. If run or range is invalid, then this function will always return zero.

Source

pub unsafe fn image_bounds( self: &CTRun, context: Option<&CGContext>, range: CFRange, ) -> CGRect

Available on crate feature objc2-core-graphics only.

Calculates the image bounds for a glyph range.

The image bounds for a run is the union of all non-empty glyph bounding rects, each positioned as it would be if drawn using CTRunDraw using the current context (for clients linked against macOS High Sierra or iOS 11 and later) or the text position of the supplied context (for all others). Note that the result is ideal and does not account for raster coverage due to rendering. This function is purely a convenience for using glyphs as an image and should not be used for typographic purposes.

Parameter run: The run that you want to calculate the image bounds for.

Parameter context: The context which the image bounds will be calculated for or NULL, in which case the bounds are relative to CGPointZero.

Parameter range: The range of glyphs to be measured, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

Returns: A rect that tightly encloses the paths of the run’s glyphs. The rect origin will match the drawn position of the requested range; that is, it will be translated by the supplied context’s text position and the positions of the individual glyphs. If the run or range is invalid, CGRectNull will be returned.

See also: CTRunGetTypographicBounds

Source

pub unsafe fn text_matrix(self: &CTRun) -> CGAffineTransform

Returns the text matrix needed to draw this run.

To properly draw the glyphs in a run, the fields ‘tx’ and ‘ty’ of the CGAffineTransform returned by this function should be set to the current text position.

Parameter run: The run object from which to get the text matrix.

Returns: A CGAffineTransform.

Source

pub unsafe fn base_advances_and_origins( self: &CTRun, range: CFRange, advances_buffer: *mut CGSize, origins_buffer: *mut CGPoint, )

Copies a range of base advances and/or origins into user-provided buffers.

A run’s base advances and origins determine the positions of its glyphs but require additional processing before being used for drawing. Similar to the advances returned by CTRunGetAdvances, base advances are the displacement from the origin of a glyph to the origin of the next glyph, except base advances do not include any positioning the font layout tables may have done relative to another glyph (such as a mark relative to its base). The actual position of the current glyph is determined by the displacement of its origin from the starting position, and the position of the next glyph by the displacement of the current glyph’s base advance from the starting position.

Parameter runRef: The run whose base advances and/or origins you wish to copy.

Parameter range: The range of values to be copied. If the length of the range is set to 0, then the copy operation will continue from the range’s start index to the end of the run.

Parameter advancesBuffer: The buffer where the base advances will be copied to, or NULL. If not NULL, the buffer must allow for at least as many elements as specified by the range’s length.

Parameter originsBuffer: The buffer where the origins will be copied to, or NULL. If not NULL, the buffer must allow for at least as many elements as specified by the range’s length.

Source

pub unsafe fn draw(self: &CTRun, context: &CGContext, range: CFRange)

Available on crate feature objc2-core-graphics only.

Draws a complete run or part of one.

This is a convenience call, since the run could also be drawn by accessing its glyphs, positions, and text matrix. Unlike when drawing the entire line containing the run with CTLineDraw, the run’s underline (if any) will not be drawn, since the underline’s appearance may depend on other runs in the line. This call may leave the graphics context in any state and does not flush the context after drawing. This call also expects a text matrix with y values increasing from bottom to top; a flipped text matrix may result in misplaced diacritics.

Parameter run: The run that you want to draw.

Parameter context: The context to draw the run to.

Parameter range: The range of glyphs to be drawn, with the entire range having a location of 0 and a length of CTRunGetGlyphCount. If the length of the range is set to 0, then the operation will continue from the range’s start index to the end of the run.

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 CTRun

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<CFType> for CTRun

Source§

fn as_ref(&self) -> &CFType

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

impl AsRef<CTRun> for CTRun

Source§

fn as_ref(&self) -> &Self

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

impl Borrow<AnyObject> for CTRun

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for CTRun

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for CTRun

Source§

fn type_id() -> CFTypeID

Returns the CFType of the run object

Source§

impl Debug for CTRun

Source§

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

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

impl Deref for CTRun

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Hash for CTRun

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 CTRun

Source§

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

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

impl PartialEq for CTRun

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 CTRun

Source§

const ENCODING_REF: Encoding

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

impl Type for CTRun

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 CTRun

Auto Trait Implementations§

§

impl !Freeze for CTRun

§

impl !RefUnwindSafe for CTRun

§

impl !Send for CTRun

§

impl !Sync for CTRun

§

impl !Unpin for CTRun

§

impl !UnwindSafe for CTRun

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,