Search code examples
iosobjective-ccore-text

CTFontManagerUnregisterGraphicsFont returns true but memory not released


CTFontManagerUnregisterGraphicsFont(cgFont, &fontError) returned true so I expect that:

  1. cgFont be released from memory (The registered font is a Japanese font over 5MB!)
  2. Calling [UIFont fontWithName:postscriptName size:fontSize] afterwards should return nil

But cgFont behaves as though it was not unregistered.

Is this behavior expected? Thanks for your help


Solution

  • Your expectations don't match my understanding of the documentation. The docs say that "Registered fonts are discoverable through font descriptor matching." "Unregistered fonts are no longer discoverable through font descriptor matching." That's all it means.

    When you're done with a CGFont, you should call CGFontRelease(). You should only unregister a font if you also registered it.