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

Hold on to data used for FT_New_Memory_Face until after FT_Done_Face is called. #19

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

ChrisLoer
Copy link
Collaborator

FreeType documentation for FT_New_Memory_face at https://freetype.org/freetype2/docs/reference/ft2-base_interface.html specifies "You must not deallocate the memory before calling FT_Done_Face", but it looks like we pass it a pointer to the contents of a vector that goes out of scope. This change just does a simple char* malloc and holds onto it until free_fontstack.

I came across this while debugging missing/corrupted glyphs showing up in a large set of SDFs. To my surprise, the missing glyphs showed up when I ran font-maker a second time with the same inputs, and then when I put some debugging code in to capture the set of glyphs, I found that the set of glyphs changed from one run to the next.

Looking at the code, I saw this, it looked suspicious, and when I changed it the set of glyphs started being reproducible between runs. I haven't done much else to verify the change (didn't actually observe memory corruption in the debugger or anything), but it seems pretty straightforward, at least if I'm reading the docs right.

@bdon

@bdon bdon merged commit 2584db2 into maplibre:main Feb 16, 2023
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.

2 participants