pub struct GlyphFont { /* private fields */ }Expand description
A loaded font that blits glyphs directly to a u32 framebuffer.
Implementations§
Source§impl GlyphFont
impl GlyphFont
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, String>
pub fn from_bytes(data: &[u8]) -> Result<Self, String>
Load from raw TTF/OTF bytes.
Sourcepub fn measure(&mut self, text: &str, px: f32) -> f32
pub fn measure(&mut self, text: &str, px: f32) -> f32
Total advance width of text at size px, in pixels.
Sourcepub fn draw_text(
&mut self,
buf: &mut [u32],
w: usize,
h: usize,
x: f32,
y: f32,
px: f32,
color: u32,
text: &str,
)
pub fn draw_text( &mut self, buf: &mut [u32], w: usize, h: usize, x: f32, y: f32, px: f32, color: u32, text: &str, )
Draw text into a packed 0x00RRGGBB framebuffer of w×h pixels.
(x, y) is the top-left of the text box (matching the vector ui_text
convention): the baseline is placed px below y via the font’s ascent.
Each glyph’s coverage alpha-blends color over the existing pixels.
Auto Trait Implementations§
impl Freeze for GlyphFont
impl RefUnwindSafe for GlyphFont
impl Send for GlyphFont
impl Sync for GlyphFont
impl Unpin for GlyphFont
impl UnsafeUnpin for GlyphFont
impl UnwindSafe for GlyphFont
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