Skip to content

Commit

Permalink
Add API for getting the clip box of a COLR glyph (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV authored Jun 17, 2024
1 parent df952ff commit 6cfe34e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/tables/colr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,21 @@ impl<'a> Table<'a> {
self.get_v1(glyph_id).is_some() || self.get_v0(glyph_id).is_some()
}

/// Returns the clip box for a glyph.
pub fn clip_box(
&self,
glyph_id: GlyphId,
#[cfg(feature = "variable-fonts")] coords: &[NormalizedCoordinate],
) -> Option<ClipBox> {
self.clip_list.find(
glyph_id,
#[cfg(feature = "variable-fonts")]
&self.variation_data(),
#[cfg(feature = "variable-fonts")]
coords,
)
}

// This method should only be called from outside, not from within `colr.rs`.
// From inside, you always should call paint_impl, so that the recursion stack can
// be passed on and any kind of recursion can be prevented.
Expand Down Expand Up @@ -955,11 +970,9 @@ impl<'a> Table<'a> {
#[cfg(feature = "variable-fonts")] coords: &[NormalizedCoordinate],
foreground_color: RgbaColor,
) -> Option<()> {
let clip_box = self.clip_list.find(
let clip_box = self.clip_box(
base.glyph_id,
#[cfg(feature = "variable-fonts")]
&self.variation_data(),
#[cfg(feature = "variable-fonts")]
coords,
);
if let Some(clip_box) = clip_box {
Expand Down

0 comments on commit 6cfe34e

Please sign in to comment.