diff options
Diffstat (limited to 'wgpu')
| -rw-r--r-- | wgpu/Cargo.toml | 2 | ||||
| -rw-r--r-- | wgpu/src/backend.rs | 6 | ||||
| -rw-r--r-- | wgpu/src/geometry.rs | 1 | ||||
| -rw-r--r-- | wgpu/src/layer.rs | 3 | ||||
| -rw-r--r-- | wgpu/src/layer/text.rs | 10 | ||||
| -rw-r--r-- | wgpu/src/text.rs | 7 | 
6 files changed, 27 insertions, 2 deletions
| diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 9f9bd066..254d32d6 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -44,7 +44,7 @@ path = "../graphics"  [dependencies.glyphon]  version = "0.2"  git = "https://github.com/hecrj/glyphon.git" -rev = "1d26d92b19407c5dabe4625944d4a6babbbf0715" +rev = "446cf0803065b52ba5fb9a30fe0addb6d7b5f9d9"  [dependencies.encase]  version = "0.3.0" diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 9772781a..d09b2dba 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -354,8 +354,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( @@ -366,6 +368,7 @@ impl backend::Text for Backend {          bounds: Size,          point: Point,          nearest_only: bool, +        advanced_shape: bool,      ) -> Option<core::text::Hit> {          self.text_pipeline.hit_test(              contents, @@ -374,6 +377,7 @@ impl backend::Text for Backend {              bounds,              point,              nearest_only, +            advanced_shape,          )      } diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 59ec31fe..a85875a4 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -334,6 +334,7 @@ impl Frame {              font: text.font,              horizontal_alignment: text.horizontal_alignment,              vertical_alignment: text.vertical_alignment, +            advanced_shape: text.advanced_shape,          });      } diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index c4723397..7c5b43a3 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -64,6 +64,7 @@ impl<'a> Layer<'a> {                  font: Font::MONOSPACE,                  horizontal_alignment: alignment::Horizontal::Left,                  vertical_alignment: alignment::Vertical::Top, +                advanced_shape: false,              };              overlay.text.push(text); @@ -116,6 +117,7 @@ impl<'a> Layer<'a> {                  font,                  horizontal_alignment,                  vertical_alignment, +                advanced_shape,              } => {                  let layer = &mut layers[current_layer]; @@ -127,6 +129,7 @@ impl<'a> Layer<'a> {                      font: *font,                      horizontal_alignment: *horizontal_alignment,                      vertical_alignment: *vertical_alignment, +                    advanced_shape: *advanced_shape,                  });              }              Primitive::Quad { diff --git a/wgpu/src/layer/text.rs b/wgpu/src/layer/text.rs index fdbdaafb..d36ff273 100644 --- a/wgpu/src/layer/text.rs +++ b/wgpu/src/layer/text.rs @@ -24,4 +24,14 @@ pub struct Text<'a> {      /// The vertical alignment of the [`Text`].      pub vertical_alignment: alignment::Vertical, + +    /// Whether the text needs advanced shaping and font fallback. +    /// +    /// You will need to enable this flag if the text contains a complex +    /// script, the font used needs it, and/or multiple fonts in your system +    /// may be needed to display all of the glyphs. +    /// +    /// Advanced shaping is expensive! You should only enable it when +    /// necessary. +    pub advanced_shape: bool,  } diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index f01e0b42..f433a5b6 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -83,6 +83,7 @@ impl Pipeline {                              height: (section.bounds.height * scale_factor)                                  .ceil(),                          }, +                        advanced_shape: section.advanced_shape,                      },                  ); @@ -213,6 +214,7 @@ impl Pipeline {          size: f32,          font: Font,          bounds: Size, +        advanced_shape: bool,      ) -> (f32, f32) {          let mut measurement_cache = self.measurement_cache.borrow_mut(); @@ -223,6 +225,7 @@ impl Pipeline {                  size,                  font,                  bounds, +                advanced_shape,              },          ); @@ -244,6 +247,7 @@ impl Pipeline {          bounds: Size,          point: Point,          _nearest_only: bool, +        advanced_shape: bool,      ) -> Option<Hit> {          let mut measurement_cache = self.measurement_cache.borrow_mut(); @@ -254,6 +258,7 @@ impl Pipeline {                  size,                  font,                  bounds, +                advanced_shape,              },          ); @@ -364,6 +369,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); @@ -388,6 +394,7 @@ struct Key<'a> {      size: f32,      font: Font,      bounds: Size, +    advanced_shape: bool,  }  type KeyHash = u64; | 
