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

glyph-vector/glyph-vector-2 examples do not look at the 3rd order bezier curve bit #58

Open
HinTak opened this issue Apr 29, 2017 · 12 comments

Comments

@HinTak
Copy link
Collaborator

HinTak commented Apr 29, 2017

The examples ignore the 3rd order bezier curve bit and always intepolate between off-curve points. This is strictly speaking only correct for truetype fonts (which only use 2nd order bezier curves). The difference is small but may be important for some glyphs.

Also I think they assume the first point is always on curve. First point being off is less common, but valid.

I'm not going to fix these, but would push a couple of coments in the relevant places.
I just think the examples should do the right thing if somebody want to use a different font or a different glyph, or documented not to do so quite correctly...

(cairo don't have 2nd order curves - it is either line or 3rd order; but a 2nd order curve is just a 3rd order with duplicated off points).

@rougier
Copy link
Owner

rougier commented May 1, 2017

How do you get first point off curve for a cubic Bézier considering the explicit form? You mean given first point doesn't correspond to t=0, right?

@HinTak
Copy link
Collaborator Author

HinTak commented May 1, 2017

A while ago there was a discussion on the Opentype list about this sort of thing. It is legal for a curve to consist of entirely off-curve points. Say 4, at the corner of a square. The rasterizer interpolates them. That was the answer from Microsoft people.

So an implied on-curve point is between the first and the last.

I think it can be even more extreme - a contour can be made from 3 off-curve points. Font designers rarely do it, that's all.

@rougier
Copy link
Owner

rougier commented May 2, 2017

Didn't know that. Do you have a pointer to some documentation such that we can add it in the relevant example (where I'm asking to rephrase). It's not the example is not optimal but it is more a partial implementation.

@rougier
Copy link
Owner

rougier commented May 2, 2017

But freetype outline takes care of normalizing the output, no?
See https://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html)

@rougier
Copy link
Owner

rougier commented May 2, 2017

Ok, no it doesn't, we have to take care of point tags.

@HinTak
Copy link
Collaborator Author

HinTak commented May 2, 2017

You do interpolate most of the time - just afaic, not the first point; and also always split a 3-order curve into two, with an interpolation in the middle. Difference small but for some glyph, might be visible.

@rougier
Copy link
Owner

rougier commented May 2, 2017

So we better implement the full method.

@HinTak
Copy link
Collaborator Author

HinTak commented May 2, 2017

3rd curves only on postscript fonts. 2nd order is sufficient for truetype.

@HinTak
Copy link
Collaborator Author

HinTak commented May 3, 2017

I hope this is shown side by side - left interpolated 2nd order, right true-3rd order:

glyph-vector-2-cairo-interpolated
glyph-vector-2-cairo-real

and again, with the control points,, which make it clearer:

glyph-vector-cairo-s--interpoloated-minionpro-regular otf
glyph-vector-cairo-real

correct answer from ftgrid:
screenshot from 2017-05-02 22-57-41

These are using MinionPro-Regular.otf from adobe acrobat reader.

@HinTak
Copy link
Collaborator Author

HinTak commented May 3, 2017

Hmm, my 'g' is a bit off in the horizonal direction for the MinionPro-Regular.otf

@HinTak
Copy link
Collaborator Author

HinTak commented May 4, 2017

These are the g's from MinionPro-Regular.otf and MinionPro-It.otf, correctly aligned in the horizontal. from
the top of #55 .

glyph-vector-2-cairo-it
glyph-vector-2-cairo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants