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

Fix potential CoreText font rendering infinite recursion #985

Merged
merged 1 commit into from Nov 4, 2019

Conversation

@ychin
Copy link
Member

ychin commented Nov 4, 2019

The function recurseDraw is actually a misnomer. It uses recursion in a way that is unnecessary as it's a simple while loop that keeps drawing as many characters as possible until all are drawn. The recursion is just a convenience to invoke the CoreText rendering code. If the API for CTFontGetGlyphsForCharacters works as expected, in theory we shouldn't get infinite recursion since lookupFont calls the same function, but just for safety and to avoid potential subtle interactions with the API, just kill the recursion and directly draw the texts in the loop to make it easier to reason through.

Fix #983.

The function `recurseDraw` is actually a misnomer. It uses recursion in
a way that is unnecessary as it's a simple while loop that keeps drawing
as many characters as possible until all are drawn. The recursion is
just a convenience to invoke the CoreText rendering code. If the API for
`CTFontGetGlyphsForCharacters` works as expected, in theory we shouldn't
get infinite recursion since `lookupFont` calls the same function, but
just for safety and to avoid potential subtle interactions, just kill
the recursion and directly draw the texts in the loop to make it easier
to reason through.

Fix #983.
@ychin ychin force-pushed the ychin:fix-recurse-draw branch from 4237cc8 to 61c8fa4 Nov 4, 2019
@ychin ychin merged commit 9823bad into macvim-dev:master Nov 4, 2019
1 check passed
1 check passed
Travis CI - Pull Request Build Passed
Details
@ychin ychin deleted the ychin:fix-recurse-draw branch Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.