-
Notifications
You must be signed in to change notification settings - Fork 681
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
How to keep all control points when assigning layer to glyph? #5418
Comments
I was able to keep the control points by changing fontforge/fontforge/splineutil.c Line 166 in cce02b1
from fontforge/fontforge/splinerefigure.c Lines 57 to 58 in cce02b1
@skef You last modified the two lines in splinerefigure.c, so you may have some background on this. |
The changes you're suggesting are large and fundamental and absolutely not motivated by your small use case, which I assume has to do with using FontForge for variable font development, something it's likely never going to be really designed for. If you want to approach this problem in a way that has any likelihood of being accepted, you'll probably need to add a flag/mode to setLayer that means something like "trust me completely" and then implement the code to read in the Python layer object so that nothing changes. Given that you can't use the normal spline code such as SplineRemake3, that would be a not huge but still significant project. |
In any case, the changes to management of nonextcp and noprevcp did not really have to do with RealNear, they addressed longstanding problems where one of the two would wind up being set to True and the other to False, and then you would have a Cubic spline with one control point, which is self-contradictory and would confuse all sorts of algorithms both inside and outside FontForge. The solution to that was to make the control point positions themselves the source of the values of those booleans. The direction you want to head would amount to removing support for lines from the cubic mode of FontForge. That's not going to happen. So the code would wind up needing to manage nonextcp and noprevcp separately again, and all those bugs that were resolved by that commit would come back. It might simply be the case that FontForge isn't the right tool for the specific kind of font development you wish to pursue. |
Let me approach this from a different perspective: Why specifically are you trying to solve this problem, instead of dealing with the issue at a different point in your development "stack"? Over time I've looked at a number of variable font development platforms and what they generally worry about is whether there are the same number of splines on each corresponding contour, not the same number of points. Why can't the code that integrates your design instances (or "masters") say "oh, this is a line but this is a cubic, so I'll just convert the line into a cubic to match"? If the answer is something like "then I can't use FontForge's interpolation code to preview a master", maybe that's what you should be looking to improve. One could, for example, either modify the interpolation code to be tolerant of the spline/line problem generally, or add a flag that makes it tolerant that way. And that could be beneficial to users in other situations. |
First of all, thank you for taking the time to provide a thorough explanation and outline possible solution approaches.
OK, that's what I was afraid of.
I'm using
While this would be possible, the control points of a cubic representing a line are only constrained to lie on the line segment.
Since I'm utilizing
Of the different solutions you mentioned, implementing a separate mode seems to me to be the most promising. The routine should not make any changes to the geometry, it should just do some checks (e.g. if the number of control points is correct for the layer type). Do you have a preference for the interface? Some ideas:
both instead of g.layers[1] = l whose behavior would not change. |
That may be true but it's beside the point of our discussion, because (as far as I recall) splineRefigure3 and the other conversion code doesn't coerce cubic splines with merely colinear points into lines. The only condition FontForge is giving you trouble with is a spline where both control points are co-located with their associated on-curve points. And therefore if you have a line (or a degenerate "line" with both on-curve points co-located) in one case and a spline in another you know where the control points "are": they're co-located with their on-curve points. So there's no ambiguity in practice. The point isn't to special-case all cubic "lines", it's to special-case the case you're actually having trouble with. I still think you would be better off putting some layer between FontForge and fontmake to do this for you rather than mucking around in FontForge code. And I'm not going to guarantee in advance that a PR along the lines you image will be accepted. But I won't stop you outright. Anyway, stop uisng |
Looked into
So if you're building a CFF-based font it calls
So that takes all the masters of a glyph and is intended to provide an opportunity to make changes. So all you would need here is something to read through the glyphs spline by spline (rather than point by point) and add the control points back if necessary (i.e. if some of the splines in other masters are cubics). You can limit this to when all the points on the spline are colocated if you like, or provide whatever limitation you find to be appropriate, so that other conditions will continue to error out on the compatibility check. Then you pass that filter as a parameter to fontmake and you've solved your problem. |
I was able to implement a filter that does exactly what I want. I was not aware of the possibility of using filters in If anyone comes across this issue in the future: |
FontForge seems to remove control points between on-curve points that have the same coordinates when assigning a layer to a glyph.
Is there a way to disable the removal of these points?
Steps to reproduce
A simplified example showing this behavior:
Actual behavior
Expected behavior
FontForge version and OS
FontForge: 20230101 git:cce02b132c698b4568e7823abdd2f1b3daa32b5e
Ubuntu 22.04.4 LTS
Why this is a problem
I'm trying to create a variable font based on @ctrlcctrlv's tutorial. One of the properties that should be variable is the radius of the corners.
If the radius is greater than 0, the control points are obviously needed. If it is 0, there are two on-curve points at the corner (which is correct), but the two control points between them must be present for interpolation.
The text was updated successfully, but these errors were encountered: