KeyTextColor constant for MFLabel and core ui Checker for hasText on MFLabel update molecule protocol for mf label. separator use molecule protocol fix to header
62 lines
1.9 KiB
Objective-C
62 lines
1.9 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;
|
|
|
|
@implementation MFFonts
|
|
|
|
+ (void)loadMVMFonts {
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
[MFFonts loadFont:@"NHaasGroteskDSStd-75Bd" type:@"otf"];
|
|
[MFFonts loadFont:@"NHaasGroteskDSStd-55Rg" type:@"otf"];
|
|
[MFFonts loadFont:@"OCRAExtended" type:@"ttf"];
|
|
});
|
|
}
|
|
|
|
+ (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 {
|
|
[self loadMVMFonts];
|
|
return [UIFont fontWithName:@"NHaasGroteskDSStd-75Bd" size:size];
|
|
}
|
|
|
|
+ (nullable UIFont *)mfFont55Rg:(CGFloat)size {
|
|
[self loadMVMFonts];
|
|
return [UIFont fontWithName:@"NHaasGroteskDSStd-55Rg" size:size];
|
|
}
|
|
|
|
+ (nullable UIFont *)mfFontOcratxt:(CGFloat)size {
|
|
[self loadMVMFonts];
|
|
return [UIFont fontWithName:@"OCRAExtended" size:size];
|
|
}
|
|
|
|
+ (nullable UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size {
|
|
return [UIFont fontWithName:name size:size] ?: [self mfFont55Rg:size];
|
|
}
|
|
|
|
@end
|