Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 0345bf2

Browse files
author
Emily Laguna
authored
Merge pull request #266 from wordpress-mobile/issue/newyork-serif-font
Adds a new method to use the iOS 13+ system serif (New York) font
2 parents 29c5869 + 1392bdb commit 0345bf2

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

WordPressShared.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressShared"
3-
s.version = "1.9.0"
3+
s.version = "1.9.1-beta.1"
44
s.summary = "Shared components used in building the WordPress iOS apps and other library components."
55

66
s.description = <<-DESC

WordPressShared.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1A4094D52270A75E009AA86D /* NSBundle+WordPressShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A4094D42270A75E009AA86D /* NSBundle+WordPressShared.swift */; };
1212
1A4095102271AA9E009AA86D /* WPShared-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A40950D2271AA9E009AA86D /* WPShared-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; };
1313
2EB9C57E3BFEDA1676FE857C /* Pods_WordPressShared.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE15A6EE80D7766A21B83BF5 /* Pods_WordPressShared.framework */; };
14+
32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */; };
1415
740B23CC1F17F1FF00067A2A /* DisplayableImageHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 740B23CA1F17F1FF00067A2A /* DisplayableImageHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
1516
740B23CD1F17F1FF00067A2A /* DisplayableImageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CB1F17F1FF00067A2A /* DisplayableImageHelper.m */; };
1617
740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 740B23CE1F17F28E00067A2A /* DisplayableImageHelperTest.m */; };
@@ -114,6 +115,7 @@
114115
/* Begin PBXFileReference section */
115116
1A4094D42270A75E009AA86D /* NSBundle+WordPressShared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+WordPressShared.swift"; sourceTree = "<group>"; };
116117
1A40950D2271AA9E009AA86D /* WPShared-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPShared-Swift.h"; sourceTree = "<group>"; };
118+
32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WPStyleGuide+SerifFonts.swift"; sourceTree = "<group>"; };
117119
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 = "<group>"; };
118120
47629DF6D2C813279CBF93C4 /* Pods_WordPressSharedTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressSharedTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
119121
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 = "<group>"; };
@@ -452,6 +454,7 @@
452454
B5A7880E202B3A55007874FB /* WPNUXUtility.h */,
453455
B5A78811202B3A55007874FB /* WPNUXUtility.m */,
454456
B5A7880F202B3A55007874FB /* WPStyleGuide+DynamicType.swift */,
457+
32E1BFD424A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift */,
455458
B5A7881D202B3A92007874FB /* WPTableViewCell.h */,
456459
B5A7881A202B3A92007874FB /* WPTableViewCell.m */,
457460
B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */,
@@ -707,6 +710,7 @@
707710
B5393FD8206D608F007BF9D4 /* EmailFormatValidator.swift in Sources */,
708711
F106FA62226FA82E00706DE4 /* String+URLValidation.swift in Sources */,
709712
F10A569023E1FC1300B184F4 /* String+StripShortcodes.swift in Sources */,
713+
32E1BFD524A63DE6007A08F0 /* WPStyleGuide+SerifFonts.swift in Sources */,
710714
93C882AD1EEB1E2F00227A59 /* NSDate+Helpers.swift in Sources */,
711715
74650F801F0EA4BD00188EDB /* NSMutableData+Helpers.swift in Sources */,
712716
7414BD621F13D084005759F8 /* UIDevice+Helpers.m in Sources */,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Foundation
2+
3+
/// WPStyleGuide Extension to use serif fonts.
4+
///
5+
extension WPStyleGuide {
6+
/// Returns the system serif font (New York) for iOS 13+ but defaults to noto for older os's
7+
@objc public class func serifFontForTextStyle(_ style: UIFont.TextStyle,
8+
fontWeight weight: UIFont.Weight = .regular) -> UIFont {
9+
guard #available(iOS 13, *),
10+
let fontDescriptor = WPStyleGuide.fontForTextStyle(style, fontWeight: weight).fontDescriptor.withDesign(.serif)
11+
else {
12+
return WPStyleGuide.notoFontForTextStyle(style, fontWeight: weight)
13+
}
14+
15+
return UIFontMetrics.default.scaledFont(for: UIFont(descriptor: fontDescriptor, size: 0.0))
16+
}
17+
18+
19+
private class func notoFontForTextStyle(_ style: UIFont.TextStyle,
20+
fontWeight weight: UIFont.Weight = .regular) -> UIFont {
21+
var font: UIFont
22+
23+
switch weight {
24+
// Map all the bold weights to the bold font
25+
case .bold, .semibold, .heavy, .black:
26+
font = WPStyleGuide.notoBoldFontForTextStyle(style)
27+
default:
28+
font = WPStyleGuide.notoFontForTextStyle(style)
29+
}
30+
31+
return font
32+
}
33+
}

0 commit comments

Comments
 (0)