Skip to main content

BitmapGlyph

Struct BitmapGlyph 

Source
pub struct BitmapGlyph<'a> {
Show 14 fields glyph: GlyphId, source: BitmapSource, pixels: Pixels<'a>, width: u32, height: u32, x_bearing: i32, y_bearing: i32, inner_x_bearing: i32, inner_y_bearing: i32, h_advance: Option<u32>, ppem_x: u16, ppem_y: u16, origin: Origin, units_per_em: u16,
}
Expand description

An embedded bitmap glyph.

A bitmap is positioned in two steps. The outer bearings offset the glyph origin in font units, so they scale with the font size. The inner bearings then position the image’s corner in pixels of the strike, so they scale by the ratio of the font size to the strike size.

Fields§

§glyph: GlyphId§source: BitmapSource§pixels: Pixels<'a>§width: u32§height: u32§x_bearing: i32§y_bearing: i32§inner_x_bearing: i32§inner_y_bearing: i32§h_advance: Option<u32>§ppem_x: u16§ppem_y: u16§origin: Origin§units_per_em: u16

Implementations§

Source§

impl<'a> BitmapGlyph<'a>

Source

pub fn glyph(&self) -> GlyphId

Returns the glyph ID of this bitmap.

For an sbix entry that reuses another glyph’s image, this is the requested glyph.

Source

pub fn source(&self) -> BitmapSource

Returns the table that contains the bitmap.

Source

pub fn pixels(&self) -> Pixels<'a>

Returns the pixel data.

Source

pub fn width(&self) -> u32

Returns the width in pixels.

Source

pub fn height(&self) -> u32

Returns the height in pixels.

Source

pub fn x_bearing(&self) -> i32

Returns the horizontal offset of the image’s origin from the glyph origin, in font units.

This is the hmtx bearing for an sbix glyph with an outline, and zero otherwise.

Source

pub fn y_bearing(&self) -> i32

Returns the vertical offset of the image’s origin above the glyph origin, in font units.

This is the bottom of the outline’s bounding box for an sbix glyph with an outline, and zero otherwise.

Source

pub fn inner_x_bearing(&self) -> i32

Returns the horizontal position of the origin corner, in pixels to the right of the image’s origin.

Source

pub fn inner_y_bearing(&self) -> i32

Returns the vertical position of the origin corner, in pixels above the image’s origin.

Source

pub fn h_advance(&self) -> Option<u32>

Returns the advance width in pixels, if the table provides one.

This is always None for sbix.

Source

pub fn ppem_x(&self) -> u16

Returns the horizontal pixels per em of the strike that contains the glyph.

Source

pub fn ppem_y(&self) -> u16

Returns the vertical pixels per em of the strike that contains the glyph.

Source

pub fn origin(&self) -> Origin

Returns the corner that the inner bearings position.

Source

pub fn ppem(&self) -> u16

Returns the size of the strike.

This is the larger of the horizontal and vertical pixels per em.

Source

pub fn extents(&self) -> GlyphExtents<f32>

Returns the ink extents of the bitmap, in font units.

Each value is scaled from pixels by the strike size and rounded to a whole unit. The bearing is to the top left corner, whatever corner the table uses. The table’s outer bearings are not included.

Trait Implementations§

Source§

impl<'a> Clone for BitmapGlyph<'a>

Source§

fn clone(&self) -> BitmapGlyph<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for BitmapGlyph<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for BitmapGlyph<'a>

§

impl<'a> RefUnwindSafe for BitmapGlyph<'a>

§

impl<'a> Send for BitmapGlyph<'a>

§

impl<'a> Sync for BitmapGlyph<'a>

§

impl<'a> Unpin for BitmapGlyph<'a>

§

impl<'a> UnsafeUnpin for BitmapGlyph<'a>

§

impl<'a> UnwindSafe for BitmapGlyph<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.