-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* β¨ Add FontModifier * π Change availability from iOSApplicationExtension to iOS * π§ Use recommended build settings * π§ Do not run changelog check for forks * π Update changelog --------- Co-authored-by: Jakub Olejnik <[email protected]>
- Loading branch information
1 parent
f7d0999
commit f0ad9c2
Showing
9 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import SwiftUI | ||
|
||
@available(iOS 14.0, *) | ||
public extension View { | ||
/// Sets font and line height for text in this view. | ||
/// | ||
/// - Parameters: | ||
/// - font: The font to use in this view. | ||
/// - lineHeight: The line height to use in this view. | ||
/// - textStyle: The text style for relative font scaling. If `nil`is specified then dynamic type is turned off. | ||
func font( | ||
_ font: UIFont, | ||
lineHeight: Double, | ||
textStyle: Font.TextStyle? | ||
) -> some View { | ||
let customFont: Font | ||
|
||
// Do not scale font based on dynamic type when nil `relativeTo` specified | ||
if let textStyle = textStyle { | ||
customFont = .custom( | ||
font.fontName, | ||
size: font.pointSize, | ||
relativeTo: textStyle | ||
) | ||
} else { | ||
customFont = Font(font) | ||
} | ||
|
||
return self | ||
.font(customFont) | ||
.lineSpacing(lineHeight - font.lineHeight) | ||
.padding(.vertical, (lineHeight - font.lineHeight) / 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategories-iOS.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategoriesCore.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategoriesExample.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters