-
Notifications
You must be signed in to change notification settings - Fork 540
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
Fix the GetKerningPairAdjustments API. #2858
Fix the GetKerningPairAdjustments API. #2858
Conversation
@dotnet-policy-service agree |
I don't understand why the tests are failing. The stuff in the logs doesn't look like stuff that I've broken, so I'm taking this PR out of draft. Again, I made this PR since it seemed a better thing to do than just opening a ticket and hoping someone else would write code for me. But I don't have time to learn what's going on with |
@pdjonov no, thanks for this PR. It looks very good. CI is a bit temperamental and I am still trying to figure out why macos and Android keep failing the first run. Android has additional issue with the emulators not always booting and macOS has random test crashes. But, if the other test platforms all pass then it is highly likely it is just a random failure. Also, the test were all failing before since main had been broken for some time. But it is all fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and the docs.
I looked at the skia source and it seems only the SkTypeface_FreeType
(FreeType-based typefaces) support this feature. This probably means just Linux-based OSes will support this (Linux, Android and WASM)
Do you perhaps have a test for this? Not sure if you have a font that you can use to check some things and then just make sure the values get passed around correctly?
Going to merge this as tests are hard for this scenario and we can add them later. Even skia does not have tests... |
Co-authored-by: Matthew Leibowitz <mattleibow@live.com> (cherry picked from commit 7c5b9ef)
Description of Change
The SkTypeface::getKerningPairAdjustments API states:
However,
SkTypeface.GetKerningPairAdjustments
returnscount
entries and further in the case wheregetKerningPairAdjustments
returns false it may return invalid values to the caller. This PR:Span
-based overload ofGetKerningPairAdjustments
that:glyphs.Length - 1
output entries (but will accept and ignore more),SkTypeface::getKerningPairAdjustments
wrote valid data into the output span,GetKerningPairAdjustments
in terms of the new overload.This patch adds a
HasGetKerningPairAdjustments
that callers can use to query whether the font contains any kerning information or whetherGetKerningPairAdjustments
will always return zeroes.API Changes
Added:
public bool SkTypeface.HasGetKerningPairAdjustments { get; }
public bool GetKerningPairAdjustments (ReadOnlySpan<ushort> glyphs, Span<int> adjustments)
Behavioral Changes
public int[] GetKerningPairAdjustments (ReadOnlySpan<ushort> glyphs)
will now return zeroes in places where it previously returned partial/invalid data that the Skia documentation says to ignore.PR Checklist
Apologies if this isn't quite up to the project standards. I was initially going to just submit a bug report, but then I thought it might be nicer (and likelier to actually get fixed) if I made a quick PR instead of just complaining. I fully acknowledge that I'm not invested enough in this project to learn all of the conventions properly, and I apologize if this wastes anyone's time cleaning up what I've misunderstood. Y'all can do with this patch whatever you will.
I just think it'd be nice if I could be rid of this abomination: