61 lines
1.8 KiB
Objective-C
61 lines
1.8 KiB
Objective-C
//
|
|
// MFFonts.m
|
|
// myverizon
|
|
//
|
|
// Created by Scott Pfeil on 11/17/14.
|
|
// Copyright (c) 2014 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
#import "MFFonts.h"
|
|
#import <CoreText/CoreText.h>
|
|
#import "MVMCoreUIUtility.h"
|
|
#import <MVMCore/MVMCoreLoggingHandler.h>
|
|
|
|
@implementation MFFonts
|
|
|
|
+ (void)loadFont:(NSString *)fontName type:(NSString *)type{
|
|
|
|
NSString *fontPath = [[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:fontName ofType:type];
|
|
NSData *inData = [NSData dataWithContentsOfFile:fontPath];
|
|
CFErrorRef error;
|
|
CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)inData);
|
|
[UIFont familyNames];//fixing weird app freeze after launch app issue
|
|
CGFontRef font = CGFontCreateWithDataProvider(provider);
|
|
if (!CTFontManagerRegisterGraphicsFont(font, &error)) {
|
|
CFStringRef errorDescription = CFErrorCopyDescription(error);
|
|
MVMCoreLog(@"Failed to load font: %@", errorDescription);
|
|
CFRelease(errorDescription);
|
|
}
|
|
CFRelease(font);
|
|
CFRelease(provider);
|
|
}
|
|
|
|
+ (nullable UIFont *)mfFont75Bd:(CGFloat)size {
|
|
NSString *fontName = @"NHaasGroteskDSStd-75Bd";
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
[MFFonts loadFont:fontName type:@"otf"];
|
|
});
|
|
return [UIFont fontWithName:fontName size:size];
|
|
}
|
|
|
|
+ (nullable UIFont *)mfFont55Rg:(CGFloat)size {
|
|
NSString *fontName = @"NHaasGroteskDSStd-55Rg";
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
[MFFonts loadFont:fontName type:@"otf"];
|
|
});
|
|
return [UIFont fontWithName:fontName size:size];
|
|
}
|
|
|
|
+ (nullable UIFont *)mfFontOcratxt:(CGFloat)size {
|
|
NSString *fontName = @"OCRAExtended";
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
[MFFonts loadFont:fontName type:@"ttf"];
|
|
});
|
|
return [UIFont fontWithName:fontName size:size];
|
|
}
|
|
|
|
@end
|