The UIFont interface doesn't expose any methods to access the weight property of a font. The current implementation of -isLargeForContrastRatios: wants to treat medium weight fonts as bold, and it looks in the font name for the substring "medium". This is somewhat brittle.
The CoreText font interface does expose the weight property, and since this class is toll-free bridged to UIFont, the implementation ought to use CoreText to inspect the true weight attribute, something like this:
The UIFont interface doesn't expose any methods to access the weight property of a font. The current implementation of -isLargeForContrastRatios: wants to treat medium weight fonts as bold, and it looks in the font name for the substring "medium". This is somewhat brittle.
The CoreText font interface does expose the weight property, and since this class is toll-free bridged to UIFont, the implementation ought to use CoreText to inspect the true weight attribute, something like this:
CTFontRef coreTextFont = (bridge CTFontRef)font; CFDictionaryRef coreTextFontTraits = CTFontCopyTraits(coreTextFont); NSDictionary *fontTraits = (bridge NSDictionary )coreTextFontTraits; NSNumber fontWeight = fontTraits[(NSString *)kCTFontWeightTrait]; CFRelease(coreTextFontTraits);
if (fontWeight.floatValue >= (UIFontWeightMedium - FLT_EPSILON)) { return YES; }