Struct tetra::graphics::text::VectorFontBuilder
source · pub struct VectorFontBuilder { /* private fields */ }
Expand description
A builder for vector-based fonts.
TrueType and OpenType fonts are supported. The font data will only be loaded
into memory once, and it will be shared between all Font
s that
are subsequently created by the builder instance.
Font::vector
provides a simpler API for loading vector fonts, if you don’t need
all of the functionality of this struct.
Performance
Creating a VectorFontBuilder
is a relatively expensive operation. If you need to create
extra sizes of the font later on, store the VectorFontBuilder
rather than building a new one.
Cloning a VectorFontBuilder
is a very cheap operation, as the underlying data is shared between the
original instance and the clone via reference-counting.
Implementations§
source§impl VectorFontBuilder
impl VectorFontBuilder
sourcepub fn new<P>(path: P) -> Result<VectorFontBuilder>where
P: AsRef<Path>,
pub fn new<P>(path: P) -> Result<VectorFontBuilder>where P: AsRef<Path>,
Loads a vector font from the given file.
Errors
TetraError::FailedToLoadAsset
will be returned if the file could not be loaded.TetraError::InvalidFont
will be returned if the font data was invalid.
sourcepub fn from_file_data(data: &'static [u8]) -> Result<VectorFontBuilder>
pub fn from_file_data(data: &'static [u8]) -> Result<VectorFontBuilder>
Loads a vector font from a slice of binary data.
Errors
TetraError::InvalidFont
will be returned if the font data was invalid.
sourcepub fn texture_style(
&mut self,
texture_style: FontTextureStyle
) -> &mut VectorFontBuilder
pub fn texture_style( &mut self, texture_style: FontTextureStyle ) -> &mut VectorFontBuilder
Sets which style of texture data should be generated for this font.
Trait Implementations§
source§impl Clone for VectorFontBuilder
impl Clone for VectorFontBuilder
source§fn clone(&self) -> VectorFontBuilder
fn clone(&self) -> VectorFontBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more