Render emojis

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-04-13 17:31:10 +02:00
parent fff1d9c631
commit cdcdccfb89
7 changed files with 255 additions and 56 deletions

View file

@ -29,6 +29,7 @@ pub struct Layer {
images: Vec<Image>,
shadows: Vec<Shadow>,
glyphs: Vec<Glyph>,
image_glyphs: Vec<ImageGlyph>,
icons: Vec<Icon>,
paths: Vec<Path>,
}
@ -58,6 +59,14 @@ pub struct Glyph {
pub color: Color,
}
#[derive(Debug)]
pub struct ImageGlyph {
pub font_id: FontId,
pub font_size: f32,
pub id: GlyphId,
pub origin: Vector2F,
}
pub struct Icon {
pub bounds: RectF,
pub svg: usvg::Tree,
@ -204,6 +213,10 @@ impl Scene {
self.active_layer().push_glyph(glyph)
}
pub fn push_image_glyph(&mut self, image_glyph: ImageGlyph) {
self.active_layer().push_image_glyph(image_glyph)
}
pub fn push_icon(&mut self, icon: Icon) {
self.active_layer().push_icon(icon)
}
@ -264,13 +277,14 @@ impl Layer {
pub fn new(clip_bounds: Option<RectF>) -> Self {
Self {
clip_bounds,
quads: Vec::new(),
underlines: Vec::new(),
images: Vec::new(),
shadows: Vec::new(),
glyphs: Vec::new(),
icons: Vec::new(),
paths: Vec::new(),
quads: Default::default(),
underlines: Default::default(),
images: Default::default(),
shadows: Default::default(),
image_glyphs: Default::default(),
glyphs: Default::default(),
icons: Default::default(),
paths: Default::default(),
}
}
@ -318,6 +332,14 @@ impl Layer {
self.shadows.as_slice()
}
fn push_image_glyph(&mut self, glyph: ImageGlyph) {
self.image_glyphs.push(glyph);
}
pub fn image_glyphs(&self) -> &[ImageGlyph] {
self.image_glyphs.as_slice()
}
fn push_glyph(&mut self, glyph: Glyph) {
self.glyphs.push(glyph);
}