Struct alacritty::renderer::GlyphCache [−][src]
pub struct GlyphCache {
cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>,
rasterizer: Rasterizer,
font_key: FontKey,
bold_key: FontKey,
italic_key: FontKey,
bold_italic_key: FontKey,
font_size: Size,
glyph_offset: Delta<i8>,
metrics: Metrics,
}Expand description
Naïve glyph cache.
Currently only keyed by char, and thus not possible to hold different
representations of the same code point.
Fields
cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>Cache of buffered glyphs.
rasterizer: RasterizerRasterizer for loading new glyphs.
font_key: FontKeyRegular font.
bold_key: FontKeyBold font.
italic_key: FontKeyItalic font.
bold_italic_key: FontKeyBold italic font.
font_size: SizeFont size.
glyph_offset: Delta<i8>Glyph offset.
metrics: MetricsFont metrics.
Implementations
pub fn new<L>(
rasterizer: Rasterizer,
font: &Font,
loader: &mut L
) -> Result<GlyphCache, Error> where
L: LoadGlyph,
Computes font keys for (Regular, Bold, Italic, Bold Italic).
fn load_regular_font(
rasterizer: &mut Rasterizer,
description: &FontDesc,
size: Size
) -> Result<FontKey, Error>
Get a glyph from the font.
If the glyph has never been loaded before, it will be rasterized and inserted into the cache.
Errors
This will fail when the glyph could not be rasterized. Usually this is due to the glyph not being present in any font.
Load glyph into the atlas.
This will apply all transforms defined for the glyph cache to the rasterized glyph before insertion.
Clear currently cached data in both GL and the registry.
pub fn update_font_size<L: LoadGlyph>(
&mut self,
font: &Font,
dpr: f64,
loader: &mut L
) -> Result<(), Error>
Prefetch glyphs that are almost guaranteed to be loaded anyways.