graphics_buffer/
glyphs.rs

1use std::{io, path::Path};
2
3use graphics::glyph_cache::rusttype;
4use texture::TextureSettings;
5
6use crate::RenderBuffer;
7
8/// A character cache for drawing text to a `RenderBuffer`.
9///
10/// If the link to the `GlyphCache` type is not working,
11/// try generating the docs yourself.
12pub type BufferGlyphs<'a> = rusttype::GlyphCache<'a, (), RenderBuffer>;
13
14/// Create a `BufferGlyphs` from some font data
15#[allow(clippy::result_unit_err)]
16pub fn buffer_glyphs_from_bytes(font_data: &[u8]) -> Result<BufferGlyphs, ()> {
17    BufferGlyphs::from_bytes(font_data, (), TextureSettings::new())
18}
19
20/// Create a `BufferGlyphs` from a path to some font
21pub fn buffer_glyphs_from_path<'a, P: AsRef<Path>>(font_path: P) -> io::Result<BufferGlyphs<'a>> {
22    BufferGlyphs::new(font_path, (), TextureSettings::new())
23}