ruffle/core/src/font.rs

24 lines
608 B
Rust
Raw Normal View History

2019-05-04 18:45:11 +00:00
use crate::backend::render::ShapeHandle;
2019-05-24 17:25:03 +00:00
use crate::player::UpdateContext;
2019-05-04 18:45:11 +00:00
type Error = Box<std::error::Error>;
pub struct Font {
glyphs: Vec<ShapeHandle>,
}
impl Font {
pub fn from_swf_tag(context: &mut UpdateContext, tag: &swf::Font) -> Result<Font, Error> {
let mut glyphs = vec![];
for glyph in &tag.glyphs {
let shape_handle = context.renderer.register_glyph_shape(glyph);
glyphs.push(shape_handle);
}
2019-05-24 17:25:03 +00:00
Ok(Font { glyphs })
2019-05-04 18:45:11 +00:00
}
pub fn get_glyph(&self, i: usize) -> Option<ShapeHandle> {
2019-05-09 21:14:21 +00:00
self.glyphs.get(i).cloned()
2019-05-04 18:45:11 +00:00
}
}