This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CTFontManagerRegisterFontsForURLs((__bridge CFArrayRef)((^{ | |
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSURL *resourceURL = [[NSBundle mainBundle] resourceURL]; | |
NSArray *resourceURLs = [fileManager contentsOfDirectoryAtURL:resourceURL includingPropertiesForKeys:nil options:0 error:nil]; | |
return [resourceURLs filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSURL *url, NSDictionary *bindings) { | |
CFStringRef pathExtension = (__bridge CFStringRef)[url pathExtension]; | |
NSArray *allIdentifiers = (__bridge_transfer NSArray *)UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, pathExtension, CFSTR("public.font")); | |
if (![allIdentifiers count]) { | |
return NO; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)pspdf_preloadedImage { | |
CGImageRef image = self.CGImage; | |
// make a bitmap context of a suitable size to draw to, forcing decode | |
size_t width = CGImageGetWidth(image); | |
size_t height = CGImageGetHeight(image); | |
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); | |
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace, | |
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little); |