Skip to content

Commit

Permalink
Face::set_variation allows duplicated axes now.
Browse files Browse the repository at this point in the history
  • Loading branch information
RazrFalcon committed Oct 13, 2023
1 parent 4350154 commit 037ae4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- `svg::SvgDocumentsList` returns `svg::SvgDocument` and not just `&[u8]` now.
Thanks to [wjian23](https://github.com/wjian23).
- `Face::set_variation` allows duplicated axes now.

## [0.19.2] - 2023-09-13
### Added
Expand Down
19 changes: 7 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2098,21 +2098,16 @@ impl<'a> Face<'a> {
return None;
}

let v = self
.variation_axes()
.into_iter()
.enumerate()
.find(|(_, a)| a.tag == axis);
if let Some((idx, a)) = v {
if idx >= MAX_VAR_COORDS {
return None;
}

self.coordinates.data[idx] = a.normalized_value(value);
} else {
if usize::from(self.variation_axes().len()) >= MAX_VAR_COORDS {
return None;
}

for (i, var_axis) in self.variation_axes().into_iter().enumerate() {
if var_axis.tag == axis {
self.coordinates.data[i] = var_axis.normalized_value(value);
}
}

// TODO: optimize
if let Some(avar) = self.tables.avar {
// Ignore error.
Expand Down

0 comments on commit 037ae4c

Please sign in to comment.