-
Notifications
You must be signed in to change notification settings - Fork 17
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
mathKerning is wrong in many ways #22
Comments
Yikes. It shouldn't be that way.
Hm. I'll look into it when I have time to think through that logic again. Test cases would be really helpful if you can post some here. |
This one is easy to fix. I'll give it a try later this week.
I also want to give it a try fixing. Will keep you posted. [Erik says hi as well!] |
I pulled the value finding code from MetricsMachine and add it as an example algorithm to the UFO 3 spec. Look at the "Kerning Value Lookup Algorithm" here. I've been thinking about making (a slightly more efficient version of) this code available in a central location for years. I think ufoLib is the best candidate. I don't think this would create a dependency loop because ufoLib relies on any modules that would need this. fontMath has an existing ufoLib dependency so that wouldn't be an issue. If you'd like, I can do this tonight or tomorrow. |
@behdad I'm looking into this issue, but I'm not able to reproduce it. Here is my test code: from fontMath.mathKerning import MathKerning
groups = {
"public.kern1.A" : ["A", "A.alt"],
"public.kern2.O" : ["O", "O.alt"]
}
kerning1 = {
("public.kern1.A", "public.kern2.O") : 100
}
kerning2 = {
("public.kern1.A", "public.kern2.O") : 200
}
kerning1 = MathKerning(kerning1, groups)
kerning2 = MathKerning(kerning2, groups)
kerning3 = kerning1 + kerning2
print kerning3["A.alt", "O.alt"] This gives me the expected value I see a reference to a predefined value of Was the error somewhere else? |
Ok, my bad. The first issue does not exist. I didn't note that the code is using "self.get()" which properly does fallback. So, the only issue outstanding is the fact that if the two sides have different groups, then they are merged wrongly as far as I see. I'll send a PR to add test for the first issue. |
As discussed in: robotools#22
@behdad should this be closed? |
No, I think the following is still outstanding: if the two sides have different groups, then they are merged wrongly as far as I see. |
Fontmath Kerning really needs all participants to have the same groups.
Erik
… On 2 Feb 2018, at 21:38, Behdad Esfahbod ***@***.***> wrote:
@behdad should this be closed?
No, I think the following is still outstanding: if the two sides have different groups, then they are merged wrongly as far as I see.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Perhaps this should be the fix for this issue. I just reviewed the code and it's much simpler than I remembered. It simply combines them without any checking for conflicts. I vaguely remember trying to solve this about 15 years ago in v0.001a1 but I probably got lost in the edge cases. If someone wants to take a shot at the statistical work on algorithmically resolving group conflicts, go for it. Otherwise, I think we should add something like this to the start of g1 = self.groups()
g2 = other.groups()
if g1 != g2:
raise SomeKindOfError("Kerning groups must be exactly the same.") |
Yes, error would work. |
I just found that in fontMath/Lib/fontMath/mathKerning.py Lines 229 to 232 in b79e82b
MathKerning.round() changes the instance's data instead of returning a rounded copy like MathGlyph and MathInfo. Is this intentional?
|
All in _processMathOne(). Two major issues I see:
The text was updated successfully, but these errors were encountered: