Skip to content

Commit

Permalink
Add Cluster::style getter
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Burns <nico@nicoburns.com>
  • Loading branch information
nicoburns committed Jan 31, 2025
1 parent 13fd37b commit 21afd6b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parley/src/layout/cluster.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 the Parley Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use super::{BreakReason, Brush, Cluster, ClusterInfo, Glyph, Layout, Line, Range, Run};
use super::{BreakReason, Brush, Cluster, ClusterInfo, Glyph, Layout, Line, Range, Run, Style};
use swash::text::cluster::Whitespace;

/// Defines the visual side of the cluster for hit testing.
Expand Down Expand Up @@ -101,6 +101,11 @@ impl<'a, B: Brush> Cluster<'a, B> {
self.data.text_range(self.run.data)
}

/// Returns the style that applies to the cluster.
pub fn style(&self) -> &Style<B> {
&self.run.layout.styles()[usize::from(self.data.style_index)]
}

/// Returns the advance of the cluster.
pub fn advance(&self) -> f32 {
self.data.advance
Expand Down

0 comments on commit 21afd6b

Please sign in to comment.