Open skef opened 5 years ago
@skef I am about to solve all the issues you mentioned (but probably in a new github project as the compatibility with ff2017 will break). However, I fear that I have to ignore No. 10: I already have low level methods that operate with coordinates of points. I have worked on a intermediate level method (operating on a point living in a contour) but realized, that I will not use the intermediate level method in the high level method (operating on the whole contour) because I either had to compute many things again and again (like the length of the contour and on_curve checks) or I have to work with additional arguments (such as the length of the contour) which are actually dependent on other arguments.
@linusromer That's perfectly fine -- this is just the stuff, as I was looking at the code, that I thought might be helpful on one level or another. That particular comment had to do with generality of application, and one can't always make code entirely general.
I just hope the feedback was more helpful than schoolmarmish.
If this winds up being integrated into a FontForge contrib directory there could be more feedback from other quarters. Obviously some folks prefer that any tool applicable to quadratic contours (in this case just harmonize, I think) be made to work with them. (I personally think that's a bit much to ask of contributed work.) Right now anything added to FontForge's contrib winds up in all menus, with no way to remove it, but if these function have their own sub-menu I doubt that would raise much concern. All of this is stuff that has been requested at one point or another.
The documented python hotkeys API is broken because it is superseded by the hotkeys
file mechanism. Have you played around with any hotkeys for your own use? If this does wind up in contrib
we could consider assigning default hotkeys for it.
@skef Your feedback is very helpful and not schoolmarmish at all.
Regarding quadratic bezier splines: The algorithm that I am using for cubic bezier splines reduces to a simple 3-point-average for quadratic bezier splines. Just as in Fontlab, the nodes of quadratic splines will change again, if "harmonize" is executed again (the nodes will tend to the 2-point-average of the neighbour handles). On the other hand, "harmonize handles" has no meaning for quadratic bezier splines. I play with the thought of assigning the 2-point-average of the neighbour handles to "harmonize handles" for quadratic splines (and renaming "harmonize handles" to "harmonize (variant)" ). Tunnify has no meaning for quadratic bezier splines, as the handles are already balanced (so I will not print any warnings for this).
Regarding feedback from other quarters: I opened a thread at typedrawers for harmonize-tunnify-inflection.py which led to some feedback . I will update the thread as soon as I have published the new version. Maybe I should ask there for a suitable menu name and a suitable hotkey. Would you have any favorites? The provisional name of the new version is "Curvatura", because the tools are all related to curvature and "Curvatura" is understandable in many languages but still not as overused as "curvature" yet.
I'm glad it's helpful.
I'm afraid I thought about the toolname question when I wrote that note and didn't come up with anything. ("Marketing" isn't my strong suit.)
With the hot keys obviously you don't want to grab something already taken in the defaults here, and you presumably want to match up the font-level hot keys and the char-level ones. Beyond that I would advise, maybe counter-intuitively, not using a combination that's too convenient, as FontForge might want shorter combos for future use. So I guess the ideal compromise is a set of double-modifier hotkeys not already in use that have some mnemonic relationship to the commands, however tenuous.
@skef I did not get any help at typedrawers on the name "Curvatura". I took the name "Curvatura" and I have published the new version of the plugin at github.com/linusromer/curvatura.
Answers to your comments (same number):
The boolean is_glyph_variant is true iff the point selection in the UI does not matter.
Implemented now in Curvatura.py
.
Implemented now in Curvatura.py
.
Older versions of FontForge had a bug for fontforge.point.type
, which was the only reason I did not use it. Curvatura.py
now uses it.
With Curvatura a path that cannot be adjusted also should not be adjusted. Therefore no error message is printed.
Implemented now in Curvatura.py
.
"Harmonize" and "Harmonize (variant)" both now work in Curvatura.py
for quadratic bezier splines, too.
Implemented now in Curvatura.py
.
Implemented now in Curvatura.py
.
Not implemented (for the reasons mentioned before).
Implemented now in Curvatura.py
.
Implemented now in Curvatura.py
.
If you have any further suggestions on Curvatura.py
, I would be glad to read and implement them!
@skef Regarding the hotkeys: Indeed, I have played with the hotkeys. Many combinations are already taken by default. I used:
CharView.Menu.Tools.Curvatura.Harmonize:Ctrl+Shift+P
CharView.Menu.Tools.Curvatura.Harmonize (variant):Ctrl+Shift+Q
CharView.Menu.Tools.Curvatura.Add points of inflection:Ctrl+Shift+Y
CharView.Menu.Tools.Curvatura.Tunnify (balance):Ctrl+Shift+U
FontView.Menu.Tools.Curvatura.Harmonize:Ctrl+Shift+P
FontView.Menu.Tools.Curvatura.Harmonize (variant):Ctrl+Shift+Q
FontView.Menu.Tools.Curvatura.Add points of inflection:Ctrl+Shift+Y
FontView.Menu.Tools.Curvatura.Tunnify (balance):Ctrl+Shift+U
I thought that "p" and "q" are recognizable as partner. "Y" is just as in "Ynflection" and "U" as in "tUnnify".
(I hope that) I've kicked off a discussion that could lead to this tool being released with FontForge, which right now is the best hope for wide use. (The FontForge ecosystem is pretty centralized at present. Users communicate to get help and share advice but there doesn't seem to be much tool sharing.) The idea would be to add it to the centralized (not per-user) contrib
directory, which means it would be present under the Tools
menu from that release until whenever it is superseded or otherwise removed. So basically part of "Default FontForge".
If and when that happens there will probably be some further change requests. I haven't looked at the new code in depth yet but I'll try to. What I have read looks very good.
This isn't a "real" issue -- I'm using this as a context for some code feedback.
Please keep in mind that while all code feedback winds up sounding like a list of criticisms that's not really what I'm doing here. In particular I'm not listing things that would be required for an eventual integration of the code in to FontForge -- I suspect such a list would be shorter. I'm just making whatever observations might be handy.
First, if you download the zip in https://github.com/fontforge/fontforge/pull/3991#issuecomment-546970598 you'll find a sort of "model" for keeping this sort of code inside a namespace. (Given that this is python I'm sure its only one of many such models). The reason that might interest you is because it would allow your code to be used any of three ways, two of which could be useful. Suppose if at the bottom instead of running
registerMenuItem()
directly you were to put:In that case if your file is loaded as a python module someone could use its functionality in their own script. Then if you put code in place of
[bar]
it would execute when the script is run from the command line. And finally if you put code in place offoo
it would run when loaded via the python config directory.Code comments:
None
in place ofare_contours_selected
should have the same effect -- when there is noenable_function
the option should always be enabled....,"Harmonize");
,...,"Harmonize handles");
etc. you could have...,"Your tool name", "Harmonize");
,...,"Your tool name", "Harmonize handles");
etc.fontforge.point.type
field. Given how it works that may be fine, but I would recommend considering a looser test inon_same_line
for smooth points (rounding can result in a larger angle divergence than .05). (Also -- and this is really picky -- given that trig functions are expensive why not base this criterion on the cross product divergence as inside
?)selected
field works for these points as of a recent release.)c.closed
. The data structure will normally save you here, but someone could add two off-curve points to the end of an open contour and you could wind up with a false positive.Those are my thoughts for the time being.