This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… logic (#4124) Co-authored-by: Brandon T <JustBrandonT@gmail.com>
- Loading branch information
1 parent
4c01bcd
commit 46ca3c1
Showing
20 changed files
with
1,400 additions
and
13 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,21 @@ | ||
// Copyright 2021 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import UIKit | ||
|
||
extension UIFont { | ||
|
||
/// Extended Dynamic Font Function for custom weight | ||
/// - Parameters: | ||
/// - style: textStyle for the dynamic font | ||
/// - weight: weight of the dynamic font to be adjusted | ||
public static func preferredFont(for style: TextStyle, weight: Weight) -> UIFont { | ||
let fontMetrics = UIFontMetrics(forTextStyle: style) | ||
let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style) | ||
let font = UIFont.systemFont(ofSize: fontDescriptor.pointSize, weight: weight) | ||
|
||
return fontMetrics.scaledFont(for: font) | ||
} | ||
} |
Oops, something went wrong.