Update glyph_brush and glow_glyph

This commit is contained in:
Héctor Ramón Jiménez 2020-05-27 23:09:27 +02:00
parent 22ced3485e
commit 823ea15732
7 changed files with 41 additions and 86 deletions

View file

@ -250,10 +250,6 @@ impl backend::Text for Backend {
) -> (f32, f32) {
self.text_pipeline.measure(contents, size, font, bounds)
}
fn space_width(&self, size: f32) -> f32 {
self.text_pipeline.space_width(size)
}
}
#[cfg(feature = "image")]

View file

@ -6,7 +6,6 @@ use std::{cell::RefCell, collections::HashMap};
pub struct Pipeline {
draw_brush: RefCell<wgpu_glyph::GlyphBrush<'static, ()>>,
draw_font_map: RefCell<HashMap<String, wgpu_glyph::FontId>>,
measure_brush: RefCell<glyph_brush::GlyphBrush<'static, ()>>,
}
@ -52,7 +51,6 @@ impl Pipeline {
Pipeline {
draw_brush: RefCell::new(draw_brush),
draw_font_map: RefCell::new(HashMap::new()),
measure_brush: RefCell::new(measure_brush),
}
}
@ -109,20 +107,6 @@ impl Pipeline {
}
}
pub fn space_width(&self, size: f32) -> f32 {
use wgpu_glyph::GlyphCruncher;
let glyph_brush = self.measure_brush.borrow();
// TODO: Select appropriate font
let font = &glyph_brush.fonts()[0];
font.glyph(' ')
.scaled(wgpu_glyph::Scale { x: size, y: size })
.h_metrics()
.advance_width
}
pub fn trim_measurement_cache(&mut self) {
// TODO: We should probably use a `GlyphCalculator` for this. However,
// it uses a lifetimed `GlyphCalculatorGuard` with side-effects on drop.