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: u32Cell width in pixels.
cell_h: u32Cell height in pixels.
columns: u32Cells per atlas row.
glyphs: BTreeMap<char, u32>Every glyph in the atlas → its cell index (row-major).
wide: WideSetThe 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
impl FontAtlasDef
Sourcepub fn cell_rect(&self, index: u32) -> AtlasRect
pub fn cell_rect(&self, index: u32) -> AtlasRect
The pixel rectangle of cell index. columns must be non-zero (a
validated atlas guarantees it).
Sourcepub fn glyph_rect(&self, c: char) -> Option<AtlasRect>
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).
Sourcepub fn wide_rect(&self, c: char) -> Option<AtlasRect>
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.
Sourcepub fn wide_rect_in(&self, set: Option<&str>, c: char) -> Option<AtlasRect>
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.
Sourcepub fn wide_cell(&self, set: Option<&str>, c: char) -> Option<u32>
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.
Sourcepub fn wide_set(&self, name: Option<&str>) -> Option<&WideSet>
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).
Sourcepub fn all_wide_sets(
&self,
) -> impl Iterator<Item = (Option<&str>, &WideSet)> + '_
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.
Sourcepub fn wide_chars(&self) -> BTreeSet<char>
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.
Sourcepub fn draws(&self, c: char) -> bool
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.
Sourcepub fn drawn(&self) -> impl Iterator<Item = char> + '_
pub fn drawn(&self) -> impl Iterator<Item = char> + '_
Every character draws accepts, in code-point order,
each once.
Sourcepub fn cell_end(&self) -> u32
pub fn cell_end(&self) -> u32
One past the last cell index any glyph takes: how many cells of the atlas its glyphs reach.
Sourcepub fn from_source(
file: &str,
source: &str,
png_file: &str,
png: Option<&[u8]>,
required: &str,
) -> Result<Self, Vec<ContentError>>
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).
Sourcepub fn problems(&self, required: &str) -> Vec<String>
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.
Trait Implementations§
Source§impl AssetKind for FontAtlasDef
impl AssetKind for FontAtlasDef
Source§impl Clone for FontAtlasDef
impl Clone for FontAtlasDef
Source§fn clone(&self) -> FontAtlasDef
fn clone(&self) -> FontAtlasDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more