Skip to content

Commit

Permalink
[Typography] Use MDFTextAccessibility's isLargeForContrastRatios.
Browse files Browse the repository at this point in the history
This is part of a larger effort to break apart and trim down the size of our typography solutions.

PiperOrigin-RevId: 316484500
  • Loading branch information
Jeff Verkoeyen authored and material-automation committed Jun 15, 2020
1 parent df66587 commit 244dd62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions MaterialComponents.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ Pod::Spec.new do |mdc|

component.dependency "MaterialComponents/private/Application"
component.dependency "MaterialComponents/private/Math"
component.dependency "MDFTextAccessibility"

component.test_spec 'UnitTests' do |unit_tests|
unit_tests.source_files = [
Expand Down
8 changes: 3 additions & 5 deletions components/Typography/src/MDCTypography.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
// limitations under the License.

#import "MDCTypography.h"

#import "private/UIFont+MaterialTypographyPrivate.h"
#import <MDFTextAccessibility/MDFTextAccessibility.h>

static id<MDCTypographyFontLoading> gFontLoader = nil;
const CGFloat MDCTypographyStandardOpacity = (CGFloat)0.87;
Expand Down Expand Up @@ -144,11 +146,7 @@ + (BOOL)isLargeForContrastRatios:(nonnull UIFont *)font {
return [fontLoader isLargeForContrastRatios:font];
}

// Copied from [MDFTextAccessibility isLargeForContrastRatios:]
UIFontDescriptor *fontDescriptor = font.fontDescriptor;
BOOL isBold =
(fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold) == UIFontDescriptorTraitBold;
return font.pointSize >= 18 || (isBold && font.pointSize >= 14);
return [MDFTextAccessibility isLargeForContrastRatios:font];
}

+ (UIFont *)italicFontFromFont:(UIFont *)font {
Expand Down

0 comments on commit 244dd62

Please sign in to comment.