From b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Feb 2023 07:33:33 +0100 Subject: Overhaul `Font` type to allow font family selection --- graphics/src/backend.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 256b7ab5..7bbdee95 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -31,6 +31,9 @@ pub trait Text { /// [`ICON_FONT`]: Self::ICON_FONT const ARROW_DOWN_ICON: char; + /// Returns the default [`Font`]. + fn default_font(&self) -> Font; + /// Returns the default size of text. fn default_size(&self) -> f32; -- cgit From 238154af4ac8dda7f12dd90aa7be106e933bcb30 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Feb 2023 11:12:15 +0100 Subject: Implement `font::load` command in `iced_native` --- graphics/src/backend.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 7bbdee95..8658cffe 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -4,6 +4,8 @@ use iced_native::svg; use iced_native::text; use iced_native::{Font, Point, Size}; +use std::borrow::Cow; + /// The graphics backend of a [`Renderer`]. /// /// [`Renderer`]: crate::Renderer @@ -64,6 +66,9 @@ pub trait Text { point: Point, nearest_only: bool, ) -> Option; + + /// Loads a [`Font`] from its bytes. + fn load_font(&mut self, font: Cow<'static, [u8]>); } /// A graphics backend that supports image rendering. -- cgit From 5fd5d1cdf8e5354788dc40729c4565ef377d3bba Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Mar 2023 21:34:26 +0100 Subject: Implement `Canvas` support for `iced_tiny_skia` --- graphics/src/backend.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 8658cffe..c44372e8 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -10,6 +10,8 @@ use std::borrow::Cow; /// /// [`Renderer`]: crate::Renderer pub trait Backend { + type Geometry: Into; + /// Trims the measurements cache. /// /// This method is currently necessary to properly trim the text cache in -- cgit From 6cc48b5c62bac287b8f9f1c79c1fb7486c51b18f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 3 Mar 2023 04:57:55 +0100 Subject: Move `Canvas` and `QRCode` to `iced` crate Rename `canvas` modules to `geometry` in graphics subcrates --- graphics/src/backend.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index c44372e8..8658cffe 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -10,8 +10,6 @@ use std::borrow::Cow; /// /// [`Renderer`]: crate::Renderer pub trait Backend { - type Geometry: Into; - /// Trims the measurements cache. /// /// This method is currently necessary to properly trim the text cache in -- cgit From 3a0d34c0240f4421737a6a08761f99d6f8140d02 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Mar 2023 05:37:11 +0100 Subject: Create `iced_widget` subcrate and re-organize the whole codebase --- graphics/src/backend.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 8658cffe..dd2888ab 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -1,8 +1,8 @@ //! Write a graphics backend. -use iced_native::image; -use iced_native::svg; -use iced_native::text; -use iced_native::{Font, Point, Size}; +use iced_core::image; +use iced_core::svg; +use iced_core::text; +use iced_core::{Font, Point, Size}; use std::borrow::Cow; -- cgit From 33b5a900197e2798a393d6d9a0834039666eddbb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 19 Apr 2023 01:19:56 +0200 Subject: Make basic text shaping the default shaping strategy --- graphics/src/backend.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index dd2888ab..0e107dd5 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -48,6 +48,7 @@ pub trait Text { size: f32, font: Font, bounds: Size, + advanced_shape: bool, ) -> (f32, f32); /// Tests whether the provided point is within the boundaries of [`Text`] @@ -65,6 +66,7 @@ pub trait Text { bounds: Size, point: Point, nearest_only: bool, + advanced_shape: bool, ) -> Option; /// Loads a [`Font`] from its bytes. -- cgit From 4bd290afe7d81d9aaf7467b3ce91491f6600261a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 19 Apr 2023 02:00:45 +0200 Subject: Introduce `text::Shaping` enum and replace magic boolean --- graphics/src/backend.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 0e107dd5..0c2a6d30 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -48,7 +48,7 @@ pub trait Text { size: f32, font: Font, bounds: Size, - advanced_shape: bool, + shaping: text::Shaping, ) -> (f32, f32); /// Tests whether the provided point is within the boundaries of [`Text`] @@ -64,9 +64,9 @@ pub trait Text { size: f32, font: Font, bounds: Size, + shaping: text::Shaping, point: Point, nearest_only: bool, - advanced_shape: bool, ) -> Option; /// Loads a [`Font`] from its bytes. -- cgit From 9499a8f9e6f9971dedfae563cb133232aa3cebc2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 4 May 2023 13:00:16 +0200 Subject: Support configurable `LineHeight` in text widgets --- graphics/src/backend.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 0c2a6d30..ae89da06 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -46,6 +46,7 @@ pub trait Text { &self, contents: &str, size: f32, + line_height: text::LineHeight, font: Font, bounds: Size, shaping: text::Shaping, @@ -62,6 +63,7 @@ pub trait Text { &self, contents: &str, size: f32, + line_height: text::LineHeight, font: Font, bounds: Size, shaping: text::Shaping, -- cgit From 5bc7cbf5bca039ec3a4cbe82b161c087a4b39680 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 20 Jun 2023 06:22:17 +0200 Subject: Use subpixel glyph positioning and layout linearity ... for offsetting and scaling text --- graphics/src/backend.rs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index ae89da06..6a082576 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -6,18 +6,6 @@ use iced_core::{Font, Point, Size}; use std::borrow::Cow; -/// The graphics backend of a [`Renderer`]. -/// -/// [`Renderer`]: crate::Renderer -pub trait Backend { - /// Trims the measurements cache. - /// - /// This method is currently necessary to properly trim the text cache in - /// `iced_wgpu` and `iced_glow` because of limitations in the text rendering - /// pipeline. It will be removed in the future. - fn trim_measurements(&mut self) {} -} - /// A graphics backend that supports text rendering. pub trait Text { /// The icon font of the backend. -- cgit From 78ad365db232e53cbdf12105e40c1dbe87a3238c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 28 Jun 2023 00:35:37 +0200 Subject: Reuse entries in `text::Cache` in `iced_wgpu` --- graphics/src/backend.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 6a082576..70ccc664 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -38,7 +38,7 @@ pub trait Text { font: Font, bounds: Size, shaping: text::Shaping, - ) -> (f32, f32); + ) -> Size; /// Tests whether the provided point is within the boundaries of [`Text`] /// laid out with the given parameters, returning information about -- cgit From 0ae1baa37bd7b6607f79b33b8a6d8c5daafde0b2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 22 Jun 2023 00:38:36 +0200 Subject: Introduce custom backend-specific primitives --- graphics/src/backend.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 70ccc664..3ff24335 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -6,6 +6,13 @@ use iced_core::{Font, Point, Size}; use std::borrow::Cow; +/// The graphics backend of a [`Renderer`]. +/// +/// [`Renderer`]: crate::Renderer +pub trait Backend { + type Primitive; +} + /// A graphics backend that supports text rendering. pub trait Text { /// The icon font of the backend. -- cgit From 6921564c9f66e8103e19ec658099c5f5c32e8cc5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 29 Jun 2023 07:55:52 +0200 Subject: Write missing docs in `iced_graphics` and `iced_wgpu` --- graphics/src/backend.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 3ff24335..77bb650b 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -10,6 +10,7 @@ use std::borrow::Cow; /// /// [`Renderer`]: crate::Renderer pub trait Backend { + /// The custom kind of primitives this [`Backend`] supports. type Primitive; } -- cgit From d666e739cdcc2084c14593888867d40066c232fe Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 29 Jun 2023 18:23:11 +0200 Subject: Trim text measurements only before `layout` --- graphics/src/backend.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'graphics/src/backend.rs') diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index 77bb650b..59e95bf8 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -12,6 +12,13 @@ use std::borrow::Cow; pub trait Backend { /// The custom kind of primitives this [`Backend`] supports. type Primitive; + + /// Trims the measurements cache. + /// + /// This method is currently necessary to properly trim the text cache in + /// `iced_wgpu` and `iced_glow` because of limitations in the text rendering + /// pipeline. It will be removed in the future. + fn trim_measurements(&mut self) {} } /// A graphics backend that supports text rendering. -- cgit