File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
WooCommerce/Classes/Extensions Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -84,12 +84,19 @@ extension UIFont {
8484 return UIFontMetrics ( forTextStyle: style) . scaledFont ( for: noticonFont)
8585 }
8686
87- /// Returns a UIFont instance for the specified Style + Weight.
87+ /// Returns a UIFont instance for the specified Style + Weight + Max Size .
8888 ///
89- class func font( forStyle style: UIFont . TextStyle , weight: UIFont . Weight ) -> UIFont {
89+ class func font( forStyle style: UIFont . TextStyle , weight: UIFont . Weight , maxFontSize : CGFloat ? = nil ) -> UIFont {
9090 let descriptor = UIFontDescriptor
9191 . preferredFontDescriptor ( withTextStyle: style)
9292 . addingAttributes ( [ . traits: [ UIFontDescriptor . TraitKey. weight: weight] ] )
93+
94+ // Limit the font size if needed
95+ if let maxFontSize, descriptor. pointSize > maxFontSize {
96+ return UIFont ( descriptor: descriptor, size: maxFontSize)
97+ }
98+
99+ // Return font without a predefined size.
93100 return UIFont ( descriptor: descriptor, size: 0 )
94101 }
95102
You can’t perform that action at this time.
0 commit comments