Hi, folks.
The docs for createSystemTypefaceFor say:
/** Attempts to create a font from some raw font file data (e.g. a TTF or OTF file image).
The system will take its own internal copy of the data, so you can free the block once
this method has returned.
The typeface will remain registered with the system for as long as there is at least one
owner of the returned Ptr. This allows typefaces registered with createSystemTypefaceFor to
be created using just a typeface family name, e.g. in font fallback lists.
*/
However, on Windows, typefaces allocated this way may be leaking. If I give my plugin editor a Font member and initialize it using FontOptions with a typeface returned from this method, I think the typeface might not be properly cleaned up when the editor is closed its Font member is destroyed.
Hereās a minimal plugin example which has this problem. Itās essentially the audio plugin example, but it loads a font from BinaryData.
Loading this in Reaper and repeatedly opening and closing its editor, Visual Studioās heap snapshots, taken while the editor is closed, show typeface-related objects accumulating on the heap:
Iām testing with the current tip of the develop branch (e26c69e7bf35c9c800ac826c74d258d5fbafd1eb).
Thanks for taking a look!




