pub struct NSTypesetter { /* private fields */ }
NSTypesetter
only.Expand description
Implementations§
Source§impl NSTypesetter
impl NSTypesetter
pub fn usesFontLeading(&self) -> bool
Sourcepub fn setUsesFontLeading(&self, uses_font_leading: bool)
pub fn setUsesFontLeading(&self, uses_font_leading: bool)
Setter for usesFontLeading
.
pub fn typesetterBehavior(&self) -> NSTypesetterBehavior
NSLayoutManager
only.Sourcepub fn setTypesetterBehavior(&self, typesetter_behavior: NSTypesetterBehavior)
Available on crate feature NSLayoutManager
only.
pub fn setTypesetterBehavior(&self, typesetter_behavior: NSTypesetterBehavior)
NSLayoutManager
only.Setter for typesetterBehavior
.
pub fn hyphenationFactor(&self) -> c_float
Sourcepub fn setHyphenationFactor(&self, hyphenation_factor: c_float)
pub fn setHyphenationFactor(&self, hyphenation_factor: c_float)
Setter for hyphenationFactor
.
pub fn lineFragmentPadding(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setLineFragmentPadding(&self, line_fragment_padding: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setLineFragmentPadding(&self, line_fragment_padding: CGFloat)
objc2-core-foundation
only.Setter for lineFragmentPadding
.
pub fn substituteFontForFont(&self, original_font: &NSFont) -> Retained<NSFont>
NSFont
only.pub fn textTabForGlyphLocation_writingDirection_maxLocation( &self, glyph_location: CGFloat, direction: NSWritingDirection, max_location: CGFloat, ) -> Option<Retained<NSTextTab>>
NSParagraphStyle
and NSText
and objc2-core-foundation
only.pub fn bidiProcessingEnabled(&self) -> bool
Sourcepub fn setBidiProcessingEnabled(&self, bidi_processing_enabled: bool)
pub fn setBidiProcessingEnabled(&self, bidi_processing_enabled: bool)
Setter for bidiProcessingEnabled
.
Sourcepub unsafe fn attributedString(&self) -> Option<Retained<NSAttributedString>>
pub unsafe fn attributedString(&self) -> Option<Retained<NSAttributedString>>
§Safety
This is not retained internally, you must ensure the object is still alive.
Sourcepub unsafe fn setAttributedString(
&self,
attributed_string: Option<&NSAttributedString>,
)
pub unsafe fn setAttributedString( &self, attributed_string: Option<&NSAttributedString>, )
Setter for attributedString
.
§Safety
This is unretained, you must ensure the object is kept alive while in use.
pub fn setParagraphGlyphRange_separatorGlyphRange( &self, paragraph_range: NSRange, paragraph_separator_range: NSRange, )
pub fn paragraphGlyphRange(&self) -> NSRange
pub fn paragraphSeparatorGlyphRange(&self) -> NSRange
pub fn paragraphCharacterRange(&self) -> NSRange
pub fn paragraphSeparatorCharacterRange(&self) -> NSRange
Sourcepub unsafe fn layoutParagraphAtPoint(
&self,
line_fragment_origin: NSPointPointer,
) -> NSUInteger
pub unsafe fn layoutParagraphAtPoint( &self, line_fragment_origin: NSPointPointer, ) -> NSUInteger
§Safety
line_fragment_origin
must be a valid pointer.
pub fn beginParagraph(&self)
pub fn endParagraph(&self)
pub fn beginLineWithGlyphAtIndex(&self, glyph_index: NSUInteger)
pub fn endLineWithGlyphRange(&self, line_glyph_range: NSRange)
pub fn lineSpacingAfterGlyphAtIndex_withProposedLineFragmentRect( &self, glyph_index: NSUInteger, rect: NSRect, ) -> CGFloat
objc2-core-foundation
only.pub fn paragraphSpacingBeforeGlyphAtIndex_withProposedLineFragmentRect( &self, glyph_index: NSUInteger, rect: NSRect, ) -> CGFloat
objc2-core-foundation
only.pub fn paragraphSpacingAfterGlyphAtIndex_withProposedLineFragmentRect( &self, glyph_index: NSUInteger, rect: NSRect, ) -> CGFloat
objc2-core-foundation
only.Sourcepub unsafe fn getLineFragmentRect_usedRect_forParagraphSeparatorGlyphRange_atProposedOrigin(
&self,
line_fragment_rect: NSRectPointer,
line_fragment_used_rect: NSRectPointer,
paragraph_separator_glyph_range: NSRange,
line_origin: NSPoint,
)
pub unsafe fn getLineFragmentRect_usedRect_forParagraphSeparatorGlyphRange_atProposedOrigin( &self, line_fragment_rect: NSRectPointer, line_fragment_used_rect: NSRectPointer, paragraph_separator_glyph_range: NSRange, line_origin: NSPoint, )
§Safety
line_fragment_rect
must be a valid pointer.line_fragment_used_rect
must be a valid pointer.
pub fn attributesForExtraLineFragment( &self, ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>
Sourcepub unsafe fn layoutManager(&self) -> Option<Retained<NSLayoutManager>>
Available on crate feature NSLayoutManager
only.
pub unsafe fn layoutManager(&self) -> Option<Retained<NSLayoutManager>>
NSLayoutManager
only.§Safety
This is not retained internally, you must ensure the object is still alive.
Sourcepub unsafe fn textContainers(
&self,
) -> Option<Retained<NSArray<NSTextContainer>>>
Available on crate feature NSTextContainer
only.
pub unsafe fn textContainers( &self, ) -> Option<Retained<NSArray<NSTextContainer>>>
NSTextContainer
only.§Safety
This is not retained internally, you must ensure the object is still alive.
Sourcepub unsafe fn currentTextContainer(&self) -> Option<Retained<NSTextContainer>>
Available on crate feature NSTextContainer
only.
pub unsafe fn currentTextContainer(&self) -> Option<Retained<NSTextContainer>>
NSTextContainer
only.§Safety
This is not retained internally, you must ensure the object is still alive.
pub fn currentParagraphStyle(&self) -> Option<Retained<NSParagraphStyle>>
NSParagraphStyle
only.pub fn setHardInvalidation_forGlyphRange( &self, flag: bool, glyph_range: NSRange, )
Sourcepub unsafe fn layoutGlyphsInLayoutManager_startingAtGlyphIndex_maxNumberOfLineFragments_nextGlyphIndex(
&self,
layout_manager: &NSLayoutManager,
start_glyph_index: NSUInteger,
max_num_lines: NSUInteger,
next_glyph: NonNull<NSUInteger>,
)
Available on crate feature NSLayoutManager
only.
pub unsafe fn layoutGlyphsInLayoutManager_startingAtGlyphIndex_maxNumberOfLineFragments_nextGlyphIndex( &self, layout_manager: &NSLayoutManager, start_glyph_index: NSUInteger, max_num_lines: NSUInteger, next_glyph: NonNull<NSUInteger>, )
NSLayoutManager
only.§Safety
next_glyph
must be a valid pointer.
pub fn layoutCharactersInRange_forLayoutManager_maximumNumberOfLineFragments( &self, character_range: NSRange, layout_manager: &NSLayoutManager, max_num_lines: NSUInteger, ) -> NSRange
NSLayoutManager
only.Sourcepub unsafe fn printingAdjustmentInLayoutManager_forNominallySpacedGlyphRange_packedGlyphs_count(
layout_mgr: &NSLayoutManager,
nominally_spaced_glyphs_range: NSRange,
packed_glyphs: NonNull<c_uchar>,
packed_glyphs_count: NSUInteger,
) -> NSSize
Available on crate feature NSLayoutManager
only.
pub unsafe fn printingAdjustmentInLayoutManager_forNominallySpacedGlyphRange_packedGlyphs_count( layout_mgr: &NSLayoutManager, nominally_spaced_glyphs_range: NSRange, packed_glyphs: NonNull<c_uchar>, packed_glyphs_count: NSUInteger, ) -> NSSize
NSLayoutManager
only.§Safety
packed_glyphs
must be a valid pointer.
pub fn baselineOffsetInLayoutManager_glyphIndex( &self, layout_mgr: &NSLayoutManager, glyph_index: NSUInteger, ) -> CGFloat
NSLayoutManager
and objc2-core-foundation
only.NSLayoutManager
only.pub fn defaultTypesetterBehavior() -> NSTypesetterBehavior
NSLayoutManager
only.Source§impl NSTypesetter
Methods declared on superclass NSObject
.
impl NSTypesetter
Methods declared on superclass NSObject
.
Source§impl NSTypesetter
NSLayoutPhaseInterface.
impl NSTypesetter
NSLayoutPhaseInterface.
Sourcepub unsafe fn willSetLineFragmentRect_forGlyphRange_usedRect_baselineOffset(
&self,
line_rect: NSRectPointer,
glyph_range: NSRange,
used_rect: NSRectPointer,
baseline_offset: NonNull<CGFloat>,
)
Available on crate feature objc2-core-foundation
only.
pub unsafe fn willSetLineFragmentRect_forGlyphRange_usedRect_baselineOffset( &self, line_rect: NSRectPointer, glyph_range: NSRange, used_rect: NSRectPointer, baseline_offset: NonNull<CGFloat>, )
objc2-core-foundation
only.§Safety
line_rect
must be a valid pointer.used_rect
must be a valid pointer.baseline_offset
must be a valid pointer.
pub fn shouldBreakLineByWordBeforeCharacterAtIndex( &self, char_index: NSUInteger, ) -> bool
pub fn shouldBreakLineByHyphenatingBeforeCharacterAtIndex( &self, char_index: NSUInteger, ) -> bool
pub fn hyphenationFactorForGlyphAtIndex( &self, glyph_index: NSUInteger, ) -> c_float
pub fn hyphenCharacterForGlyphAtIndex(&self, glyph_index: NSUInteger) -> u32
pub fn boundingBoxForControlGlyphAtIndex_forTextContainer_proposedLineFragment_glyphPosition_characterIndex( &self, glyph_index: NSUInteger, text_container: &NSTextContainer, proposed_rect: NSRect, glyph_position: NSPoint, char_index: NSUInteger, ) -> NSRect
NSTextContainer
only.Source§impl NSTypesetter
NSGlyphStorageInterface.
impl NSTypesetter
NSGlyphStorageInterface.
Sourcepub unsafe fn characterRangeForGlyphRange_actualGlyphRange(
&self,
glyph_range: NSRange,
actual_glyph_range: NSRangePointer,
) -> NSRange
pub unsafe fn characterRangeForGlyphRange_actualGlyphRange( &self, glyph_range: NSRange, actual_glyph_range: NSRangePointer, ) -> NSRange
§Safety
actual_glyph_range
must be a valid pointer or null.
Sourcepub unsafe fn glyphRangeForCharacterRange_actualCharacterRange(
&self,
char_range: NSRange,
actual_char_range: NSRangePointer,
) -> NSRange
pub unsafe fn glyphRangeForCharacterRange_actualCharacterRange( &self, char_range: NSRange, actual_char_range: NSRangePointer, ) -> NSRange
§Safety
actual_char_range
must be a valid pointer or null.
Sourcepub unsafe fn getLineFragmentRect_usedRect_remainingRect_forStartingGlyphAtIndex_proposedRect_lineSpacing_paragraphSpacingBefore_paragraphSpacingAfter(
&self,
line_fragment_rect: NSRectPointer,
line_fragment_used_rect: NSRectPointer,
remaining_rect: NSRectPointer,
starting_glyph_index: NSUInteger,
proposed_rect: NSRect,
line_spacing: CGFloat,
paragraph_spacing_before: CGFloat,
paragraph_spacing_after: CGFloat,
)
Available on crate feature objc2-core-foundation
only.
pub unsafe fn getLineFragmentRect_usedRect_remainingRect_forStartingGlyphAtIndex_proposedRect_lineSpacing_paragraphSpacingBefore_paragraphSpacingAfter( &self, line_fragment_rect: NSRectPointer, line_fragment_used_rect: NSRectPointer, remaining_rect: NSRectPointer, starting_glyph_index: NSUInteger, proposed_rect: NSRect, line_spacing: CGFloat, paragraph_spacing_before: CGFloat, paragraph_spacing_after: CGFloat, )
objc2-core-foundation
only.§Safety
line_fragment_rect
must be a valid pointer.line_fragment_used_rect
must be a valid pointer.remaining_rect
must be a valid pointer.
pub fn setLineFragmentRect_forGlyphRange_usedRect_baselineOffset( &self, fragment_rect: NSRect, glyph_range: NSRange, used_rect: NSRect, baseline_offset: CGFloat, )
objc2-core-foundation
only.pub fn setNotShownAttribute_forGlyphRange( &self, flag: bool, glyph_range: NSRange, )
pub fn setDrawsOutsideLineFragment_forGlyphRange( &self, flag: bool, glyph_range: NSRange, )
Sourcepub unsafe fn setLocation_withAdvancements_forStartOfGlyphRange(
&self,
location: NSPoint,
advancements: *const CGFloat,
glyph_range: NSRange,
)
Available on crate feature objc2-core-foundation
only.
pub unsafe fn setLocation_withAdvancements_forStartOfGlyphRange( &self, location: NSPoint, advancements: *const CGFloat, glyph_range: NSRange, )
objc2-core-foundation
only.§Safety
advancements
must be a valid pointer.
pub fn setAttachmentSize_forGlyphRange( &self, attachment_size: NSSize, glyph_range: NSRange, )
Source§impl NSTypesetter
NSTypesetter_Deprecated.
impl NSTypesetter
NSTypesetter_Deprecated.
pub fn actionForControlCharacterAtIndex( &self, char_index: NSUInteger, ) -> NSTypesetterControlCharacterAction
Sourcepub unsafe fn getGlyphsInRange_glyphs_characterIndexes_glyphInscriptions_elasticBits_bidiLevels(
&self,
glyphs_range: NSRange,
glyph_buffer: *mut NSGlyph,
char_index_buffer: *mut NSUInteger,
inscribe_buffer: *mut NSGlyphInscription,
elastic_buffer: *mut Bool,
bidi_level_buffer: *mut c_uchar,
) -> NSUInteger
👎DeprecatedAvailable on crate features NSFont
and NSLayoutManager
only.
pub unsafe fn getGlyphsInRange_glyphs_characterIndexes_glyphInscriptions_elasticBits_bidiLevels( &self, glyphs_range: NSRange, glyph_buffer: *mut NSGlyph, char_index_buffer: *mut NSUInteger, inscribe_buffer: *mut NSGlyphInscription, elastic_buffer: *mut Bool, bidi_level_buffer: *mut c_uchar, ) -> NSUInteger
NSFont
and NSLayoutManager
only.§Safety
glyph_buffer
must be a valid pointer.char_index_buffer
must be a valid pointer.inscribe_buffer
must be a valid pointer.elastic_buffer
must be a valid pointer.bidi_level_buffer
must be a valid pointer.
Sourcepub unsafe fn substituteGlyphsInRange_withGlyphs(
&self,
glyph_range: NSRange,
glyphs: *mut NSGlyph,
)
👎DeprecatedAvailable on crate feature NSFont
only.
pub unsafe fn substituteGlyphsInRange_withGlyphs( &self, glyph_range: NSRange, glyphs: *mut NSGlyph, )
NSFont
only.§Safety
glyphs
must be a valid pointer.
pub fn insertGlyph_atGlyphIndex_characterIndex( &self, glyph: NSGlyph, glyph_index: NSUInteger, character_index: NSUInteger, )
NSFont
only.pub fn deleteGlyphsInRange(&self, glyph_range: NSRange)
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
Available on crate feature NSAccessibilityConstants
only.
pub fn class(&self) -> &'static AnyClass
NSAccessibilityConstants
only.Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.Available on crate feature NSAccessibilityConstants
only.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.NSAccessibilityConstants
only.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Available on crate feature NSAccessibilityConstants
only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
NSAccessibilityConstants
only.Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for NSTypesetter
impl AsRef<AnyObject> for NSTypesetter
Source§impl AsRef<NSObject> for NSTypesetter
impl AsRef<NSObject> for NSTypesetter
Source§impl AsRef<NSTypesetter> for NSATSTypesetter
Available on crate feature NSATSTypesetter
only.
impl AsRef<NSTypesetter> for NSATSTypesetter
NSATSTypesetter
only.Source§fn as_ref(&self) -> &NSTypesetter
fn as_ref(&self) -> &NSTypesetter
Source§impl AsRef<NSTypesetter> for NSTypesetter
impl AsRef<NSTypesetter> for NSTypesetter
Source§impl Borrow<AnyObject> for NSTypesetter
impl Borrow<AnyObject> for NSTypesetter
Source§impl Borrow<NSObject> for NSTypesetter
impl Borrow<NSObject> for NSTypesetter
Source§impl Borrow<NSTypesetter> for NSATSTypesetter
Available on crate feature NSATSTypesetter
only.
impl Borrow<NSTypesetter> for NSATSTypesetter
NSATSTypesetter
only.Source§fn borrow(&self) -> &NSTypesetter
fn borrow(&self) -> &NSTypesetter
Source§impl ClassType for NSTypesetter
impl ClassType for NSTypesetter
Source§const NAME: &'static str = "NSTypesetter"
const NAME: &'static str = "NSTypesetter"
Source§type ThreadKind = <<NSTypesetter as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSTypesetter as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for NSTypesetter
impl Debug for NSTypesetter
Source§impl DefaultRetained for NSTypesetter
impl DefaultRetained for NSTypesetter
Source§impl Deref for NSTypesetter
impl Deref for NSTypesetter
Source§impl Hash for NSTypesetter
impl Hash for NSTypesetter
Source§impl Message for NSTypesetter
impl Message for NSTypesetter
Source§impl NSObjectProtocol for NSTypesetter
impl NSObjectProtocol for NSTypesetter
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref