Skip to content

Commit f547e3e

Browse files
committed
v0.4.2
1 parent 3170790 commit f547e3e

11 files changed

Lines changed: 53 additions & 35 deletions

File tree

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/TypographyKit.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@
389389
);
390390
runOnlyForDeploymentPostprocessing = 0;
391391
shellPath = /bin/sh;
392-
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
392+
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"error: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
393393
};
394394
/* End PBXShellScriptBuildPhase section */
395395

@@ -495,6 +495,7 @@
495495
ONLY_ACTIVE_ARCH = YES;
496496
SDKROOT = iphoneos;
497497
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
498+
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
498499
};
499500
name = Debug;
500501
};
@@ -542,6 +543,7 @@
542543
MTL_ENABLE_DEBUG_INFO = NO;
543544
SDKROOT = iphoneos;
544545
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
546+
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
545547
VALIDATE_PRODUCT = YES;
546548
};
547549
name = Release;

Example/TypographyKit/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1515

1616
func application(_ application: UIApplication,
1717
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18-
// Override point for customization after application launch.
1918
return true
2019
}
2120

Example/TypographyKit/TypographyKit.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"text": "gold"
77
},
88
"typography-kit": {
9+
"minimum-point-size": 10,
10+
"maximum-point-size": 100,
911
"point-step-size": 2,
1012
"point-step-multiplier": 1
1113
},

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,18 @@ You may specify your own point step size and multiplier by inclusion of a dictio
241241

242242
<key>typography-kit</key>
243243
<dict>
244+
<key>minimum-point-size</key>
245+
<integer>10</integer>
246+
<key>maximum-point-size</key>
247+
<integer>100</integer>
244248
<key>point-step-size</key>
245249
<integer>2</integer>
246250
<key>point-step-multiplier</key>
247251
<integer>1</integer>
248252
</dict>
249253

254+
Optionally, you may clamp the font point size to a lower and / or upper bound using the `minimum-point-size` and `maximum-point-size` properties.
255+
250256
### Remote Configuration
251257
TypographyKit also allows you to host your configuration remotely so that your colors and font styles can be updated dynamically. To do so, simply add the following line to your app delegate so that it is invoked when your app finishes launching:
252258

TypographyKit.podspec

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
1-
#
2-
# Be sure to run `pod lib lint TypographyKit.podspec' to ensure this is a
3-
# valid spec before submitting.
4-
#
5-
# Any lines starting with a # are optional, but their use is encouraged
6-
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
7-
#
8-
91
Pod::Spec.new do |s|
102
s.name = 'TypographyKit'
11-
s.version = '0.4.0'
3+
s.version = '0.4.2'
124
s.summary = 'Visually consistent, accessible type for your iOS application.'
135
s.swift_version = '4.1'
146
s.description = <<-DESC
157
TypographyKit makes it easy to define typography styles in your iOS app helping you achieve visual consistency in your design as well as supporting Dynamic Type even where using custom fonts.
168
DESC
17-
189
s.homepage = 'https://github.com/rwbutler/TypographyKit'
19-
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
2010
s.license = { :type => 'MIT', :file => 'LICENSE' }
2111
s.author = { 'rwbutler' => 'github@rwbutler.com' }
2212
s.source = { :git => 'https://github.com/rwbutler/TypographyKit.git', :tag => s.version.to_s }
23-
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
24-
2513
s.ios.deployment_target = '8.0'
26-
2714
s.source_files = 'TypographyKit/Classes/**/*'
28-
29-
# s.resource_bundles = {
30-
# 'TypographyKit' => ['TypographyKit/Assets/*.png']
31-
# }
32-
33-
# s.public_header_files = 'Pod/Classes/**/*.h'
34-
# s.frameworks = 'UIKit', 'MapKit'
3515
end

TypographyKit/Classes/ConfigurationSettings.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
//
88

99
struct ConfigurationSettings {
10+
let minimumPointSize: Float?
11+
let maximumPointSize: Float?
1012
let pointStepSize: Float
1113
let pointStepMultiplier: Float
14+
15+
init(minimumPointSize: Float? = nil, maximumPointSize: Float? = nil,
16+
pointStepSize: Float = 2.0, pointStepMultiplier: Float = 1.0) {
17+
self.minimumPointSize = minimumPointSize
18+
self.maximumPointSize = maximumPointSize
19+
self.pointStepSize = pointStepSize
20+
self.pointStepMultiplier = pointStepMultiplier
21+
}
1222
}

TypographyKit/Classes/ParsingService.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,18 @@ extension ParsingService {
3838
}
3939

4040
func parse(_ configEntries: [String: Any]) -> ParsingServiceResult? {
41-
var configuration: ConfigurationSettings = ConfigurationSettings(pointStepSize: 2.0,
42-
pointStepMultiplier: 1.0)
41+
var configuration: ConfigurationSettings = ConfigurationSettings()
4342
var typographyColors: [String: UIColor] = [:]
4443
var typographyStyles: [String: Typography] = [:]
4544

4645
if let typographyKitConfig = configEntries["typography-kit"] as? [String: Float],
4746
let pointStepSize = typographyKitConfig["point-step-size"],
4847
let pointStepMultiplier = typographyKitConfig["point-step-multiplier"] {
49-
configuration = ConfigurationSettings(pointStepSize: pointStepSize,
48+
let minimumPointSize = typographyKitConfig["minimum-point-size"]
49+
let maximumPointSize = typographyKitConfig["maximum-point-size"]
50+
configuration = ConfigurationSettings(minimumPointSize: minimumPointSize,
51+
maximumPointSize: maximumPointSize,
52+
pointStepSize: pointStepSize,
5053
pointStepMultiplier: pointStepMultiplier)
5154
}
5255
var colorAliases: [String: String] = [:] // keys which are synonyms for other colors
@@ -66,22 +69,20 @@ extension ParsingService {
6669
for (fontTextStyleKey, fontTextStyle) in fontTextStyles {
6770
let fontName = fontTextStyle[ConfigurationKey.fontName.rawValue] as? String
6871
let pointSize = fontTextStyle[ConfigurationKey.pointSize.rawValue] as? Float
69-
var textColor: UIColor? = nil
72+
var textColor: UIColor?
7073
if let textColorName = fontTextStyle[ConfigurationKey.textColor.rawValue] as? String {
7174
if let color = typographyColors[textColorName] {
7275
textColor = color
7376
} else {
7477
textColor = TypographyColor(string: textColorName)?.uiColor
7578
}
7679
}
77-
var letterCase: LetterCase? = nil
80+
var letterCase: LetterCase?
7881
if let letterCaseName = fontTextStyle[ConfigurationKey.letterCase.rawValue] as? String {
7982
letterCase = LetterCase(rawValue: letterCaseName)
8083
}
81-
typographyStyles[fontTextStyleKey] = Typography(fontName: fontName,
82-
fontSize: pointSize,
83-
letterCase: letterCase,
84-
textColor: textColor)
84+
typographyStyles[fontTextStyleKey] = Typography(fontName: fontName, fontSize: pointSize,
85+
letterCase: letterCase, textColor: textColor)
8586
}
8687
}
8788
return (configurationSettings: configuration,

TypographyKit/Classes/Typography.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public struct Typography {
5656
pointSize += (TypographyKit.pointStepSize
5757
* contentSizeCategoryStepMultiplier
5858
* TypographyKit.pointStepMultiplier)
59+
if let minimumPointSize = TypographyKit.minimumPointSize, pointSize < minimumPointSize {
60+
pointSize = minimumPointSize
61+
}
62+
if let maximumPointSize = TypographyKit.maximumPointSize, maximumPointSize < pointSize {
63+
pointSize = maximumPointSize
64+
}
5965
return UIFont(name: fontName, size: CGFloat(pointSize))
6066
}
6167
}

TypographyKit/Classes/TypographyKit.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ public struct TypographyKit {
3030
return .plist // default
3131
}()
3232

33+
public static var minimumPointSize: Float? = {
34+
return configuration?.configurationSettings.minimumPointSize
35+
}()
36+
37+
public static var maximumPointSize: Float? = {
38+
return configuration?.configurationSettings.maximumPointSize
39+
}()
40+
3341
public static var pointStepSize: Float = {
3442
return configuration?.configurationSettings.pointStepSize ?? 2.0
3543
}()
@@ -90,7 +98,7 @@ private extension TypographyKit {
9098
}
9199

92100
private static func parseConfiguration(data: Data) -> ParsingServiceResult? {
93-
var parsingService: ParsingService? = nil
101+
var parsingService: ParsingService?
94102
switch configurationType {
95103
case .plist:
96104
parsingService = PropertyListParsingService()

0 commit comments

Comments
 (0)