Skip to content

Commit

Permalink
Updated README.md and CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rwbutler committed Feb 16, 2023
1 parent f4ed4d1 commit e0d64af
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- All methods & properties previously accessed using `TypographyKit.` may now be accessed using the shortened form: `TK.`.
- Support for RGBA colour values e.g. rgba(255,255,255,255).
- Support for hexadecimal color values with transparency e.g. #FFFFFFFF.
- New configuration options may now be declared as part of the TypographyKit JSON configuration file:
- `development-color`: If the app build is a development build and `should-use-development-colors` is `true` then when the value of a color hasn't been specified, TypographyKit will fallback to using the value of this color.
- `fallback-color`: If the app build is *not* a development build -or- the app build is a development build but `should-use-development-colors` is `false` then this color will be used if the value of a color has not been set.
- `is-development`: Can be used to set whether or not the build is a development build. If the value is not set, this is determined according to whether or not the build is debug.
- `should-crash-if-color-not-found`: If the build is a development build and the value of this key is `true` then if the value of a color hasn't been specified then the app will crash. Default value: `false`.
- `should-use-development-colors`: If the build is a development build and the value of this key is `true` then if the value of a color hasn't been specified then the specified `development-colour` will be used. Default value: `true`.

- All configuration options specified in the TypographyKit configuration file may also be specified via the `TypographyKit.Configuration` object when configuring the framework. Note: Settings specified in the TypographyKit configuration file override settings specified programmatically.


## Changed
- Deployment target updated to iOS 11.0 (dropped support for iOS 9.0 and 10.0 in-line with Xcode 14).
- `TypographyKit.colors` should no longer be used. Instead use:
- For SwiftUI: `TypographyKit.color(named:)` or `TK.color(named:)`.
- For UIKit: `TypographyKit.uiColor(named:)` or `TK.uiColor(named:)`.
Expand Down
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ To learn more about how to use TypographyKit, take a look at the table of conten

- [Features](#features)
- [What's New in TypographyKit 5.0.0?](#whats-new-in-typographykit-500)
- [What's New in TypographyKit 4.0.0?](#whats-new-in-typographykit-400)
- [Installation](#installation)
- [Cocoapods](#cocoapods)
- [Carthage](#carthage)
Expand Down Expand Up @@ -56,25 +55,44 @@ To learn more about how to use TypographyKit, take a look at the table of conten

## What's new in TypographyKit 5.0.0?

TypographyKit 5.0.0 drops support for iOS 9.0, updating the deployment target to 11.0 in line with Xcode 14.

## What's new in TypographyKit 4.0.0?
- First-class support for SwiftUI colors - to obtain a color, use `TK.color(named:)`.
- You may specify a fallback color to be used in the event that you forget to define a color. Use the `fallback-color` key to specify which color should be used in this case.
- Setting: `fallback-color`
- Default: Black in light mode and white in dark mode.
- You may specify a development color which is used in the event that you forget to define a color in development builds. This color may be different from the fallback color. For example, you may want to use an easily noticeable color such as red to make it visually clear that you have forgotten to define a color in development builds. However, you may want to ensure that this red color will never be shown in production builds - this is why development colors will never be shown in production builds (instead the fallback color will be used).
- Setting: `development-color`
- Default: `red`

- Setting: `is-development`
- Default: `true` in #DEBUG builds; `false` otherwise

- Setting: `should-use-development-colors`
- Default: `true`

- You may optionally specify that your development app builds crash if you forget to define a color. This makes it even less likely that you will forget to specify a color value during development. This setting only affects development builds so there is no need to worry that production builds might crash.
- Setting: `should-crash-if-color-not-found`
- Default: `false`

TypographyKit 4.0.0 introduces support for SwiftUI. In order to make use of TypographyKit with SwiftUI, create a TypographyKit configuration file (either JSON or PList) and an extension on `UIFont.TextStyle` as described in the [Usage](#usage) section, then simply apply your typography style to a SwiftUI `Text` view as follows:
- To start using the framework, now `import TypographyKit` and then configure as follows:

```swift
Text("An example using TypographyKit with SwiftUI")
.typography(style: .interactive)
TypographyKit.configure(
with: TypographyKitConfiguration.default
.setConfigurationURL(configurationURL)
)
```

A letter case may be applied directly to the String as follows:
Alternatively, an `async` version of this method exists for developers supporting iOS 13 and above:

```swift
"An example using TypographyKit with SwiftUI"
.letterCase(style: .interactive)
await TypographyKit.configure(with:
TypographyKitConfiguration.default.setConfigurationURL(configurationURL)
)
```
- All configuration properties specified programmatically may alternatively be specified in the TypographyKit configuration file.
- Note: Values in the configuration file override those specified programmatically.

This results in the letter case defined for the specified typography style (in config) being applied.
For a detailed list of changes, see [CHANGELOG.md](CHANGELOG.md).

## Installation

Expand Down
7 changes: 5 additions & 2 deletions TypographyKit/Classes/TypographyKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public struct TypographyKit {

public static func tkColor(named colorName: String) -> TypographyColor {
guard let color = colors[colorName] else {
LoggingService.log(error: .notFound(element: colorName), key: colorName)
if isDevelopment {
if shouldCrashIfColorNotFound {
fatalError("Unable to locate color named '\(colorName)' and 'shouldCrashIfColorNotFound' = 'true'.")
Expand Down Expand Up @@ -411,7 +412,8 @@ private extension TypographyKit {
static func loadSettings(
configuration: TypographyKitConfiguration
) async -> TypographyKitSettings? {
guard let configurationURL = configuration.configurationURL, let data = try? Data(contentsOf: configurationURL) else {
guard let configurationURL = configuration.configurationURL,
let data = try? Data(contentsOf: configurationURL) else {
// Data not received - load from cache.
guard case let .success(model) = loadSettings(from: nil, configuration: configuration) else {
return nil
Expand All @@ -427,7 +429,8 @@ private extension TypographyKit {
static func loadSettingsSync(
configuration: TypographyKitConfiguration
) -> TypographyKitSettings? {
guard let configurationURL = configuration.configurationURL, let data = try? Data(contentsOf: configurationURL) else {
guard let configurationURL = configuration.configurationURL,
let data = try? Data(contentsOf: configurationURL) else {
// Data not received - load from cache.
guard case let .success(model) = loadSettings(from: nil, configuration: configuration) else {
return nil
Expand Down
5 changes: 4 additions & 1 deletion TypographyKit/Classes/TypographyKitConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ let isDevelopment = false
configurationURL: configurationURL,
developmentColor: developmentColor,
isDevelopment: isDevelopment,
fallbackColor: .clear,
fallbackColor: .dynamicColor(colors: [
.light: .black,
.dark: .white
]),
labels: LabelSettings(lineBreakMode: .byWordWrapping),
minPointSize: nil,
maxPointSize: nil,
Expand Down

0 comments on commit e0d64af

Please sign in to comment.