From 05af8d00d4c0f7b8e0ece85224fd90a92da86da8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 17:15:44 +0200 Subject: Draft new `iced_graphics` crate :tada: --- wgpu/src/text.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index f4521e72..8bcd6d83 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -138,7 +138,7 @@ impl Pipeline { .advance_width } - pub fn clear_measurement_cache(&mut self) { + 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. // This makes stuff quite inconvenient. A manual method for trimming the -- cgit From e0c4f1a08e756f11c30a99cd739fe78267e5040b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 20:20:51 +0200 Subject: Move `font::Source` to `iced_graphics` --- wgpu/src/text.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 8bcd6d83..ae9b6b22 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -1,7 +1,5 @@ -mod font; - use crate::Transformation; - +use iced_graphics::font; use std::{cell::RefCell, collections::HashMap}; pub const BUILTIN_ICONS: iced_native::Font = iced_native::Font::External { -- cgit From f0480854a9cd76f443848dbfa14256089b56abfe Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 20:30:46 +0200 Subject: Move built-in fonts to `iced_graphics` --- wgpu/src/text.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index ae9b6b22..c1782fe5 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -2,15 +2,6 @@ use crate::Transformation; use iced_graphics::font; use std::{cell::RefCell, collections::HashMap}; -pub const BUILTIN_ICONS: iced_native::Font = iced_native::Font::External { - name: "iced_wgpu icons", - bytes: include_bytes!("text/icons.ttf"), -}; - -pub const CHECKMARK_ICON: char = '\u{F00C}'; - -const FALLBACK_FONT: &[u8] = include_bytes!("../fonts/Lato-Regular.ttf"); - #[derive(Debug)] pub struct Pipeline { draw_brush: RefCell>, @@ -32,7 +23,7 @@ impl Pipeline { default_font.map(|slice| slice.to_vec()).unwrap_or_else(|| { font_source .load(&[font::Family::SansSerif, font::Family::Serif]) - .unwrap_or_else(|_| FALLBACK_FONT.to_vec()) + .unwrap_or_else(|_| font::FALLBACK.to_vec()) }); let load_glyph_brush = |font: Vec| { @@ -51,7 +42,7 @@ impl Pipeline { .unwrap_or_else(|_: wgpu_glyph::rusttype::Error| { log::warn!("System font failed to load. Falling back to embedded font..."); - load_glyph_brush(FALLBACK_FONT.to_vec()).expect("Load fallback font") + load_glyph_brush(font::FALLBACK.to_vec()).expect("Load fallback font") }); let draw_brush = brush_builder -- cgit From 720e7756f2afe30706b6b1a7fbde86b9f15e1d8c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 22:55:12 +0200 Subject: Move `Layer` to `iced_graphics` --- wgpu/src/text.rs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index c1782fe5..17d3f6dd 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -57,10 +57,6 @@ impl Pipeline { } } - pub fn overlay_font(&self) -> wgpu_glyph::FontId { - wgpu_glyph::FontId(0) - } - pub fn queue(&mut self, section: wgpu_glyph::Section<'_>) { self.draw_brush.borrow_mut().queue(section); } -- cgit From 823ea1573245b849a0696543838a7ad1d0f914d8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 27 May 2020 23:09:27 +0200 Subject: Update `glyph_brush` and `glow_glyph` --- wgpu/src/text.rs | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 17d3f6dd..d65c0385 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -6,7 +6,6 @@ use std::{cell::RefCell, collections::HashMap}; pub struct Pipeline { draw_brush: RefCell>, draw_font_map: RefCell>, - measure_brush: RefCell>, } @@ -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. -- cgit