Cubic to quadratic conversion when importing vectors

Discuss FontCreator here, please do not post support requests, feature requests, or bug reports!
Post Reply
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Cubic to quadratic conversion when importing vectors

Post by jamadagni »

Hello Erwin (and others). I hope I'm right on the following points:
  • FC only supports quadratic Beziers as they are what are used in the TrueType format.
  • When importing EPS or PDF files, FC converts each cubic Beziers to a pair of quadratic ones.
Could you please then clarify:
  • Is there an importable vector format that can store quadratic Beziers as they are? I'm not sure whether EPS/PDF will store quadratic Beziers as they are both based on postscript i.e. cubic Beziers.
  • If such an importable format exists, would FC correctly diagnose the input material as quadratic Beziers and import it as it is without trying to further break it down?
Basically I find Inkscape much more suitable for vector editing and am trying to find a way of exporting quadratic Beziers and importing them into FC for the final touchup works. What I'm missing from FC's ability to edit (quadratic) Beziers is glyph simplification (importing from cubics via PDF creates way too many nodes) and smooth nodes (incoming control point, node and outgoing control point should be on straight line) etc, So I'd like to know the above points...

P.S.: I should also admit that i have to first convince the Inkscape people to add quadratic Bezier editing mode: see here. Seems that for now I had better settle for cubic to quadratic conversion, but I would still like to hear what you have to say on this. Thank you!
Shriramana Sharma
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9878
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: Cubic to quadratic conversion when importing vectors

Post by Bhikkhu Pesala »

Have you read this thread yet?.

It seems to me that there is no solution to this problem other than learning to use the tools in FontCreator for manipulating curves.

Surely the way to go is to improve the vector tools, e.g. to have some automatic curve smoothing to remove excess points?
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Re: Cubic to quadratic conversion when importing vectors

Post by jamadagni »

Bhikkhu Pesala wrote:Have you read this thread yet?.
It seems to me that there is no solution to this problem other than learning to use the tools in FontCreator for manipulating curves.
Thanks for that link. I completely share the sentiments of that author. And of course the tools in FC already allow for manipulating curves, but I suppose Erwin is working on making them even more feature-rich.

I would certainly like to see a transition from the off-curve on-curve paradigm to the nodes/handles paradigm prevalent in vector editing tools. Of course, the off-curve points already define the handles, but what I mean is I would like to see the handles and be able to manipulate them, such as in making them collinear (for smooth nodes) and stuff.

[Shifting to a node/handle paradigm would however mean one is no longer able to select an off-curve and on-curve points and align/distribute them horizontally or vertically using the relevant commands. However, I cannot see any meaning in aligning an on-curve point with an off-curve one. Perhaps though there is some meaning to aligning off-curve points mutually so as to maintaining a uniform size of handles. Distributing a mixture of on-curve and off-curve points may have a similar use. Perhaps then a mixture of both approaches would be possible. {Obviously, I'm just thinking out aloud in all this.}]
Surely the way to go is to improve the vector tools, e.g. to have some automatic curve smoothing to remove excess points?
FontLab seems to have a smoothing option. Not sure how efficient it is, though.

Basically the way I look at it is like this:

There should be nodes (on-curve points) wherever the tangents to the curves are paraxial. There should be nodes wherever there are inflection points in the curve (because these are second-order Beziers and cannot contain inflections). Apart from that, there should be nodes only when it is absolutely unavoidable for maintaing the proper desired shape of the curve (as in circular/elliptic components).

This would spell for proper economy in terms of points IMO.

BTW, at least in the case of nodes where the tangents are paraxial, I suppose we can already make sure that the curve is smooth by ensuring that the off-curve - on-curve - off-curve points are aligned up vertically or horizontally? (See also remark above.)
Shriramana Sharma
vanisaac
Posts: 337
Joined: Sun Mar 30, 2003 1:33 pm
Location: Washington State, USA

Re: Cubic to quadratic conversion when importing vectors

Post by vanisaac »

The on-curve/off-curve control points are inherent to the true type font format. Cubic bezier splines cannot ever be stored in a true type font. They must be converted. So the node/handle paradigm that you are so used to - and which absolutely baffles me whenever I've tried to use it - is never going to be the way FCP does it in any default capacity. It basically surrenders your control of the outline to an algorithmic approximation.
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Re: Cubic to quadratic conversion when importing vectors

Post by jamadagni »

vanisaac wrote:The on-curve/off-curve control points are inherent to the true type font format. Cubic bezier splines cannot ever be stored in a true type font. They must be converted. So the node/handle paradigm that you are so used to - and which absolutely baffles me whenever I've tried to use it - is never going to be the way FCP does it in any default capacity. It basically surrenders your control of the outline to an algorithmic approximation.
Why do you say so? There is no approximation involved here if handles are provided to edit quadratic Beziers. And as for Cubic beziers, FC already uses approximations (or is it an exact analytic split-down, I'm not sure) to convert imported cubic Beziers to quadratic.

And anyhow, I find it not necessary for FC to provide for handles for helping me smoothen the curves. I realized that in the case of nodes at paraxial tangents, I can simply select the on-curve point with its two off-curve neighbours and align them up vertically or horizontally to achieve the desired result (since the off-curve points are precisely the handles that I am asking for!). And in other cases, I can just place two off-curve points sequentially and they will automatically imply an on-curve point exactly half-way on the straight line connecting them.

All the same, a font-editor's vector editing capabilities cannot match those of a dedicated vector-editing program, so I would still like to have an answer (from Erwin) whether it is possible to import quadratic Beziers into FC as is (without their being re-analysed that is).
Last edited by jamadagni on Wed Jun 06, 2012 5:48 am, edited 1 time in total.
Shriramana Sharma
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Re: Cubic to quadratic conversion when importing vectors

Post by jamadagni »

Bhikkhu Pesala wrote:Have you read this thread yet?.
I have read it now. Thanks. I'm glad others have the same sentiment as I.
It seems to me that there is no solution to this problem other than learning to use the tools in FontCreator for manipulating curves.
Surely the way to go is to improve the vector tools, e.g. to have some automatic curve smoothing to remove excess points?
Yes, this smoothing is very important. As I have posted replying to Van just now, I now think there is no need for providing handles support a la Inkscape and co as the desired functionality can be achieved in other (more efficient?) ways. But since importing third-order curves still generates way too many points, it would be superb if FC could do the simplify function. As the Inkscape code is open-source, maybe Erwin can study the relevant code sections and implement the algorithm here too.
Shriramana Sharma
Erwin Denissen
Moderator
Moderator
Posts: 11159
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: Cubic to quadratic conversion when importing vectors

Post by Erwin Denissen »

A feature to optimise contours in order to reduce the number if required points is in our to-do list. I hope it will make it into FC7.
Erwin Denissen
High-Logic
Proven Font Technology
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Re: Cubic to quadratic conversion when importing vectors

Post by jamadagni »

Erwin Denissen wrote:A feature to optimise contours in order to reduce the number if required points is in our to-do list. I hope it will make it into FC7.
Good. FWIW I'll just recount what I said in a previous post on this thread on which minimal points should be allowed in a contour:
  1. There should be nodes (on-curve points) wherever the tangents to the curves are paraxial (horizontal and vertical extrema of each curve), as per industry standards (if I am not mistaken).
  2. There should be nodes wherever there are inflection points in the curve (because these are second-order Beziers and cannot contain inflections).
  3. Apart from that, there should be nodes only when it is absolutely unavoidable for maintaing the proper desired shape of the curve (as in circular/elliptic components).
Note: Please make it so that the "simplify" tool does not remove but actually adds (if not present) the horizontal and vertical extrema.

Looks like 7.0 is going to be a very features-rich release. Do you have a publicly viewable list of to-do-s?
Shriramana Sharma
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Re: Cubic to quadratic conversion when importing vectors

Post by jamadagni »

I would also appreciate an answer to the question whether it is possible to import quadratic outlines from other applications somehow. But given that FC doesn't support SVG format, it seems difficult since PDF (or EPS, all based on PostScript) only, if this is any indication:
PostScript is noteworthy for implementing on-the fly rasterization; everything, even text, is specified in terms of straight lines and cubic Bézier curves (previously found only in CAD applications), which allows arbitrary scaling, rotating and other transformations.
.
Erwin, comments please?
Shriramana Sharma
William
Top Typographer
Top Typographer
Posts: 2038
Joined: Tue Sep 14, 2004 6:41 pm
Location: Worcestershire, England
Contact:

Re: Cubic to quadratic conversion when importing vectors

Post by William »

jamadagni wrote: Apart from that, there should be nodes only when it is absolutely unavoidable for maintaing the proper desired shape of the curve (as in circular/elliptic components)
I cannot offer a mathematical proof of the matter, yet my understanding of quadratic Bézier curves is that it is, with absolute mathematical precision, impossible to use them to produce a circle or an ellipse.

One can, however, use a number of quadratic Bézier curves joined together to produce an approximation of a circle or an ellipse.

It is a convenient analogy to think of the way that a circle can be approximated using straight lines. Using three straight lines produces a triangle which is very unlike a circle, using four straight lines is not much better, yet once one uses, say, twelve or sixteen straight lines the approximation is better. With a thousand straight lines the approximation would be much better.

It is much the same with using Bézier curves; however, with Bézier curves it is possible to get a much better approximation using a smaller number of items than with straight lines.

Since using Bézier curves joined together to produce an approximation of a circle or an ellipse produces an approximation to a circle or an ellipse rather than an exact mathematical circle or ellipse, there is the matter of deciding how many quadratic Bézier curves to use in making the approximation. I usually use an approximation to a circle that I produced for my Stardisc font in 2007.

viewtopic.php?f=10&t=1717

I have the font installed on the computer that I use, so it is just a matter of opening the font file in FontCreator and copying the glyph for the disc into a new font whenever I need a contour that is a circle. Often I scale the glyph in the new font. That circle has eight quadratic Bézier curves. It is a very regular design with the eight curves being, within the limits of the approximation, each the same size. If I need an ellipse, I scale the circle.

I have tried drawing a few filled circles and ellipses in Serif PagePlus X4 and then using copy and then pasting into FontCreator. The results look alright: close inspection shows mostly curves, of various lengths, with sometimes a very short straight line amongst them.

It is a matter of judgement at the time, by a person or by an automated process, as to how many Bézier curve pieces are needed to approximate to a circle or an ellipse.

William Overington

8 June 2012
Last edited by William on Fri Jun 08, 2012 12:47 pm, edited 1 time in total.
jamadagni
Posts: 71
Joined: Fri Jun 17, 2011 4:10 am
Location: 11 N 78 E

Re: Cubic to quadratic conversion when importing vectors

Post by jamadagni »

William wrote:
jamadagni wrote: Apart from that, there should be nodes only when it is absolutely unavoidable for maintaing the proper desired shape of the curve (as in circular/elliptic components)
I cannot offer a mathematical proof of the matter, yet my understanding of quadratic Bézier curves is that it is, with absolute mathematical precision, impossible to use them to produce a circle or an ellipse.
William thanks for your detailed post. When I say "maintaining the proper desired shape", there is always the disclaimer of course: "as far as possible". :-)
Shriramana Sharma
William
Top Typographer
Top Typographer
Posts: 2038
Joined: Tue Sep 14, 2004 6:41 pm
Location: Worcestershire, England
Contact:

Re: Cubic to quadratic conversion when importing vectors

Post by William »

jamadagni wrote: When I say "maintaining the proper desired shape", there is always the disclaimer of course: "as far as possible". :-)
Indeed. I suppose that another way to look at it would be that in order for someone or a computer program to try to produce a perfect circle using quadratic Bézier curves, that an infinite number of quadratic Bézier curves would be needed: so at some stage a decision needs to be made that the number of quadratic Bézier curves being used is enough for the desired effect.

On a different aspect of this matter of quadratic Bézier curves, I am including here a link to how I used quadratic Bézier curves in producing my Sonnet Calligraphic font. There are two illustrations that will hopefully be of interest.

This is because I thought of a technique of producing a design for a calligraphic curve by starting with straight lines, then converting all of the on-curve nodes to off-curve nodes and then adding an on-curve node half-way between each sequential pair of two of those off-curve nodes. Adding the on-curve node half-way between each sequential pair of two of those off-curve nodes does not alter the shape of the curve, yet does mean that each quadratic Bézier curve is defined from an on-curve point to an on-curve point, with possibly an off-curve point between them.

viewtopic.php?p=13099#p13099

What I really like about those two diagrams is that the design is based mostly on several long thin rectangles, with the change of width from rectangle to rectangle quite dramatic; yet the final result has the continuous calligraphic curve varying in width smoothly from thick to thin then to intermediate width and then back to thin, all as a result of the quadratic Bézier equations.

William Overington

8 June 2012
Post Reply