Struct Font
pub struct Font<'ttf_module, 'rwops> { /* private fields */ }
dep_sdl2
only.Expand description
A loaded TTF font.
Implementations§
§impl<'ttf, 'r> Font<'ttf, 'r>
impl<'ttf, 'r> Font<'ttf, 'r>
pub fn render<'a, 'b>(&'a self, text: &'b str) -> PartialRendering<'a, 'b>
pub fn render<'a, 'b>(&'a self, text: &'b str) -> PartialRendering<'a, 'b>
Starts specifying a rendering of the given UTF-8-encoded text.
pub fn render_latin1<'a, 'b>(
&'a self,
text: &'b [u8],
) -> PartialRendering<'a, 'b>
pub fn render_latin1<'a, 'b>( &'a self, text: &'b [u8], ) -> PartialRendering<'a, 'b>
Starts specifying a rendering of the given Latin-1-encoded text.
pub fn render_char(&self, ch: char) -> PartialRendering<'_, 'static>
pub fn render_char(&self, ch: char) -> PartialRendering<'_, 'static>
Starts specifying a rendering of the given UTF-8-encoded character.
pub fn size_of(&self, text: &str) -> Result<(u32, u32), FontError> ⓘ
pub fn size_of(&self, text: &str) -> Result<(u32, u32), FontError> ⓘ
Returns the width and height of the given text when rendered using this font.
pub fn size_of_latin1(&self, text: &[u8]) -> Result<(u32, u32), FontError> ⓘ
pub fn size_of_latin1(&self, text: &[u8]) -> Result<(u32, u32), FontError> ⓘ
Returns the width and height of the given text when rendered using this font.
pub fn size_of_char(&self, ch: char) -> Result<(u32, u32), FontError> ⓘ
pub fn size_of_char(&self, ch: char) -> Result<(u32, u32), FontError> ⓘ
Returns the width and height of the given text when rendered using this font.
pub fn get_outline_width(&self) -> u16
pub fn get_outline_width(&self) -> u16
Returns the width of the font’s outline.
pub fn set_outline_width(&mut self, width: u16)
pub fn set_outline_width(&mut self, width: u16)
Sets the width of the font’s outline.
pub fn get_hinting(&self) -> Hinting
pub fn get_hinting(&self) -> Hinting
Returns the font’s freetype hints.
pub fn set_hinting(&mut self, hinting: Hinting)
pub fn set_hinting(&mut self, hinting: Hinting)
Sets the font’s freetype hints.
pub fn get_kerning(&self) -> bool
pub fn get_kerning(&self) -> bool
Returns whether the font is kerning.
pub fn set_kerning(&mut self, kerning: bool)
pub fn set_kerning(&mut self, kerning: bool)
Sets whether the font should use kerning.
pub fn descent(&self) -> i32
pub fn descent(&self) -> i32
Returns the font’s lowest descent (height below base). This is a negative number.
pub fn recommended_line_spacing(&self) -> i32
pub fn recommended_line_spacing(&self) -> i32
Returns the recommended line spacing for text rendered with this font.
pub fn face_count(&self) -> u16
pub fn face_count(&self) -> u16
Returns the number of faces in this font.
pub fn face_is_fixed_width(&self) -> bool
pub fn face_is_fixed_width(&self) -> bool
Returns whether the font is monospaced.
pub fn face_family_name_borrowed(&self) -> Option<&'ttf CStr> ⓘ
pub fn face_family_name_borrowed(&self) -> Option<&'ttf CStr> ⓘ
Returns the family name of the current font face without doing any heap allocations.
pub fn face_family_name(&self) -> Option<String> ⓘ
pub fn face_family_name(&self) -> Option<String> ⓘ
Returns the family name of the current font face.
pub fn face_style_name_borrowed(&self) -> Option<&'ttf CStr> ⓘ
pub fn face_style_name_borrowed(&self) -> Option<&'ttf CStr> ⓘ
Returns the name of the current font face without doing any heap allocations.
pub fn face_style_name(&self) -> Option<String> ⓘ
pub fn face_style_name(&self) -> Option<String> ⓘ
Returns the name of the current font face.
pub fn find_glyph(&self, ch: char) -> Option<u16> ⓘ
pub fn find_glyph(&self, ch: char) -> Option<u16> ⓘ
Returns the index of the given character in this font face.
pub fn find_glyph_metrics(&self, ch: char) -> Option<GlyphMetrics> ⓘ
pub fn find_glyph_metrics(&self, ch: char) -> Option<GlyphMetrics> ⓘ
Returns the glyph metrics of the given character in this font face.
Trait Implementations§
Auto Trait Implementations§
impl<'ttf_module, 'rwops> Freeze for Font<'ttf_module, 'rwops>
impl<'ttf_module, 'rwops> RefUnwindSafe for Font<'ttf_module, 'rwops>
impl<'ttf_module, 'rwops> !Send for Font<'ttf_module, 'rwops>
impl<'ttf_module, 'rwops> !Sync for Font<'ttf_module, 'rwops>
impl<'ttf_module, 'rwops> Unpin for Font<'ttf_module, 'rwops>
impl<'ttf_module, 'rwops> UnwindSafe for Font<'ttf_module, 'rwops>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more