pub struct BitmapFont { /* private fields */ }Expand description
Holds a decoded bitmap Font.
Implementations§
Source§impl BitmapFont
impl BitmapFont
Sourcepub fn new(
device: &Device,
font: BMFont,
pages: impl Into<Vec<Arc<Image>>>,
) -> Result<Self>
pub fn new( device: &Device, font: BMFont, pages: impl Into<Vec<Arc<Image>>>, ) -> Result<Self>
Creates a bitmap font renderer from decoded font metadata and page images.
Sourcepub fn measure(&self, text: &str) -> ([i32; 2], [u32; 2])
pub fn measure(&self, text: &str) -> ([i32; 2], [u32; 2])
Returns the position and area, in pixels, required to render the given text.
NOTE: The ‘start’ of the render area is at the zero coordinate, however it may extend into the negative x direction due to ligatures.
Sourcepub fn print(
&mut self,
graph: &mut Graph,
image: impl Into<AnyImageNode>,
x: f32,
y: f32,
color: impl Into<BitmapGlyphColor>,
text: impl AsRef<str>,
)
pub fn print( &mut self, graph: &mut Graph, image: impl Into<AnyImageNode>, x: f32, y: f32, color: impl Into<BitmapGlyphColor>, text: impl AsRef<str>, )
Prints text at the given position using the default scale factor of 1.0.
Sourcepub fn print_scale(
&mut self,
graph: &mut Graph,
image: impl Into<AnyImageNode>,
x: f32,
y: f32,
color: impl Into<BitmapGlyphColor>,
text: impl AsRef<str>,
scale: f32,
)
pub fn print_scale( &mut self, graph: &mut Graph, image: impl Into<AnyImageNode>, x: f32, y: f32, color: impl Into<BitmapGlyphColor>, text: impl AsRef<str>, scale: f32, )
Prints text at the given position using a caller-specified scale factor.
Sourcepub fn print_scale_scissor(
&mut self,
graph: &mut Graph,
image: impl Into<AnyImageNode>,
x: f32,
y: f32,
color: impl Into<BitmapGlyphColor>,
text: impl AsRef<str>,
scale: f32,
scissor: Option<(i32, i32, u32, u32)>,
)
pub fn print_scale_scissor( &mut self, graph: &mut Graph, image: impl Into<AnyImageNode>, x: f32, y: f32, color: impl Into<BitmapGlyphColor>, text: impl AsRef<str>, scale: f32, scissor: Option<(i32, i32, u32, u32)>, )
Prints text with an optional scissor rectangle and caller-specified scale factor.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BitmapFont
impl !UnwindSafe for BitmapFont
impl Freeze for BitmapFont
impl Send for BitmapFont
impl Sync for BitmapFont
impl Unpin for BitmapFont
impl UnsafeUnpin for BitmapFont
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