cu2qu icon indicating copy to clipboard operation
cu2qu copied to clipboard

Automatically elevate lines to flat curves on incompatibilities (with warning)

Open jamesgk opened this issue 8 years ago • 12 comments

It seems it's not uncommon for masters to have a few segments which are incompatible simply because one master's is a curve and another's is a line. In those cases, we can simply promote the line to a flat curve and continue conversion.

jamesgk avatar Oct 20 '16 19:10 jamesgk

FWIW fontMath does this

adrientetar avatar Oct 20 '16 19:10 adrientetar

Just looked at the code, the way I interprete it, the off-curve controls are positioned exactly where the on-curve controls are, i.e.:

contourPoints.append((None, prevPt, False, None, None))
contourPoints.append((None, pt, False, None, None))

I think I remember this being told to be a bad practice, for designers, because there's no direction for the controls then. Designers should use a tiny offset to the closest on-curve point, to hint the renderer.

Do you have any thoughts about this? Should designers position off curve points directly on the closest on-curve point, or just a bit into the "right" direction? Are there rendering problems with this practice of making on- and off-curve the equal position?

graphicore avatar Oct 20 '16 22:10 graphicore

Oh, and, I totally think it is cool to make curves out of lines to make interpolation more compatible :-)

graphicore avatar Oct 20 '16 22:10 graphicore

there's no direction for the controls

What do you mean by that? I didn't understand.

adrientetar avatar Oct 20 '16 23:10 adrientetar

I think direction for controls is referring to the directions of the vectors from p0 to p1 and p3 to p2. And I actually don't think there needs to be a direction, since apparently it's not uncommon to see cubic curves in original sources where p0==p1 and p2==p3. It's probably worth mentioning that we can specially handle this case in cu2qu just by turning the curve into a line.

jamesgk avatar Oct 24 '16 19:10 jamesgk

Yea. idk if cu2qu should do this thing I mean it's just a curve converter. Then again it already has a focus on compatibility.

adrientetar avatar Oct 24 '16 20:10 adrientetar

cc @twardoch who brought this up with us separately.

jamesgk avatar Oct 24 '16 20:10 jamesgk

@adrientetar sorry, I missed your question.

there's no direction for the controls

What do you mean by that?

Yes, this:

I think direction for controls is referring to the directions of the vectors from p0 to p1 and p3 to p2.

About this:

it's not uncommon to see cubic curves in original sources where p0==p1 and p2==p3.

That doesn't mean it's good practice either. But, probably it's not that important anyways, I thought it may have something to do with rasterization or so.

graphicore avatar Oct 24 '16 20:10 graphicore

Gimme some time to comment here please. Don't merge anything just yet.

behdad avatar Oct 26 '16 08:10 behdad

Gimme some time to comment here please.

any news on this front? It seems sensible to have this upgrade-line-to-curve feature, even if only as an option.

anthrotype avatar Jan 23 '17 18:01 anthrotype

I've ran into this as well. I don't mind requiring the outlines to be fixed manually. For me the biggest annoyance is that fonts_to_quadratic() stops with a traceback as soon as it runs into the first incompatible glyph. I wish that it skipped such glyphs instead and provided a report at the end.

miguelsousa avatar Feb 16 '17 00:02 miguelsousa

Ok, here's the problem: for a line p0..p1, what curve do you elevate it to? There is one correct solution indeed, but that's not what many people in this thread expect.

The one correct solution to elevate line to quadratic is p0,(p0+p1)/2.,p1. And correct solution to elevate line to cubic is p0,(2p0+p1)/3.,(p0+2p1)/3,p1. Those are the only curves that match the line t for t. That's important for interpolation. However, the one correct solution is NOT that useful for design work. If you just put the control points on top of the end points, you get different interpolation results. But that's, many times, the intended behavior. In fact, there's infinitely many ways to promote line to curve and only one of them matches the designer's intent. So I'm against automatically doing this.

Does that make sense?

behdad avatar Mar 22 '17 22:03 behdad