Skip to main content

FontAtlasDef

Struct FontAtlasDef 

Source
pub struct FontAtlasDef {
    pub cell_w: u32,
    pub cell_h: u32,
    pub columns: u32,
    pub glyphs: BTreeMap<char, u32>,
    pub wide: WideSet,
    pub wide_sets: BTreeMap<String, WideSet>,
}
Expand description

The validated font atlas layout.

Fields§

§cell_w: u32

Cell width in pixels.

§cell_h: u32

Cell height in pixels.

§columns: u32

Cells per atlas row.

§glyphs: BTreeMap<char, u32>

Every glyph in the atlas → its cell index (row-major).

§wide: WideSet

The unnamed wide set: every wide glyph, two cells wide, → the cell index of its left half; its right half is the next cell, in the same row. A character is narrow or wide, never both, but for WIDE_PUNCTUATION. Empty in an atlas without wide glyphs, and left out of its file.

§wide_sets: BTreeMap<String, WideSet>

The named wide sets, by name (the atlas’s own word, which a pack’s wide_font names), each laid out as wide. A character may be in several sets, each with its own shape. Empty in an atlas of one wide set or none, and left out of its file.

Implementations§

Source§

impl FontAtlasDef

Source

pub fn cell_rect(&self, index: u32) -> AtlasRect

The pixel rectangle of cell index. columns must be non-zero (a validated atlas guarantees it).

Source

pub fn glyph_rect(&self, c: char) -> Option<AtlasRect>

The pixel rectangle of narrow glyph c, or None if the atlas lacks it or has it wide (wide_rect).

Source

pub fn wide_rect(&self, c: char) -> Option<AtlasRect>

The pixel rectangle of wide glyph c, both its cells, or None if no wide set has c: wide_rect_in with no set named.

Source

pub fn wide_rect_in(&self, set: Option<&str>, c: char) -> Option<AtlasRect>

The pixel rectangle of wide glyph c, both its cells, looked up as wide_cell says, or None if no wide set has c.

Source

pub fn wide_cell(&self, set: Option<&str>, c: char) -> Option<u32>

The cell index of wide glyph c’s left half: from the named set set (the language’s, CellWidths::wide_font) first, then the unnamed set, then the other named sets in name order. None if no set has c. Every renderer looks wide glyphs up with it.

Source

pub fn wide_set(&self, name: Option<&str>) -> Option<&WideSet>

The wide set name names, the unnamed one for None, if the atlas has it (the unnamed one always).

Source

pub fn all_wide_sets( &self, ) -> impl Iterator<Item = (Option<&str>, &WideSet)> + '_

Every wide set: the unnamed one (None), then the named ones in name order.

Source

pub fn wide_chars(&self) -> BTreeSet<char>

The characters two cells wide where no language is named (CellWidths::of): every set’s, but punctuation of WIDE_PUNCTUATION the atlas also has narrow.

Source

pub fn has_wide(&self, c: char) -> bool

Whether any wide set has c.

Source

pub fn draws(&self, c: char) -> bool

Whether the atlas draws c, narrow or wide in any set: the one answer to “can this character be drawn?” where no language is named (a name box’s letters). undrawn checks a language’s text against its own set.

Source

pub fn drawn(&self) -> impl Iterator<Item = char> + '_

Every character draws accepts, in code-point order, each once.

Source

pub fn cell_end(&self) -> u32

One past the last cell index any glyph takes: how many cells of the atlas its glyphs reach.

Source

pub fn from_source( file: &str, source: &str, png_file: &str, png: Option<&[u8]>, required: &str, ) -> Result<Self, Vec<ContentError>>

Parses glyph map source (errors attributed to file) and validates it: it must hold every glyph of required, and fit the atlas image png (None if missing; errors attributed to png_file).

Source

pub fn problems(&self, required: &str) -> Vec<String>

Problems with the glyph map on its own, in plain words: a size of 0, a glyph of required it lacks, two glyphs in one cell, a character both narrow and wide (but for WIDE_PUNCTUATION), a wide glyph split across a row’s end, or a named set with an empty name.

Source

pub fn image_problems(&self, width: u32, height: u32) -> Vec<String>

Problems fitting the glyph map onto a width × height pixel image.

Trait Implementations§

Source§

impl AssetKind for FontAtlasDef

Source§

const NAME: &'static str = "font atlas"

What messages call the kind, in lowercase words: "image", "palette".
Source§

impl Clone for FontAtlasDef

Source§

fn clone(&self) -> FontAtlasDef

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 Debug for FontAtlasDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FontAtlasDef

Source§

fn default() -> FontAtlasDef

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FontAtlasDef

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for FontAtlasDef

Source§

impl PartialEq for FontAtlasDef

Source§

fn eq(&self, other: &FontAtlasDef) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for FontAtlasDef

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for FontAtlasDef

Auto Trait Implementations§

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<K> Bakeable for K

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.