diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cb821240..a28f633b 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -111,6 +111,8 @@ 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; + 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */ = {isa = PBXBuildFile; fileRef = 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */ = {isa = PBXBuildFile; fileRef = 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */; }; 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; 94AF4A3E23E9D13900676048 /* MFCaretButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94AF4A3C23E9D13900676048 /* MFCaretButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -445,6 +447,8 @@ 944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = ""; }; 944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; + 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIFont+FontWrapping.h"; sourceTree = ""; }; + 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIFont+FontWrapping.m"; sourceTree = ""; }; 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; 94AF4A3C23E9D13900676048 /* MFCaretButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = ""; }; @@ -1234,6 +1238,8 @@ D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */, D29DF14D21E693AD003B2FB9 /* MFFonts.h */, D29DF14C21E693AD003B2FB9 /* MFFonts.m */, + 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */, + 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */, D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */, D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */, D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */, @@ -1497,6 +1503,7 @@ D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */, D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */, D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */, + 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */, D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */, D29DF29A21E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h in Headers */, D29DF11521E6805F003B2FB9 /* UIColor+MFConvenience.h in Headers */, @@ -1674,6 +1681,7 @@ DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, + 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */, 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index 5e11e116..70e54e45 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -350,7 +350,7 @@ public typealias ActionBlock = () -> () if let fontName = labelModel.fontName { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? standardFontSize) } else if let fontSize = fontSize { - font = font.withSize(fontSize) + font = font.updateSize(fontSize) } } @@ -359,7 +359,7 @@ public typealias ActionBlock = () -> () } if let attributes = labelModel.attributes, let labelText = text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.withSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) for attribute in attributes { let range = NSRange(location: attribute.location, length: attribute.length) @@ -407,7 +407,7 @@ public typealias ActionBlock = () -> () if let fontName = fontAtt.name { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize) } else if let fontSize = fontSize { - font = self.font.withSize(fontSize) + font = self.font.updateSize(fontSize) } if let font = font { attributedString.removeAttribute(.font, range: range) @@ -473,7 +473,7 @@ public typealias ActionBlock = () -> () if let fontName = json?.optionalStringForKey("fontName") { label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { - label.font = label.font.withSize(fontSize) + label.font = label.font.updateSize(fontSize) } } @@ -483,7 +483,7 @@ public typealias ActionBlock = () -> () if let attributes = json?.optionalArrayForKey("attributes"), let labelText = label.text { let attributedString = NSMutableAttributedString(string: labelText, - attributes: [NSAttributedString.Key.font: mvmLabel?.font.withSize(mvmLabel!.standardFontSize) ?? label.font as UIFont, + attributes: [NSAttributedString.Key.font: mvmLabel?.font.updateSize(mvmLabel!.standardFontSize) ?? label.font as UIFont, NSAttributedString.Key.foregroundColor: label.textColor as UIColor]) for case let attribute as [String: Any] in attributes { guard let attributeType = attribute.optionalStringForKey(KeyType), @@ -535,7 +535,7 @@ public typealias ActionBlock = () -> () if let fontName = attribute.optionalStringForKey("name") { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { - font = label.font.withSize(fontSize) + font = label.font.updateSize(fontSize) } if let font = font { @@ -677,7 +677,7 @@ public typealias ActionBlock = () -> () originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: []) { value, range, stop in if let fontObj = value as? UIFont, let stylerSize = MFStyler.sizeObjectGeneric(forCurrentDevice: fontObj.pointSize)?.getValueBased(onSize: size) { - attributedString.addAttribute(.font, value: fontObj.withSize(stylerSize) as Any, range: range) + attributedString.addAttribute(.font, value: fontObj.updateSize(stylerSize) as Any, range: range) } } @@ -693,7 +693,7 @@ public typealias ActionBlock = () -> () attributedText = attributedString } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { - font = font.withSize(sizeObject.getValueBased(onSize: size)) + font = font.updateSize(sizeObject.getValueBased(onSize: size)) } } diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 1b2183aa..5e8c92cc 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -32,6 +32,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #pragma mark - Categories #import #import +#import #pragma mark - Styles #import diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index eb89312c..6accea28 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -100,6 +100,8 @@ B3 -> Legal // Returns the fonts for these styles. Scales them as needed by default #pragma mark - 3.0 fonts +///auto select corresponding font based on font size, DS for font bigger than 15 pt, TX for font smaller than 15 pt ++ (nonnull UIFont *)getMVA3FontSize:(CGFloat)size bold:(BOOL)isBold; ///Bold 36pt + (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling; + (nonnull UIFont *)fontTitle2XLarge; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index 69a04b3e..55978976 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -113,12 +113,28 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; #pragma mark - 3.0 fonts ++ (nonnull UIFont *)getMVA3FontSize:(CGFloat)size bold:(BOOL)isBold { + if (isBold) { + if (size >= 15) { + return [MFFonts mfFontDSBold:size]; + } else { + return [MFFonts mfFontTXBold:size]; + } + } else { + if (size >= 15) { + return [MFFonts mfFontDSRegular:size]; + } else { + return [MFFonts mfFontTXRegular:size]; + } + } +} + + (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling { CGFloat size = 36; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontTitle2XLarge { @@ -130,7 +146,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontTitleXLarge{ return [self fontTitleXLarge:YES]; @@ -141,7 +157,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontBoldTitleLarge { @@ -153,7 +169,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont55Rg:size]; + return [self getMVA3FontSize:size bold:NO]; } + (nonnull UIFont *)fontRegularTitleLarge { @@ -165,7 +181,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontBoldTitleMedium { @@ -177,7 +193,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont55Rg:size]; + return [self getMVA3FontSize:size bold:NO]; } + (nonnull UIFont *)fontRegularTitleMedium { @@ -189,7 +205,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontBoldBodyLarge { @@ -201,7 +217,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont55Rg:size]; + return [self getMVA3FontSize:size bold:NO]; } + (nonnull UIFont *)fontRegularBodyLarge { @@ -213,7 +229,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontBoldBodySmall { @@ -225,7 +241,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont55Rg:size]; + return [self getMVA3FontSize:size bold:NO]; } + (nonnull UIFont *)fontRegularBodySmall { @@ -237,7 +253,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont75Bd:size]; + return [self getMVA3FontSize:size bold:YES]; } + (nonnull UIFont *)fontBoldMicro { @@ -249,7 +265,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; if (genericScaling) { size = [self sizeFontGenericForCurrentDevice:size]; } - return [MFFonts mfFont55Rg:size]; + return [self getMVA3FontSize:size bold:NO]; } + (nonnull UIFont *)fontRegularMicro { diff --git a/MVMCoreUI/Utility/MFFonts.h b/MVMCoreUI/Utility/MFFonts.h index ba167df1..4bd1f532 100644 --- a/MVMCoreUI/Utility/MFFonts.h +++ b/MVMCoreUI/Utility/MFFonts.h @@ -10,6 +10,11 @@ #import #import +extern NSString * _Nonnull const DSBold; +extern NSString * _Nonnull const DSRegular; +extern NSString * _Nonnull const TXBold; +extern NSString * _Nonnull const TXRegular; + @interface MFFonts : NSObject ///return mfFontTXBold when size smaller than 15, otherwise, return mfFontDSBold diff --git a/MVMCoreUI/Utility/MFFonts.m b/MVMCoreUI/Utility/MFFonts.m index 09956ae4..964707a0 100644 --- a/MVMCoreUI/Utility/MFFonts.m +++ b/MVMCoreUI/Utility/MFFonts.m @@ -11,10 +11,10 @@ #import "MVMCoreUIUtility.h" @import MVMCore.MVMCoreLoggingHandler; -static NSString * const DSBold = @"VerizonNHGeDS-Bold"; -static NSString * const DSRegular = @"VerizonNHGeDS-Regular"; -static NSString * const TXBold = @"VerizonNHGeTX-Bold"; -static NSString * const TXRegular = @"VerizonNHGeTX-Regular"; +NSString * const DSBold = @"VerizonNHGeDS-Bold"; +NSString * const DSRegular = @"VerizonNHGeDS-Regular"; +NSString * const TXBold = @"VerizonNHGeTX-Bold"; +NSString * const TXRegular = @"VerizonNHGeTX-Regular"; @implementation MFFonts diff --git a/MVMCoreUI/Utility/UIFont+FontWrapping.h b/MVMCoreUI/Utility/UIFont+FontWrapping.h new file mode 100644 index 00000000..1fd3360d --- /dev/null +++ b/MVMCoreUI/Utility/UIFont+FontWrapping.h @@ -0,0 +1,19 @@ +// +// UIFont+FontWrapping.h +// MVMCoreUI +// +// Created by Ryan on 2/26/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UIFont (FontWrapping) + +- (UIFont *)updateFontSize:(CGFloat)size; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Utility/UIFont+FontWrapping.m b/MVMCoreUI/Utility/UIFont+FontWrapping.m new file mode 100644 index 00000000..8af7783d --- /dev/null +++ b/MVMCoreUI/Utility/UIFont+FontWrapping.m @@ -0,0 +1,25 @@ +// +// UIFont+FontWrapping.m +// MVMCoreUI +// +// Created by Ryan on 2/26/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +#import "UIFont+FontWrapping.h" +#import "MFFonts.h" +#import "MFStyler.h" +#import + +@implementation UIFont (FontWrapping) + +- (UIFont *)updateFontSize:(CGFloat)size { + if ([self.familyName isEqualToString:@"Verizon NHG eDS"] || [self.familyName isEqualToString:@"Verizon NHG eTX"]) { + return [MFStyler getMVA3FontSize:size bold:[self.fontName isEqualToString:DSBold]]; + } else { + return [self fontWithSize:size]; + } + +} + +@end