Stop loading a mono font just for the debug view

This commit is contained in:
Héctor Ramón Jiménez 2019-11-26 15:33:38 +01:00
parent a99aa1dd61
commit 80a8a57471
2 changed files with 4 additions and 16 deletions

View File

@ -30,15 +30,10 @@ impl Pipeline {
.load(&[font::Family::SansSerif, font::Family::Serif]) .load(&[font::Family::SansSerif, font::Family::Serif])
.unwrap_or_else(|_| FALLBACK_FONT.to_vec()); .unwrap_or_else(|_| FALLBACK_FONT.to_vec());
let mono_font = font_source
.load(&[font::Family::Monospace])
.unwrap_or_else(|_| FALLBACK_FONT.to_vec());
let load_glyph_brush = |font: Vec<u8>| { let load_glyph_brush = |font: Vec<u8>| {
let builder = let builder =
wgpu_glyph::GlyphBrushBuilder::using_fonts_bytes(vec![ wgpu_glyph::GlyphBrushBuilder::using_fonts_bytes(vec![
mono_font.clone(), font.clone()
font.clone(),
])?; ])?;
Ok(( Ok((
@ -109,14 +104,7 @@ impl Pipeline {
text: content, text: content,
scale: wgpu_glyph::Scale { x: size, y: size }, scale: wgpu_glyph::Scale { x: size, y: size },
bounds: (bounds.width, bounds.height), bounds: (bounds.width, bounds.height),
font_id: wgpu_glyph::FontId(font_id),
// TODO: This is a bit hacky. We are loading the debug font as the
// first font in the `draw_brush`. The `measure_brush` does not
// contain this, hence we subtract 1.
//
// This should go away once we unify `draw_brush` and
// `measure_brush`.
font_id: wgpu_glyph::FontId(font_id - 1),
..Default::default() ..Default::default()
}; };
@ -157,7 +145,7 @@ impl Pipeline {
pub fn find_font(&self, font: iced_native::Font) -> wgpu_glyph::FontId { pub fn find_font(&self, font: iced_native::Font) -> wgpu_glyph::FontId {
match font { match font {
iced_native::Font::Default => wgpu_glyph::FontId(1), iced_native::Font::Default => wgpu_glyph::FontId(0),
iced_native::Font::External { name, bytes } => { iced_native::Font::External { name, bytes } => {
if let Some(font_id) = self.draw_font_map.borrow().get(name) { if let Some(font_id) = self.draw_font_map.borrow().get(name) {
return *font_id; return *font_id;

View File

@ -146,7 +146,7 @@ impl Debug {
let mut lines = Vec::new(); let mut lines = Vec::new();
fn key_value<T: std::fmt::Debug>(key: &str, value: T) -> String { fn key_value<T: std::fmt::Debug>(key: &str, value: T) -> String {
format!("{: <30} {:?}", key, value) format!("{} {:?}", key, value)
} }
lines.push(format!( lines.push(format!(