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

ApproximateSplineFromPointsSlopesAccurate #4567

Merged
merged 7 commits into from
Jan 21, 2021
Merged

Conversation

linusromer
Copy link
Contributor

@linusromer linusromer commented Jan 10, 2021

Added an additional function ApproximateSplineFromPointsSlopesAccurate() in splinefit.c which has a boolean at the end. When the boolean is false, it behaves as before but if the boolean is true, it supplies a more accurate (but slower) approximation. The "Merge" function which lives inside splineutil2.c now uses the more accurate version. "Expand stroke" and "Simplify" do still use the original function.

Closes #4552

Added an additional function ApproximateSplineFromPointsSlopesAccurate() in splinefit.c which has a boolean at the end. When the boolean is false, it behaves as before but if the boolean is true, it supplies a more accurate (but slower) approximation. The "Merge" function which lives inside splineutil2.c now uses the more accurate version. "Expand stroke" and "Simplify" do still use the original function.
fontforge/splinefit.c Outdated Show resolved Hide resolved
fontforge/splinefit.c Outdated Show resolved Hide resolved
@skef
Copy link
Contributor

skef commented Jan 12, 2021

If the big block gets restored to its old indentation I will approve this. I'll leave other stylistic choices to the discretion of the submitter and other reviewers (if any).

Someone might quibble with adding Accurate to the function name as, well, not quite accurate: the resulting function is either accurate or not depending on the boolean. The usual FontForge convention of a leading underscore for the enhanced function isn't awesome either, but it's easy and (presumably?) sufficient.

@ctrlcctrlv
Copy link
Member

@skef, I actually think in this case the spacing might not need to be reverted.

Clearly this function was entirely changed by the commit, and it is unlikely that any bugs that arise from this would not be blamed on this commit.

Furthermore, if it is found that the bugs go older than that, I don't think it's that big a deal to go back one commit because of the already mentioned fact that this commit changes entirely the behavior of the function.

I don't know if that's enough to sway you, but I would be happy to merge this now if it is. It is an obviously useful feature to have a better merge.

@ctrlcctrlv
Copy link
Member

I would also say that because the entire function was reviewed by @linusromer and significantly changed, that it would be worse to have some of it spaced one way and some of it spaced another. If it was not such a large overhaul to the function I would have a different opinion.

@skef
Copy link
Contributor

skef commented Jan 14, 2021

@ctrlcctrlv I don't agree that the function is "entirely changed" by the commit. There's an added section that corresponds to the new boolean. The only change to the rest of the function (as far as I can tell from verifying a fraction of them) is the indentation. That indentation change obscures that the rest of the function was syntactically unmodified by the commit.

@ctrlcctrlv
Copy link
Member

Yeah but how could adding extra indentation be avoided? There's a new else block so some kind of new indentation is needed isn't it? And indentation that sticks the way we usually do things would still create changed lines wouldn't it?

@skef
Copy link
Contributor

skef commented Jan 14, 2021

Although it would be difficult to pick out specific PRs at this point, I take myself to be following a review convention I and other contributors have been informed of in similar cases. In general modifying very large blocks of existing code only for indentation has been discouraged.

Maybe @frank-trampe can weigh in on whether this is still relevant.

Yeah but how could adding extra indentation be avoided? There's a new else block so some kind of new indentation is needed isn't it?

It's C -- you avoid the extra indentation by not adding it. The project certainly doesn't use a style checker. The /* original and fast function */ comment would make it quite clear what's going on.

@ctrlcctrlv
Copy link
Member

I don't know Skef. I don't think that we have ever required someone to not add indentation that they otherwise should have.

I agree, @frank-trampe or @jtanx should weigh in.

I think not adding the indentation would harm the readability of the function and that that matters more than the blame.

the generalized function is now named with a underscore prefix.
the indention is as required by skef.
the spaces of "( is_accurate )" are now gone.
@skef skef self-requested a review January 17, 2021 23:43
@skef
Copy link
Contributor

skef commented Jan 18, 2021

@linusromer GW's indentation style (still used in most of the files) is idiosyncratic and a pain to reproduce. I followed through on your intention in a different way and added a commit to your repository. Make sure you pull it down before editing any further (if you do).

(If this is surprising, there's a little checkbox at submit time that gives project reviewers write access to the source branch of a PR and it's checked by default. Just a handy github thing.)

Since the latest commit is mine I'll let you sign off on it before approving but the current code looks good to me. (The windows build failure looks unrelated but I'll follow up on that.)

@skef
Copy link
Contributor

skef commented Jan 18, 2021

@jtanx Looks like the windows build is unhappy -- the last few commits on this have failed to build for windows in a way that doesn't seem tied to the source changes.

@frank-trampe
Copy link
Contributor

Sorry for my silence on the indentation issue. @skef was on point, and I missed the subsequent ping. It seems to be resolved.

@linusromer
Copy link
Contributor Author

linusromer commented Jan 18, 2021

@skef I am okay with your commit on github.com/linusromer/fontforge

Since the latest commit is mine I'll let you sign off on it before approving but the current code looks good to me.

Is this comment already enough for "sign off" or do I have to do something else?

Copy link
Contributor

@skef skef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Unless someone swoops in I'll merge in a day or two.

new parameter to the existing function and change the
other calls.
@skef
Copy link
Contributor

skef commented Jan 19, 2021

After thinking about this I could hear @jtanx asking "Are there really enough existing calls that we need to add a new signature?" It turns out that there are only 5 so the answer is "no". I added a commit to go back to a single function and change those existing calls so I'll sit on this another day before merging.

@skef skef merged commit 35f4d38 into fontforge:master Jan 21, 2021
Omnikron13 pushed a commit to Omnikron13/fontforge that referenced this pull request May 31, 2022
Adds a boolean parameter to ApproximateSplineFromPointsSlopes(). When the boolean is false it behaves as before but if the boolean is true the function uses a more accurate (but slower) method of calculation. The "Merge" function which lives inside splineutil2.c now uses the new algorithm while Simplify and Expand Stroke use the original one.

Authored by Linus Romer
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

Successfully merging this pull request may close these issues.

Make Merge/splinefit/ApproximateSplineFromPoints* more accurate
4 participants