     /// Arbitrary value out of range -1.0 to 1.0.
     static let notSet: CGFloat = -2.0
     
-    static func weightForName(name: String) -> FontWeight? {
+    static func fontWeightForName(name: String) -> FontWeight? {
         return all.filter { $0.name == name }.first
     }
+    
+    static func fontWeightForApproximateWeight(approximateWeight: CGFloat) -> FontWeight {
+        var closest: FontWeight = .medium
+        for possible in all {
+            if abs(possible.rawValue - approximateWeight) < abs(closest.rawValue - approximateWeight) {
+                closest = possible
+            }
+        }
+        return closest
+    }
+
     
 }
 

        if let familyName = flatDict[Key.familyName] as? String {
            attributes[UIFontDescriptorFamilyAttribute] = familyName
            if let weight = flatDict[Key.weight] as? CGFloat {
                let validWeight = weight.validWeight
                let traits = [UIFontWeightTrait: validWeight]
                attributes[UIFontDescriptorTraitsAttribute] = traits
            }

extension UIFont {
    
    func fontWithWeight(weight: CGFloat) -> UIFont {
        let fontWeight = FontWeight.fontWeightForApproximateWeight(weight)
        let traits = [UIFontWeightTrait: fontWeight.rawValue]
        let attributes: TextAttributes = [UIFontDescriptorFamilyAttribute: familyName, UIFontDescriptorTraitsAttribute: traits]
        let descriptor = UIFontDescriptor(fontAttributes: attributes)
        let font = UIFont(descriptor: descriptor, size: pointSize)
