Skip to content

Commit 4ba4bb6

Browse files
authored
Merge pull request #86 from danqing/master
Fix iOS 13 font regression (Times New Roman)
2 parents 89b1dd9 + 6a9faab commit 4ba4bb6

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

ExampleiOS/Base.lproj/Main.storyboard

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
97
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
108
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
119
</dependencies>
@@ -23,8 +21,7 @@
2321
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2422
<subviews>
2523
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="M2v-v6-dEE">
26-
<rect key="frame" x="10" y="30" width="355" height="627"/>
27-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
24+
<rect key="frame" x="10" y="10" width="355" height="647"/>
2825
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
2926
<fontDescription key="fontDescription" type="system" pointSize="14"/>
3027
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>

Sources/SwiftRichString/Attributes/FontConvertible.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ public protocol FontConvertible {
5151

5252
// MARK: - FontConvertible for UIFont/NSFont
5353
extension Font: FontConvertible {
54-
54+
5555
/// Return the same instance of the font with specified size.
5656
///
5757
/// - Parameter size: size of the font in points. If size is `nil`, `Font.systemFontSize` is used.
5858
/// - Returns: instance of the font.
5959
public func font(size: CGFloat?) -> Font {
6060
#if os(tvOS)
6161
return Font(name: self.fontName, size: (size ?? TVOS_SYSTEMFONT_SIZE))!
62-
#elseif os(iOS)
63-
return Font(name: self.fontName, size: (size ?? Font.systemFontSize))!
6462
#elseif os(watchOS)
6563
return Font(name: self.fontName, size: (size ?? WATCHOS_SYSTEMFONT_SIZE))!
6664
#elseif os(macOS)
67-
return Font(descriptor: self.fontDescriptor, size: (size ?? Font.systemFontSize))!
65+
return Font(descriptor: self.fontDescriptor, size: (size ?? Font.systemFontSize))!
66+
#else
67+
return Font(descriptor: self.fontDescriptor, size: (size ?? Font.systemFontSize))
6868
#endif
6969
}
70-
70+
7171
}
7272

7373
// MARK: - FontConvertible for String
7474
extension String: FontConvertible {
75-
75+
7676
/// Transform a string to a valid `UIFont`/`NSFont` instance.
7777
/// String must contain a valid Postscript font's name.
7878
///
@@ -87,5 +87,5 @@ extension String: FontConvertible {
8787
return Font(name: self, size: (size ?? Font.systemFontSize))!
8888
#endif
8989
}
90-
90+
9191
}

0 commit comments

Comments
 (0)