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

New check: intersecting and/or duplicate contours #4854

Open
rimas-kudelis opened this issue Oct 9, 2024 · 3 comments
Open

New check: intersecting and/or duplicate contours #4854

rimas-kudelis opened this issue Oct 9, 2024 · 3 comments
Labels
New check proposal We expect new check proposals to include a detailed rationale description and a suggested check-id

Comments

@rimas-kudelis
Copy link
Contributor

rimas-kudelis commented Oct 9, 2024

What needs to be checked?

Intersecting and/or duplicate contours or contour parts in font glyphs.

Detailed description of the problem

One of MS Font Validator's checks that I think I'm missing in FontBakery is that of intersecting contours (error code E1111). While sometimes intersections are okay and intended, that check also helps find cases of mistakenly duplicated contours in fonts.

For example, here I have a glyph where the second contour (original letter z) is a subset of the first contour (letter z with the retroflex hook). The smaller contour was likely pasted from another glyph before the designer drew the new glyph on top, but was then simply forgotten. All it does there is occupies extra bytes at the very minimum.

It would be nice if FontBakery could warn about such cases.

Again, while Font Validator reported even things like lines that barely touched, I find that less useful than if it reported matching vectors/parts of contours/contours.

Resources and steps needed to reproduce the problem

Could the glyph file above serve as a test?

Suggested profile

Universal (broadly accepted best practices on the type design community)

Suggested result

⚠️ WARN (A potential issue that may need to be addressed)

Severity assessment

2

@rimas-kudelis rimas-kudelis added the New check proposal We expect new check proposals to include a detailed rationale description and a suggested check-id label Oct 9, 2024
@rimas-kudelis
Copy link
Contributor Author

Quoting the relevant FontValidator help file below:

glyf: Intersecting contours

The glyph indicated in the validation log contains contours that intersect with themselves (overlap) or other contours of the glyph shape. These intersections may cause the rasterizer to unpredictably fill the glyph shape. The different type of intersections are discussed below.

Self-intersecting contours
This type of intersection may take the form of a tiny loop on one of the contours of the glyph and results from a poorly controlled Bezier curve becoming undesirably deformed. This self-intersection can be very hard to see, even at high magnification. Other types of self-intersection occur when a straight line doubles back on itself, and when a single contour loops around and touches itself. To fix these problems, use an outline editing tool to shift the problematic control points or alter the type of curve used.

 

 

 

Multi-contour intersection
Contours located very near each other may be separate at some sizes but may intersect at other sizes due to scaling and gridfitting. This problem may be fixed by using an outline editing tool to move control points and make the contours more distant.

 

For more information, see the glyf table specification.

@rimas-kudelis
Copy link
Contributor Author

I just noticed that "intersecting contours" and "duplicated contours" are two distinct checks in FontValidator. Somehow this slipped my mind previously. Here's the contents of the help file for "Duplicated contours" (E1120):

glyf: Duplicated contours

The glyph indicated in the validation log contains duplicate contours. A portion of the glyph outline has a duplicated and overlapping contour. In the diagram on the left, two outlines are pasted on top of each other (note the overlapped point numbers); in the enlarged diagram on the right, the two outlines are separated.

 

Depending on the outline editing tool used, the duplicate contour may be difficult to see. The unnecessary outline may have appeared as the result of an inadvertant cut-an-paste action while editing the glyph outline.

Remove the duplicate contour carefully. Since redundant points will be removed, remaining points will be renumbered. If the font is already hinted and controlled points are removed or renumbered, hinting information may become invalid. In addition, glyph components of composite glyphs may end up attached to an incorrect location on the glyph outline.

For more information, see the glyf table specification.

@HinTak
Copy link

HinTak commented Oct 15, 2024

FWIW, I believe there is some sort of fontforge-based intersecting/duplicate contour check, tioo. And I have written more than a few times, both publicly and specifically to @davelab6 and google folks since 2015, the glyf/contour related checks in FontVal consists of more than 10% of its code base, and is perhaps the most valuable part of it.

BTW, development or FontVal has moved to
https://github.com/FontVal-extras/FontVal-RX and its parent org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New check proposal We expect new check proposals to include a detailed rationale description and a suggested check-id
Projects
None yet
Development

No branches or pull requests

2 participants