[][src]Struct stb_truetype::FontInfo

pub struct FontInfo<Data: Deref<Target = [u8]>> { /* fields omitted */ }

Methods

impl<Data: Deref<Target = [u8]>> FontInfo<Data>[src]

pub fn new(data: Data, fontstart: usize) -> Option<FontInfo<Data>>[src]

Given an offset into the file that defines a font, this function builds the necessary cached info for the rest of the system.

pub fn get_num_glyphs(&self) -> u32[src]

pub fn find_glyph_index(&self, unicode_codepoint: u32) -> u32[src]

If you're going to perform multiple operations on the same character and you want a speed-up, call this function with the character you're going to process, then use glyph-based functions instead of the codepoint-based functions.

pub fn get_codepoint_shape(&self, unicode_codepoint: u32) -> Option<Vec<Vertex>>[src]

Returns the series of vertices encoding the shape of the glyph for this codepoint.

The shape is a series of countours. Each one starts with a moveto, then consists of a series of mixed lineto and curveto segments. A lineto draws a line from previous endpoint to its x,y; a curveto draws a quadratic bezier from previous endpoint to its x,y, using cx,cy as the bezier control point.

pub fn get_glyph_box(&self, glyph_index: u32) -> Option<Rect<i16>>[src]

Like get_codepoint_box, but takes a glyph index. Use this if you have cached the glyph index for a codepoint.

pub fn get_codepoint_box(&self, codepoint: u32) -> Option<Rect<i16>>[src]

Gets the bounding box of the visible part of the glyph, in unscaled coordinates

pub fn is_glyph_empty(&self, glyph_index: u32) -> bool[src]

returns true if nothing is drawn for this glyph

pub fn get_glyph_shape(&self, glyph_index: u32) -> Option<Vec<Vertex>>[src]

Like get_codepoint_shape, but takes a glyph index instead. Use this if you have cached the glyph index for a codepoint.

pub fn get_glyph_h_metrics(&self, glyph_index: u32) -> HMetrics[src]

like get_codepoint_h_metrics, but takes a glyph index instead. Use this if you have cached the glyph index for a codepoint.

pub fn get_glyph_kern_advance(&self, glyph_1: u32, glyph_2: u32) -> i32[src]

like get_codepoint_kern_advance, but takes glyph indices instead. Use this if you have cached the glyph indices for the codepoints.

pub fn get_codepoint_kern_advance(&self, cp1: u32, cp2: u32) -> i32[src]

an additional amount to add to the 'advance' value between cp1 and cp2

pub fn get_codepoint_h_metrics(&self, codepoint: u32) -> HMetrics[src]

left_side_bearing is the offset from the current horizontal position to the left edge of the character advance_width is the offset from the current horizontal position to the next horizontal position these are expressed in unscaled coordinates

pub fn get_v_metrics(&self) -> VMetrics[src]

ascent is the coordinate above the baseline the font extends; descent is the coordinate below the baseline the font extends (i.e. it is typically negative) line_gap is the spacing between one row's descent and the next row's ascent... so you should advance the vertical position by ascent - descent + line_gap these are expressed in unscaled coordinates, so you must multiply by the scale factor for a given size

pub fn get_bounding_box(&self) -> Rect<i16>[src]

the bounding box around all possible characters

pub fn scale_for_pixel_height(&self, height: f32) -> f32[src]

computes a scale factor to produce a font whose "height" is 'pixels' tall. Height is measured as the distance from the highest ascender to the lowest descender; in other words, it's equivalent to calling GetFontVMetrics and computing: scale = pixels / (ascent - descent) so if you prefer to measure height by the ascent only, use a similar calculation.

pub fn units_per_em(&self) -> u16[src]

Returns the units per EM square of this font.

pub fn scale_for_mapping_em_to_pixels(&self, pixels: f32) -> f32[src]

computes a scale factor to produce a font whose EM size is mapped to pixels tall. This is probably what traditional APIs compute, but I'm not positive.

pub fn get_glyph_bitmap_box_subpixel(
    &self,
    glyph: u32,
    scale_x: f32,
    scale_y: f32,
    shift_x: f32,
    shift_y: f32
) -> Option<Rect<i32>>
[src]

like get_codepoint_bitmap_box_subpixel, but takes a glyph index instead of a codepoint.

pub fn get_glyph_bitmap_box(
    &self,
    glyph: u32,
    scale_x: f32,
    scale_y: f32
) -> Option<Rect<i32>>
[src]

like get_codepoint_bitmap_box, but takes a glyph index instead of a codepoint.

pub fn get_codepoint_bitmap_box_subpixel(
    &self,
    codepoint: u32,
    scale_x: f32,
    scale_y: f32,
    shift_x: f32,
    shift_y: f32
) -> Option<Rect<i32>>
[src]

same as get_codepoint_bitmap_box, but you can specify a subpixel shift for the character

pub fn get_codepoint_bitmap_box(
    &self,
    codepoint: u32,
    scale_x: f32,
    scale_y: f32
) -> Option<Rect<i32>>
[src]

get the bounding box of the bitmap centered around the glyph origin; so the bitmap width is x1-x0, height is y1-y0, and location to place the bitmap top left is (left_side_bearing*scale, y0). (Note that the bitmap uses y-increases-down, but the shape uses y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)

Important traits for FontNameIter<'a, Data>
pub fn get_font_name_strings(&self) -> FontNameIter<Data>[src]

Trait Implementations

impl<Data: Clone + Deref<Target = [u8]>> Clone for FontInfo<Data>[src]

impl<Data: Copy + Deref<Target = [u8]>> Copy for FontInfo<Data>[src]

impl<Data: Debug + Deref<Target = [u8]>> Debug for FontInfo<Data>[src]

Auto Trait Implementations

impl<Data> Send for FontInfo<Data> where
    Data: Send

impl<Data> Sync for FontInfo<Data> where
    Data: Sync

impl<Data> Unpin for FontInfo<Data> where
    Data: Unpin

impl<Data> UnwindSafe for FontInfo<Data> where
    Data: UnwindSafe

impl<Data> RefUnwindSafe for FontInfo<Data> where
    Data: RefUnwindSafe

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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