Struct fontstash::FontStash[][src]

pub struct FontStash { /* fields omitted */ }

Shared ownership of font stash

Hack for creation

Renderer needs fixed memory position so that fontstash::sys can call callback methods of it.

  1. Create Renderer in a Box with FontStash being uninitialized
  2. Call FontStash::init_mut to initialize FontStash

Implementations

impl FontStash[src]

Hack for creation

pub fn uninitialized() -> Self[src]

pub fn init_mut<R: Renderer>(&mut self, w: u32, h: u32, renderer: *mut R)[src]

impl FontStash[src]

pub fn raw(&self) -> *mut FONScontext[src]

pub fn clone(&self) -> Self[src]

impl FontStash[src]

Font storage. Each font is keyed with name string.

pub fn add_font_mem(&self, name: &str, data: &[u8]) -> Result<FontIx>[src]

pub fn set_font(&self, font: FontIx)[src]

pub fn font_ix_by_name(&self, name: &str) -> Option<FontIx>[src]

impl FontStash[src]

Atlas

pub fn atlas_size(&self) -> [u32; 2][src]

pub fn expand_atlas(&self, w: u32, h: u32) -> Result<()>[src]

Creates fontstash atlas size copying the previous data

pub fn reset_atlas(&self, w: u32, h: u32) -> Result<()>[src]

Creates new fontstash atlas with size without copying the previous data

impl FontStash[src]

States

pub fn set_size(&self, size: f32)[src]

NOTE: DPI scaling?

pub fn set_color(&self, color: u32)[src]

pub fn set_spacing(&self, spacing: f32)[src]

Horizontal space between characters?

pub fn set_blur(&self, blur: f32)[src]

pub fn set_align(&self, align: Align)[src]

Sets alignment of quadliterals returned with FontStash::text_iter

impl FontStash[src]

Texture

pub fn with_pixels(&self, f: impl FnMut(&[u8], u32, u32))[src]

NOTE: Pixel is in one byte (8 bits alpha channel only)

impl FontStash[src]

State stack

pub fn push_state(&mut self)[src]

pub fn pop_state(&mut self)[src]

pub fn clear_state(&mut self)[src]

impl FontStash[src]

Draw

pub fn text_iter(&self, text: &str) -> Result<FonsTextIter>[src]

Iterator of quadliterals aligned with Align

impl FontStash[src]

Measure

pub fn text_bounds_oneline(&self, pos: [f32; 2], text: &str) -> [f32; 4][src]

Returns [left_x, top_y, right_x, bottom_y]. Note that it doesn’t handle multiple lines of text. You need custom layer for multi-line text!

pub fn text_size_oneline(&self, text: &str) -> [f32; 2][src]

Returns [width, height]. Note that it doesn’t handle multiple lines of text. You need custom layer for multi-line text!

Trait Implementations

impl Debug for FontStash[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.