INNER CODE UNIT · Rust

load_font

PistonDevelopers/piston_window · src/piston_script.rs:187

    pub fn load_font(rt: &mut Runtime) -> Result<Variable, String> {
        use dyon::embed::PushVariable;
        use wgpu_graphics::{Filter, TextureSettings};
        use graphics::glyph_cache::rusttype::GlyphCache;

        let texture_context = unsafe {&*Current::<TextureContext>::new()};
        let glyphs = unsafe { &mut *Current::<Vec<GlyphCache<'static, TextureContext, Texture>>>::new() };
        let font_names = unsafe { &mut *Current::<FontNames>::new() };
        let file: Arc<String> = rt.pop()?;
        let texture_settings = TextureSettings::new().filter(Filter::Nearest);
        Ok(match GlyphCache::<'static, TextureContext, Texture>::new(
            &**file, texture_context.clone(), texture_settings)
        {
            Ok(x) => {
                let id = glyphs.len();
                glyphs.push(x);
                font_names.0.push(file.clone());
                Ok::<usize, Arc<String>>(id).push_var()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…