diff options
| author | 2023-04-19 01:19:56 +0200 | |
|---|---|---|
| committer | 2023-05-02 01:02:13 +0200 | |
| commit | 33b5a900197e2798a393d6d9a0834039666eddbb (patch) | |
| tree | b4ce1f77dc50d3733a2c9252d57674c3592a0c3c /tiny_skia | |
| parent | 57a276e16539d6aeca0619e0c5e36d0b1c1b5ef9 (diff) | |
| download | iced-33b5a900197e2798a393d6d9a0834039666eddbb.tar.gz iced-33b5a900197e2798a393d6d9a0834039666eddbb.tar.bz2 iced-33b5a900197e2798a393d6d9a0834039666eddbb.zip | |
Make basic text shaping the default shaping strategy
Diffstat (limited to '')
| -rw-r--r-- | tiny_skia/Cargo.toml | 5 | ||||
| -rw-r--r-- | tiny_skia/src/backend.rs | 8 | ||||
| -rw-r--r-- | tiny_skia/src/geometry.rs | 1 | ||||
| -rw-r--r-- | tiny_skia/src/text.rs | 8 | 
4 files changed, 20 insertions, 2 deletions
| diff --git a/tiny_skia/Cargo.toml b/tiny_skia/Cargo.toml index a3bddc93..32645ac1 100644 --- a/tiny_skia/Cargo.toml +++ b/tiny_skia/Cargo.toml @@ -12,7 +12,6 @@ geometry = ["iced_graphics/geometry"]  raw-window-handle = "0.5"  softbuffer = "0.2"  tiny-skia = "0.9" -cosmic-text = "0.8"  bytemuck = "1"  rustc-hash = "1.1"  kurbo = "0.9" @@ -23,6 +22,10 @@ version = "0.8"  path = "../graphics"  features = ["tiny-skia"] +[dependencies.cosmic-text] +git = "https://github.com/hecrj/cosmic-text.git" +rev = "ad111a1df10d5da503620f4b841de5d41ebd4e73" +  [dependencies.twox-hash]  version = "1.6"  default-features = false diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index 9c69e1d2..0a06f8c9 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -219,6 +219,7 @@ impl Backend {                  font,                  horizontal_alignment,                  vertical_alignment, +                advanced_shape,              } => {                  let physical_bounds =                      (primitive.bounds() + translation) * scale_factor; @@ -238,6 +239,7 @@ impl Backend {                      *font,                      *horizontal_alignment,                      *vertical_alignment, +                    *advanced_shape,                      pixels,                      clip_mask,                  ); @@ -626,8 +628,10 @@ impl backend::Text for Backend {          size: f32,          font: Font,          bounds: Size, +        advanced_shape: bool,      ) -> (f32, f32) { -        self.text_pipeline.measure(contents, size, font, bounds) +        self.text_pipeline +            .measure(contents, size, font, bounds, advanced_shape)      }      fn hit_test( @@ -638,6 +642,7 @@ impl backend::Text for Backend {          bounds: Size,          point: Point,          nearest_only: bool, +        advanced_shape: bool,      ) -> Option<text::Hit> {          self.text_pipeline.hit_test(              contents, @@ -646,6 +651,7 @@ impl backend::Text for Backend {              bounds,              point,              nearest_only, +            advanced_shape,          )      } diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 508965ad..7cdac1c8 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -114,6 +114,7 @@ impl Frame {              font: text.font,              horizontal_alignment: text.horizontal_alignment,              vertical_alignment: text.vertical_alignment, +            advanced_shape: text.advanced_shape,          });      } diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 1246bbd5..603a3e16 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -49,6 +49,7 @@ impl Pipeline {          font: Font,          horizontal_alignment: alignment::Horizontal,          vertical_alignment: alignment::Vertical, +        advanced_shape: bool,          pixels: &mut tiny_skia::PixmapMut<'_>,          clip_mask: Option<&tiny_skia::Mask>,      ) { @@ -63,6 +64,7 @@ impl Pipeline {              content,              font,              size, +            advanced_shape,          };          let (_, buffer) = self.render_cache.allocate(font_system, key); @@ -130,6 +132,7 @@ impl Pipeline {          size: f32,          font: Font,          bounds: Size, +        advanced_shape: bool,      ) -> (f32, f32) {          let mut measurement_cache = self.measurement_cache.borrow_mut(); @@ -140,6 +143,7 @@ impl Pipeline {                  size,                  font,                  bounds, +                advanced_shape,              },          ); @@ -161,6 +165,7 @@ impl Pipeline {          bounds: Size,          point: Point,          _nearest_only: bool, +        advanced_shape: bool,      ) -> Option<Hit> {          let mut measurement_cache = self.measurement_cache.borrow_mut(); @@ -171,6 +176,7 @@ impl Pipeline {                  size,                  font,                  bounds, +                advanced_shape,              },          ); @@ -390,6 +396,7 @@ impl Cache {                      .family(to_family(key.font.family))                      .weight(to_weight(key.font.weight))                      .stretch(to_stretch(key.font.stretch)), +                !key.advanced_shape,              );              let _ = entry.insert(buffer); @@ -420,6 +427,7 @@ struct Key<'a> {      size: f32,      font: Font,      bounds: Size, +    advanced_shape: bool,  }  type KeyHash = u64; | 
