Skip to content

Commit 1c0d4b8

Browse files
committed
Release 4.3.0
1 parent 15653db commit 1c0d4b8

4 files changed

Lines changed: 28 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [4.3.0] - 2021-09-21
8-
## Changed
7+
## [4.3.0] - 2021-11-09
8+
## Added
99
- Support for disabling font scaling either system-wide and/or per-font.
1010
- Support for custom letter spacing in font styles plist.
1111

TypographyKit/Classes/FontTextStyleParser.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,17 @@ private extension FontTextStyleParser {
9999
scalingMode = ScalingMode(rawValue: scalingModeName)
100100
}
101101
let letterSpacing = fontTextStyle[ConfigurationKey.letterSpacing.rawValue] as? Double ?? 0
102-
103-
return Typography(name: key, fontName: fontName, fontSize: pointSize, letterCase: letterCase,
104-
letterSpacing: letterSpacing, maximumPointSize: maxPointSize, minimumPointSize: minPointSize,
105-
scalingMode: scalingMode, textColor: textColor)
102+
return Typography(
103+
name: key,
104+
fontName: fontName,
105+
fontSize: pointSize,
106+
letterCase: letterCase,
107+
letterSpacing: letterSpacing,
108+
maximumPointSize: maxPointSize,
109+
minimumPointSize: minPointSize,
110+
scalingMode: scalingMode,
111+
textColor: textColor
112+
)
106113
}
107114

108115
/// Extends the original Typography style with another style, replacing properties of the

TypographyKit/Classes/Typography.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ public struct Typography {
6868
self.textStyle = textStyle
6969
}
7070

71-
public init(name: String, fontName: String? = nil, fontSize: Float? = nil,
72-
letterCase: LetterCase? = nil, letterSpacing: Double = 0,
73-
maximumPointSize: Float? = nil, minimumPointSize: Float? = nil,
74-
scalingMode: ScalingMode? = nil, textColor: UIColor? = nil) {
71+
public init(
72+
name: String,
73+
fontName: String? = nil,
74+
fontSize: Float? = nil,
75+
letterCase: LetterCase? = nil,
76+
letterSpacing: Double = 0,
77+
maximumPointSize: Float? = nil,
78+
minimumPointSize: Float? = nil,
79+
scalingMode: ScalingMode? = nil,
80+
textColor: UIColor? = nil
81+
) {
7582
self.name = name
7683
self.fontName = fontName
7784
self.maximumPointSize = maximumPointSize

TypographyKit/Classes/UILabelAdditions.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ extension UILabel {
115115
self.attributedText = replacementString
116116
}
117117
if self.typography.letterSpacing > 0 {
118-
guard let attrString = self.attributedText else { return }
118+
guard let attrString = self.attributedText else {
119+
return
120+
}
119121
let spacingString = NSMutableAttributedString(attributedString: attrString)
120122
spacingString.addAttribute(.kern, value: self.typography.letterSpacing, range: textRange)
121123
self.attributedText = spacingString
@@ -136,7 +138,7 @@ extension UILabel {
136138
typography.letterCase = letterCase
137139
}
138140
self.typography = typography
139-
141+
140142
if self.typography.letterSpacing > 0 {
141143
self.attributedText(NSAttributedString(string: self.text ?? ""), style: style)
142144
}

0 commit comments

Comments
 (0)