Skip to content

Commit

Permalink
Merge pull request #2 from Heads-and-Hands/feature/ligatures
Browse files Browse the repository at this point in the history
Add ligatures setting for text style
  • Loading branch information
ct4h authored Apr 13, 2021
2 parents 448e43f + 0d52dcf commit b7ba829
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/ViewStyler/TextStyle/Styles/VSTextBaseStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ public protocol VSTextBaseStyle {
var color: UIColor? { get }
var underlineStyle: NSUnderlineStyle? { get }
var letterSpacing: CGFloat? { get }
var useLigatures: Bool { get }
}

public extension VSTextBaseStyle {
var color: UIColor? { nil }
var underlineStyle: NSUnderlineStyle? { nil }
var letterSpacing: CGFloat? { nil }
var useLigatures: Bool { true }
}
8 changes: 8 additions & 0 deletions Sources/ViewStyler/TextStyle/VSStyleProvider+BaseStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public extension VSStyleProvider where View: VSStringView {
add(letterSpacing: letterSpacing)
}

add(ligatures: fontStyle.useLigatures)

return self
}

Expand All @@ -51,4 +53,10 @@ public extension VSStyleProvider where View: VSStringView {
view.addAttribute(.kern, value: letterSpacing)
return self
}

@discardableResult
func add(ligatures flag: Bool) -> VSStyleProvider<View> {
view.addAttribute(.ligature, value: flag ? 1 : 0)
return self
}
}

0 comments on commit b7ba829

Please sign in to comment.