Question

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

Was it helpful?

Solution 2

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.

OTHER TIPS

You can try the following code:

[UIFont fontWithDescriptor:[UIFontDescriptor fontDescriptorWithName:fontName size:size] size:size];

But don't use the following code:

[UIFont fontWithName:postscriptName size:fontSize]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top