diff options
author | 2019-11-14 06:47:43 +0100 | |
---|---|---|
committer | 2019-11-14 06:47:43 +0100 | |
commit | a16dab9cf2e27cb933cc91383ca79ba8e188c4c2 (patch) | |
tree | db844c70cc8fbd2f48b175e97bde50866641a1b4 /wgpu/src/renderer/widget/text.rs | |
parent | bc8d347736ec997ec0e0c401289e2bc09e212b8a (diff) | |
parent | 6857829dc3171fd68065498b6cd29f0ef02a8d43 (diff) | |
download | iced-a16dab9cf2e27cb933cc91383ca79ba8e188c4c2.tar.gz iced-a16dab9cf2e27cb933cc91383ca79ba8e188c4c2.tar.bz2 iced-a16dab9cf2e27cb933cc91383ca79ba8e188c4c2.zip |
Merge pull request #54 from hecrj/feature/external-fonts
Custom font support
Diffstat (limited to 'wgpu/src/renderer/widget/text.rs')
-rw-r--r-- | wgpu/src/renderer/widget/text.rs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/wgpu/src/renderer/widget/text.rs b/wgpu/src/renderer/widget/text.rs index b9ccd787..a8ead70b 100644 --- a/wgpu/src/renderer/widget/text.rs +++ b/wgpu/src/renderer/widget/text.rs @@ -1,8 +1,6 @@ use crate::{Primitive, Renderer}; use iced_native::{layout, text, Color, Layout, MouseCursor, Size, Text}; -use wgpu_glyph::{GlyphCruncher, Section}; - use std::f32; // TODO: Obtain from renderer configuration @@ -14,20 +12,9 @@ impl text::Renderer for Renderer { let size = text.size.map(f32::from).unwrap_or(DEFAULT_TEXT_SIZE); let bounds = limits.max(); - let section = Section { - text: &text.content, - scale: wgpu_glyph::Scale { x: size, y: size }, - bounds: (bounds.width, bounds.height), - ..Default::default() - }; - - let (width, height) = if let Some(bounds) = - self.text_measurements.borrow_mut().glyph_bounds(§ion) - { - (bounds.width().ceil(), bounds.height().ceil()) - } else { - (0.0, 0.0) - }; + let (width, height) = + self.text_pipeline + .measure(&text.content, size, text.font, bounds); let size = limits.resolve(Size::new(width, height)); @@ -41,6 +28,7 @@ impl text::Renderer for Renderer { size: text.size.map(f32::from).unwrap_or(DEFAULT_TEXT_SIZE), bounds: layout.bounds(), color: text.color.unwrap_or(Color::BLACK), + font: text.font, horizontal_alignment: text.horizontal_alignment, vertical_alignment: text.vertical_alignment, }, |