diff options
Diffstat (limited to '')
| -rw-r--r-- | graphics/src/backend.rs | 2 | ||||
| -rw-r--r-- | graphics/src/geometry/text.rs | 5 | ||||
| -rw-r--r-- | graphics/src/primitive.rs | 4 | ||||
| -rw-r--r-- | graphics/src/renderer.rs | 13 | 
4 files changed, 21 insertions, 3 deletions
| 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, diff --git a/graphics/src/geometry/text.rs b/graphics/src/geometry/text.rs index 0f731e74..c584f3cd 100644 --- a/graphics/src/geometry/text.rs +++ b/graphics/src/geometry/text.rs @@ -1,5 +1,5 @@  use crate::core::alignment; -use crate::core::text::Shaping; +use crate::core::text::{LineHeight, Shaping};  use crate::core::{Color, Font, Point};  /// A bunch of text that can be drawn to a canvas @@ -20,6 +20,8 @@ pub struct Text {      pub color: Color,      /// The size of the text      pub size: f32, +    /// The line height of the text. +    pub line_height: LineHeight,      /// The font of the text      pub font: Font,      /// The horizontal alignment of the text @@ -37,6 +39,7 @@ impl Default for Text {              position: Point::ORIGIN,              color: Color::BLACK,              size: 16.0, +            line_height: LineHeight::Relative(1.2),              font: Font::default(),              horizontal_alignment: alignment::Horizontal::Left,              vertical_alignment: alignment::Vertical::Top, diff --git a/graphics/src/primitive.rs b/graphics/src/primitive.rs index db237035..d814c757 100644 --- a/graphics/src/primitive.rs +++ b/graphics/src/primitive.rs @@ -19,8 +19,10 @@ pub enum Primitive {          bounds: Rectangle,          /// The color of the text          color: Color, -        /// The size of the text +        /// The size of the text in logical pixels          size: f32, +        /// The line height of the text +        line_height: text::LineHeight,          /// The font of the text          font: Font,          /// The horizontal alignment of the text diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 605286d6..aaf1737a 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -136,17 +136,26 @@ where          &self,          content: &str,          size: f32, +        line_height: text::LineHeight,          font: Font,          bounds: Size,          shaping: text::Shaping,      ) -> (f32, f32) { -        self.backend().measure(content, size, font, bounds, shaping) +        self.backend().measure( +            content, +            size, +            line_height, +            font, +            bounds, +            shaping, +        )      }      fn hit_test(          &self,          content: &str,          size: f32, +        line_height: text::LineHeight,          font: Font,          bounds: Size,          shaping: text::Shaping, @@ -156,6 +165,7 @@ where          self.backend().hit_test(              content,              size, +            line_height,              font,              bounds,              shaping, @@ -173,6 +183,7 @@ where              content: text.content.to_string(),              bounds: text.bounds,              size: text.size, +            line_height: text.line_height,              color: text.color,              font: text.font,              horizontal_alignment: text.horizontal_alignment, | 
