pub struct FontAtlas {
pub width: u32,
pub height: u32,
pub pixels: Vec<u8>,
/* private fields */
}Expand description
R8-Glyphen-Atlas mehrerer Schriften, Shelf-Packer mit 1px Rand (verhindert UV-Bluten beim linearen Filtern). Deterministisch: Glyphen werden sortiert nach (Font, Codepoint) gelegt.
Fields§
§width: u32§height: u32§pixels: Vec<u8>Implementations§
Source§impl FontAtlas
impl FontAtlas
Sourcepub fn build(
ttf_fonts: &[&[u8]],
px: f32,
extra: &str,
width: u32,
height: u32,
) -> Result<Self, UiError>
pub fn build( ttf_fonts: &[&[u8]], px: f32, extra: &str, width: u32, height: u32, ) -> Result<Self, UiError>
Baut das Atlas aus TTF-Bytes (Font-Reihenfolge = Font-Index).
extra ergänzt ASCII um weitere Zeichen (z. B. Umlaute).
pub fn glyph(&self, font: usize, ch: char) -> Option<Glyph>
Sourcepub fn font_count(&self) -> usize
pub fn font_count(&self) -> usize
Anzahl der Schriften im Atlas (Font-Index = Reihenfolge in
Self::build; 0 = Regular, 1 = Bold, wenn mitgeliefert).
Sourcepub fn measure(&self, font: usize, text: &str, line_h: f32) -> [f32; 2]
pub fn measure(&self, font: usize, text: &str, line_h: f32) -> [f32; 2]
Misst einen Text ohne zu zeichnen — dieselbe Pen-Logik wie
Self::text (unbekannte Zeichen übersprungen, \n bricht die
Zeile), Rückgabe (w, h).
Sourcepub fn sample(&self, u: f32, v: f32) -> f32
pub fn sample(&self, u: f32, v: f32) -> f32
Bilinear abgetastete Abdeckung (0..1) bei normalisierten Atlas-UV — Texel-Mitten-Konvention wie der Hardware-Filter.
Sourcepub fn text(
&self,
font: usize,
text: &str,
x: f32,
y: f32,
line_h: f32,
color: Rgba,
) -> (Vec<UiVertex>, [f32; 2])
pub fn text( &self, font: usize, text: &str, x: f32, y: f32, line_h: f32, color: Rgba, ) -> (Vec<UiVertex>, [f32; 2])
Legt einen Text als Vertex-Liste aus (ein Batch, texturiert).
x/y = Schreibpunkt (y = Oberkante der ersten Zeile; die
Grundlinie liegt bei y + ascent), color färbt die Glyphen.
Rückgabe: Vertices + bbox (w, h). Unbekannte Zeichen werden
übersprungen, \n bricht die Zeile (line_h).