2014-11-24 21:51:43 +01:00
|
|
|
//
|
|
|
|
// UIFont+OWS.m
|
|
|
|
// Signal
|
|
|
|
//
|
|
|
|
// Created by Dylan Bourgeois on 25/11/14.
|
|
|
|
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "UIFont+OWS.h"
|
2016-10-06 15:44:25 +02:00
|
|
|
#import "iOSVersions.h"
|
2014-11-24 21:51:43 +01:00
|
|
|
|
|
|
|
@implementation UIFont (OWS)
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
+ (UIFont *)ows_thinFontWithSize:(CGFloat)size {
|
2017-01-10 18:33:14 +01:00
|
|
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) {
|
|
|
|
return [UIFont systemFontOfSize:size weight:UIFontWeightThin];
|
|
|
|
} else {
|
|
|
|
return [UIFont fontWithName:@"HelveticaNeue-Thin" size:size];
|
|
|
|
}
|
2014-11-24 21:51:43 +01:00
|
|
|
}
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
+ (UIFont *)ows_lightFontWithSize:(CGFloat)size {
|
2017-01-10 18:33:14 +01:00
|
|
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) {
|
|
|
|
return [UIFont systemFontOfSize:size weight:UIFontWeightLight];
|
|
|
|
} else {
|
|
|
|
return [UIFont fontWithName:@"HelveticaNeue-Light" size:size];
|
|
|
|
}
|
2014-11-24 21:51:43 +01:00
|
|
|
}
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
+ (UIFont *)ows_regularFontWithSize:(CGFloat)size {
|
2017-01-10 18:33:14 +01:00
|
|
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) {
|
|
|
|
return [UIFont systemFontOfSize:size weight:UIFontWeightRegular];
|
|
|
|
} else {
|
|
|
|
return [UIFont fontWithName:@"HelveticaNeue" size:size];
|
|
|
|
}
|
2014-11-24 21:51:43 +01:00
|
|
|
}
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
+ (UIFont *)ows_mediumFontWithSize:(CGFloat)size {
|
2017-01-10 18:33:14 +01:00
|
|
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) {
|
|
|
|
return [UIFont systemFontOfSize:size weight:UIFontWeightMedium];
|
|
|
|
} else {
|
|
|
|
return [UIFont fontWithName:@"HelveticaNeue-Medium" size:size];
|
|
|
|
}
|
2014-12-06 19:26:01 +01:00
|
|
|
}
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
+ (UIFont *)ows_boldFontWithSize:(CGFloat)size {
|
2015-09-01 19:22:08 +02:00
|
|
|
return [UIFont boldSystemFontOfSize:size];
|
2014-11-24 21:51:43 +01:00
|
|
|
}
|
|
|
|
|
2015-12-26 17:27:27 +01:00
|
|
|
#pragma mark Dynamic Type
|
|
|
|
|
|
|
|
+ (UIFont *)ows_dynamicTypeBodyFont {
|
|
|
|
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
|
|
|
}
|
|
|
|
|
2016-10-06 21:47:45 +02:00
|
|
|
+ (UIFont *)ows_infoMessageFont
|
|
|
|
{
|
|
|
|
return [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
|
|
|
|
}
|
|
|
|
|
2016-10-06 15:44:25 +02:00
|
|
|
+ (UIFont *)ows_dynamicTypeTitle2Font {
|
2017-01-10 18:33:14 +01:00
|
|
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) {
|
2016-10-06 15:44:25 +02:00
|
|
|
return [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
|
|
|
|
} else {
|
|
|
|
// Dynamic title font for ios8 defaults to bold 12.0 pt, whereas ios9+ it's 22.0pt regular weight.
|
|
|
|
// Here we chose to break dynamic font, in order to have uniform style across versions.
|
|
|
|
// It's already huge, so it's unlikely to present a usability issue.
|
|
|
|
// Handy font translations: http://swiftiostutorials.com/comparison-of-system-fonts-on-ios-8-and-ios-9/
|
|
|
|
return [self ows_regularFontWithSize:22.0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-24 21:51:43 +01:00
|
|
|
@end
|