Struct sdl2::ttf::Font

source ·
pub struct Font<'ttf_module, 'rwops> { /* private fields */ }
Expand description

A loaded TTF font.

Implementations§

source§

impl<'ttf, 'r> Font<'ttf, 'r>

source

pub fn render<'a, 'b>(&'a self, text: &'b str) -> PartialRendering<'a, 'b>

Starts specifying a rendering of the given UTF-8-encoded text.

source

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.

source

pub fn render_char(&self, ch: char) -> PartialRendering<'_, 'static>

Starts specifying a rendering of the given UTF-8-encoded character.

source

pub fn size_of(&self, text: &str) -> FontResult<(u32, u32)>

Returns the width and height of the given text when rendered using this font.

source

pub fn size_of_latin1(&self, text: &[u8]) -> FontResult<(u32, u32)>

Returns the width and height of the given text when rendered using this font.

source

pub fn size_of_char(&self, ch: char) -> FontResult<(u32, u32)>

Returns the width and height of the given text when rendered using this font.

source

pub fn get_style(&self) -> FontStyle

Returns the font’s style flags.

source

pub fn set_style(&mut self, styles: FontStyle)

Sets the font’s style flags.

source

pub fn get_outline_width(&self) -> u16

Returns the width of the font’s outline.

source

pub fn set_outline_width(&mut self, width: u16)

Sets the width of the font’s outline.

source

pub fn get_hinting(&self) -> Hinting

Returns the font’s freetype hints.

source

pub fn set_hinting(&mut self, hinting: Hinting)

Sets the font’s freetype hints.

source

pub fn get_kerning(&self) -> bool

Returns whether the font is kerning.

source

pub fn set_kerning(&mut self, kerning: bool)

Sets whether the font should use kerning.

source

pub fn height(&self) -> i32

Get font maximum total height.

source

pub fn ascent(&self) -> i32

Returns the font’s highest ascent (height above base).

source

pub fn descent(&self) -> i32

Returns the font’s lowest descent (height below base). This is a negative number.

source

pub fn recommended_line_spacing(&self) -> i32

Returns the recommended line spacing for text rendered with this font.

source

pub fn face_count(&self) -> u16

Returns the number of faces in this font.

source

pub fn face_is_fixed_width(&self) -> bool

Returns whether the font is monospaced.

source

pub fn face_family_name_borrowed(&self) -> Option<&'ttf CStr>

Returns the family name of the current font face without doing any heap allocations.

source

pub fn face_family_name(&self) -> Option<String>

Returns the family name of the current font face.

source

pub fn face_style_name_borrowed(&self) -> Option<&'ttf CStr>

Returns the name of the current font face without doing any heap allocations.

source

pub fn face_style_name(&self) -> Option<String>

Returns the name of the current font face.

source

pub fn find_glyph(&self, ch: char) -> Option<u16>

Returns the index of the given character in this font face.

source

pub fn find_glyph_metrics(&self, ch: char) -> Option<GlyphMetrics>

Returns the glyph metrics of the given character in this font face.

Trait Implementations§

source§

impl<'ttf, 'r> Drop for Font<'ttf, 'r>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> 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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.