Struct rich_sdl2_rust::ttf::font::Font
source · pub struct Font<'ttf> { /* private fields */ }
Expand description
A font data structure.
Implementations§
source§impl<'ttf> Font<'ttf>
impl<'ttf> Font<'ttf>
sourcepub fn new(
_ttf: &'ttf Ttf,
file_name: &str,
point: u32,
index: Option<usize>
) -> Result<Self>
pub fn new( _ttf: &'ttf Ttf, file_name: &str, point: u32, index: Option<usize> ) -> Result<Self>
Constructs a font data from file name and point size.
The font face in the font file can be selected by an optional index, which will be 0
if None
.
§Panics
Panics if file_name
is empty.
sourcepub fn rendered_size(&self, text: &str) -> Result<Size>
pub fn rendered_size(&self, text: &str) -> Result<Size>
Calculates the rendered size of the text, or Err
on failure. The height will be same as MetricExt::height
.
Trait Implementations§
source§impl AttributeExt for Font<'_>
impl AttributeExt for Font<'_>
source§fn is_fixed_width(&self) -> bool
fn is_fixed_width(&self) -> bool
Returns whether the font is fixed width.
source§impl FontSetting for Font<'_>
impl FontSetting for Font<'_>
source§fn hinting(&self) -> FontHinting
fn hinting(&self) -> FontHinting
Returns the current hinting of the font.
source§fn set_hinting(&self, hinting: FontHinting)
fn set_hinting(&self, hinting: FontHinting)
Sets the hinting of the font.
source§fn disable_kerning(&self) -> KerningDisabler<'_>
fn disable_kerning(&self) -> KerningDisabler<'_>
Disables the font kerning.
source§impl MetricExt for Font<'_>
impl MetricExt for Font<'_>
source§fn ascent(&self) -> u32
fn ascent(&self) -> u32
Returns the maximum ascent, the hight above baseline of the glyph in the font, in pixels.
source§fn descent(&self) -> u32
fn descent(&self) -> u32
Returns the maximum ascent, the hight below baseline of the glyph in the font, in pixels.
source§fn line_skip(&self) -> u32
fn line_skip(&self) -> u32
Returns the line skip height of the font, the recommended height of a rendered line of text, in pixels. It is usually larger than
MetricExt::height()
.source§impl RenderExt for Font<'_>
impl RenderExt for Font<'_>
source§fn render(&self, text: &str, mode: RenderMode) -> Result<TtfSurface>
fn render(&self, text: &str, mode: RenderMode) -> Result<TtfSurface>
Renders the text into the
TtfSurface
, or Err
on failure.source§fn render_wrapped(
&self,
text: &str,
wrap_length: u32,
mode: RenderMode
) -> Result<TtfSurface>
fn render_wrapped( &self, text: &str, wrap_length: u32, mode: RenderMode ) -> Result<TtfSurface>
Renders the wrapped text into the
TtfSurface
, or Err
on failure.source§fn render_glyph(&self, ch: char, mode: RenderMode) -> Result<TtfSurface>
fn render_glyph(&self, ch: char, mode: RenderMode) -> Result<TtfSurface>
Renders the character into the
TtfSurface
, or Err
on failure.source§impl StyleExt for Font<'_>
impl StyleExt for Font<'_>
source§fn font_style(&self) -> FontStyle
fn font_style(&self) -> FontStyle
Returns the current font style.
source§fn set_font_style(&self, style: FontStyle)
fn set_font_style(&self, style: FontStyle)
Sets the font style.
source§fn outline_width(&self) -> u32
fn outline_width(&self) -> u32
Returns the current outline width in pixels.
source§fn set_outline_width(&self, pixels: u32)
fn set_outline_width(&self, pixels: u32)
Sets the outline width in pixels.
Auto Trait Implementations§
impl<'ttf> !RefUnwindSafe for Font<'ttf>
impl<'ttf> !Send for Font<'ttf>
impl<'ttf> !Sync for Font<'ttf>
impl<'ttf> Unpin for Font<'ttf>
impl<'ttf> !UnwindSafe for Font<'ttf>
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
Mutably borrows from an owned value. Read more