         return closest
     }
 
-    
 }
 
 // TODO: move extension to separate file.
 extension UIFont {
     
     func fontWithWeight(weight: CGFloat) -> UIFont {
-        let fontWeight = FontWeight.fontWeightForApproximateWeight(weight)
-        let traits = [UIFontWeightTrait: fontWeight.rawValue]
+        let validWeight: CGFloat
+        if #available(iOS 8.2, *) {
+            let fontWeight = FontWeight.fontWeightForApproximateWeight(weight)
+            validWeight = fontWeight.rawValue
+        } else {
+            validWeight = weight
+        }
+        let traits = [UIFontWeightTrait: validWeight]
         let attributes: TextAttributes = [UIFontDescriptorFamilyAttribute: familyName, UIFontDescriptorTraitsAttribute: traits]
         let descriptor = UIFontDescriptor(fontAttributes: attributes)
         let font = UIFont(descriptor: descriptor, size: pointSize)

    
}

enum FontWeight {
    
    case ultraLight

        if let familyName = flatDict[Key.familyName] as? String {
            attributes[UIFontDescriptorFamilyAttribute] = familyName
            if let weight = flatDict[Key.weight] as? CGFloat {
                let validWeight: CGFloat
                if #available(iOS 8.2, *) {
                    let fontWeight = FontWeight.fontWeightForApproximateWeight(weight)
                    validWeight = fontWeight.rawValue
                } else {
                    validWeight = weight
                }
                let traits = [UIFontWeightTrait: validWeight]
                attributes[UIFontDescriptorTraitsAttribute] = traits
            }
