@@ -70,13 +70,16 @@ extension Typography {
7070
7171// MARK: - Default implementations
7272
73+ /// Default implementations
7374extension FontFamily {
74- // returns no suffix
75+ /// Returns no suffix
7576 public var fontNameSuffix : String { " " }
7677
77- // returns all weights
78+ /// Returns all weights
7879 public var supportedWeights : [ Typography . FontWeight ] { Typography . FontWeight. allCases }
7980
81+ /// Generates the font to be used using `UIFont(name:size:)` and the name generated by
82+ /// `fontName(weight:traitCollection:)`
8083 public func font(
8184 for weight: Typography . FontWeight ,
8285 pointSize: CGFloat ,
@@ -95,6 +98,8 @@ extension FontFamily {
9598 return font
9699 }
97100
101+ /// Generates the font name by combining family name, the weight name
102+ /// (potentially adjusted for Bold Text), and suffix.
98103 public func fontName(
99104 for weight: Typography . FontWeight ,
100105 compatibleWith traitCollection: UITraitCollection ?
@@ -106,6 +111,7 @@ extension FontFamily {
106111 return " \( familyName) - \( weightName) \( fontNameSuffix) "
107112 }
108113
114+ /// Returns default name for each weight
109115 public func weightName( for weight: Typography . FontWeight ) -> String {
110116 // Default font name suffix by weight
111117 switch weight {
@@ -130,8 +136,8 @@ extension FontFamily {
130136 }
131137 }
132138
139+ /// Returns the next heavier supported weight (if any), otherwise the heaviest supported weight
133140 public func accessibilityBoldWeight( for weight: Typography . FontWeight ) -> Typography . FontWeight {
134- // By default returns the next heavier supported weight (if any), otherwise the heaviest supported weight
135141 let weights = supportedWeights. sorted ( by: { $0. rawValue < $1. rawValue } )
136142 // return the next heavier supported weight
137143 return weights. first ( where: { $0. rawValue > weight. rawValue } ) ?? weights. last ?? weight
0 commit comments