You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 5, 2022. It is now read-only.
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;
}