Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for getting the clip box of a COLR glyph #154

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading