Bug in Typeface::createSystemTypefaceFor(const void* data, size_t dataSize)

This function is documented as “The system will take its own internal copy of the data, so you can free the block once this method has returned”. And that was indeed the case.

Now, however, on macOS and JUCE 4.3.0 it is no longer true. If I get rid of the original data, the font I create from the typeface doesn’t work. If I refrain from deleting the original data, the font created is fine.

I don’t see exactly where this problem is originating, though.

Same issue here.

In the commit https://github.com/julianstorer/JUCE/commit/76b3689a48941e69858b99996e39fdf7db6f7cfd

this line (in the OSXTypeface constructor) :

CFDataRef cfData = CFDataCreate (kCFAllocatorDefault, (const UInt8*) data, (CFIndex) dataSize);

has been changed to :

CFDataRef cfData = CFDataCreateWithBytesNoCopy (kCFAllocatorDefault, (const UInt8*) data, (CFIndex) dataSize, kCFAllocatorNull);
1 Like

Good catch!

So: will the JUCE devs update the code correctly?

This is fixed on develop now!

1 Like