-
Notifications
You must be signed in to change notification settings - Fork 13
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
More extensive to_kurbo #132
base: fix-eq-lints
Are you sure you want to change the base?
Conversation
323e07f
to
76dfed8
Compare
The ErrorKinds used here are really UFO specification violations. Maybe they can get their own enum later. |
src/glyph/mod.rs
Outdated
_ => return Err(Error::ConvertContour(ErrorKind::TooManyOffCurves)), | ||
}; | ||
offs.clear(); | ||
pub fn to_kurbo(&self) -> Result<Vec<kurbo::PathEl>, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have many of the same comments on this patch as I had on #116, it might be worth reading through those?
6ae4065
to
e86a178
Compare
@cmyr i got the following, converting a QCurve with some off-curves: let c1 = Contour::new(
vec![
ContourPoint::new(0.0, 0.0, PointType::OffCurve, false, None, None, None),
ContourPoint::new(2.0, 2.0, PointType::OffCurve, false, None, None, None),
ContourPoint::new(4.0, 4.0, PointType::OffCurve, false, None, None, None),
ContourPoint::new(100.0, 100.0, PointType::QCurve, false, None, None, None),
],
None,
None,
);
assert_eq!(
c1.to_kurbo().unwrap(),
vec![
kurbo::PathEl::MoveTo((100.0, 100.0).into()),
kurbo::PathEl::QuadTo((0.0, 0.0).into(), (1.0, 1.0).into(),),
kurbo::PathEl::QuadTo((2.0, 2.0).into(), (3.0, 3.0).into(),),
kurbo::PathEl::QuadTo((4.0, 4.0).into(), (100.0, 100.0).into(),),
kurbo::PathEl::ClosePath,
]
); Does the |
cf04b18
to
da3c964
Compare
what's the status of this PR? Are you planning to finish this at some point? |
One day. I think I needed to validate that the decomposer actually does what kurbo expects, i.e. is the code right to put the |
I think that's correct, |
(also whatever fonttools does is as normative (if not more) in UFO world as the ufo spec itself) |
Yes, but I don't know if kurbo wants something different. @cmyr? |
why would kurbo ever want anything different? those conventions for converting between GLIF points to segment-oriented APIs like fonttools pens are well in place since ages and work, I don't see why diverging from them now |
Based on https://github.com/linebender/norad/blob/8c9038b/examples/letterspacer.rs#L523-L680, which is based on the fontTools' point pen to pen adapter pen.
This handles some more corner cases like e.g. converting successive curves without off-curves to lines, and all-off-curve paths.
I'll hold off of implementing this on
Component
andGlyph
until I have a use-case.