From c70526c2e6b2e1fe32b50462e3c17770733b6916 Mon Sep 17 00:00:00 2001 From: Emily Laguna Date: Fri, 26 Jun 2020 08:43:55 -0700 Subject: [PATCH 1/4] Add method to get the system serif font for iOS 13+ --- WordPressShared.xcodeproj/project.pbxproj | 4 +++ .../Core/Views/WPStyleGuide+SerifFonts.swift | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift diff --git a/WordPressShared.xcodeproj/project.pbxproj b/WordPressShared.xcodeproj/project.pbxproj index 16e2e51..03ecf1f 100644 --- a/WordPressShared.xcodeproj/project.pbxproj +++ b/WordPressShared.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 1A4094D52270A75E009AA86D /* NSBundle+WordPressShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A4094D42270A75E009AA86D /* NSBundle+WordPressShared.swift */; }; 1A4095102271AA9E009AA86D /* WPShared-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A40950D2271AA9E009AA86D /* WPShared-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2EB9C57E3BFEDA1676FE857C /* Pods_WordPressShared.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE15A6EE80D7766A21B83BF5 /* Pods_WordPressShared.framework */; }; + 32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */; }; 740B23CC1F17F1FF00067A2A /* DisplayableImageHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 740B23CA1F17F1FF00067A2A /* DisplayableImageHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; 740B23CD1F17F1FF00067A2A /* DisplayableImageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CB1F17F1FF00067A2A /* DisplayableImageHelper.m */; }; 740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CE1F17F28E00067A2A /* DisplayableImageHelperTest.m */; }; @@ -114,6 +115,7 @@ /* Begin PBXFileReference section */ 1A4094D42270A75E009AA86D /* NSBundle+WordPressShared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+WordPressShared.swift"; sourceTree = ""; }; 1A40950D2271AA9E009AA86D /* WPShared-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPShared-Swift.h"; sourceTree = ""; }; + 32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WPStyleGuide+SerifFonts.swift"; sourceTree = ""; }; 405129D7901B7D4AD3B46442 /* Pods-WordPressShared.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release-internal.xcconfig"; sourceTree = ""; }; 47629DF6D2C813279CBF93C4 /* Pods_WordPressSharedTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressSharedTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5AC1280B7CDCD44A2F3A20AC /* Pods-WordPressShared.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressShared.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressShared/Pods-WordPressShared.release-alpha.xcconfig"; sourceTree = ""; }; @@ -452,6 +454,7 @@ B5A7880E202B3A55007874FB /* WPNUXUtility.h */, B5A78811202B3A55007874FB /* WPNUXUtility.m */, B5A7880F202B3A55007874FB /* WPStyleGuide+DynamicType.swift */, + 32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */, B5A7881D202B3A92007874FB /* WPTableViewCell.h */, B5A7881A202B3A92007874FB /* WPTableViewCell.m */, B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */, @@ -707,6 +710,7 @@ B5393FD8206D608F007BF9D4 /* EmailFormatValidator.swift in Sources */, F106FA62226FA82E00706DE4 /* String+URLValidation.swift in Sources */, F10A569023E1FC1300B184F4 /* String+StripShortcodes.swift in Sources */, + 32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */, 93C882AD1EEB1E2F00227A59 /* NSDate+Helpers.swift in Sources */, 74650F801F0EA4BD00188EDB /* NSMutableData+Helpers.swift in Sources */, 7414BD621F13D084005759F8 /* UIDevice+Helpers.m in Sources */, diff --git a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift new file mode 100644 index 0000000..5d35647 --- /dev/null +++ b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift @@ -0,0 +1,33 @@ +import Foundation + +/// WPStyleGuide Extension to use serif fonts. +/// +extension WPStyleGuide { + /// Returns the system serif font (New York) for iOS 13+ but defaults to noto for older os's + @objc public class func serifFontForTextStyle(_ style: UIFont.TextStyle, + fontWeight weight: UIFont.Weight = .regular) -> UIFont { + guard #available(iOS 13, *), + let fontDescriptor = WPStyleGuide.fontForTextStyle(style, fontWeight: weight).fontDescriptor.withDesign(.serif) + else { + return WPStyleGuide.notoFontForTextStyle(style, fontWeight: weight) + } + + return UIFontMetrics.default.scaledFont(for: UIFont(descriptor: fontDescriptor, size: 0.0)) + } + + + private class func notoFontForTextStyle(_ style: UIFont.TextStyle, + fontWeight weight: UIFont.Weight = .regular) -> UIFont { + var font: UIFont + + switch weight { + // Map all the bold weights to the bold font + case .bold, .semibold, .heavy, .black: + font = WPStyleGuide.notoBoldFontForTextStyle(style) + default: + font = WPStyleGuide.notoFontForTextStyle(style) + } + + return font + } +} From 24a8b22b63dba3ab939a2a97a054a60afd68efc4 Mon Sep 17 00:00:00 2001 From: Emily Laguna Date: Fri, 26 Jun 2020 08:53:37 -0700 Subject: [PATCH 2/4] Update version to 1.9.1-beta.1 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index 0a1e09c..ef80a1e 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.9.0" + s.version = "1.9.1-beta.1" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From e52915ce059e70f89481bace3b238396879824ba Mon Sep 17 00:00:00 2001 From: Emily Laguna Date: Fri, 26 Jun 2020 09:04:19 -0700 Subject: [PATCH 3/4] Remove semibold from the noto bold fonts fallback --- WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift index 5d35647..de1fbc3 100644 --- a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift +++ b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift @@ -22,7 +22,7 @@ extension WPStyleGuide { switch weight { // Map all the bold weights to the bold font - case .bold, .semibold, .heavy, .black: + case .bold, .heavy, .black: font = WPStyleGuide.notoBoldFontForTextStyle(style) default: font = WPStyleGuide.notoFontForTextStyle(style) From 1392bdb7bcad56953acd77ed0f377d04487ebb6d Mon Sep 17 00:00:00 2001 From: Emily Laguna Date: Fri, 26 Jun 2020 09:12:55 -0700 Subject: [PATCH 4/4] Revert "Remove semibold from the noto bold fonts fallback" This reverts commit e52915ce059e70f89481bace3b238396879824ba. --- WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift index de1fbc3..5d35647 100644 --- a/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift +++ b/WordPressShared/Core/Views/WPStyleGuide+SerifFonts.swift @@ -22,7 +22,7 @@ extension WPStyleGuide { switch weight { // Map all the bold weights to the bold font - case .bold, .heavy, .black: + case .bold, .semibold, .heavy, .black: font = WPStyleGuide.notoBoldFontForTextStyle(style) default: font = WPStyleGuide.notoFontForTextStyle(style)