register&unregister download font error
There is a download custom font.ttf.
I register like this.
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:fontPath];
CFErrorRef error = nil;
BOOL _y = CTFontManagerRegisterFontsForURL(url,kCTFontManagerScopeProcess,&error);
if (!_y && error) {
//_y is YES and error is nil.
}
Now I do:
[UIFontfontWithName:@"Custom font name"size:14]
Then I unregister it:
CFURLRef url = (__bridgeCFURLRef)[NSURLfileURLWithPath:p];
CFErrorRef error = nil;
BOOL _y = CTFontManagerUnregisterFontsForURL(url, kCTFontManagerScopeProcess, &error);
if (!_y && error) {
//_y is YES and error is nil.
}
Now I do:
//It's always return UIFont instance
[UIFontfontWithName:@"Custom font name"size:14]
//but when I change size how much I don't use before, It's return nil
[UIFontfontWithName:@"Custom font name"size:15]
Is there cache for UIFont at OS level?
If I want update font.ttf at runtime, how to go?
Here is the effect I want:
//Before I register font, return nil
NSLog(@"%d",[UIFontfontWithName:@"Custom font name"size:14]==nil)
print:1
//When I register font, return font instance.
NSLog(@"%d",[UIFontfontWithName:@"Custom font name"size:14]==nil)
NSLog(@"%p",[UIFontfontWithName:@"Custom font name"size:14])
print:0
print:0x...
//so I can update .ttf at runtime.
//I unregister old one and register new .ttf
//I wan't get new UIFont instance without change size
//!!! Now got instance is old.
NSLog(@"%p",[UIFontfontWithName:@"Custom font name"size:14])
print:same as before!!!
//So I don't use new change from new .ttf.
Is there everybody can help me?