session-ios/Signal/src/util/UIFont+OWS.m

74 lines
2.2 KiB
Mathematica
Raw Normal View History

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"
#import "iOSVersions.h"
2014-11-24 21:51:43 +01:00
@implementation UIFont (OWS)
+ (UIFont *)ows_thinFontWithSize:(CGFloat)size {
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
}
+ (UIFont *)ows_lightFontWithSize:(CGFloat)size {
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
}
+ (UIFont *)ows_regularFontWithSize:(CGFloat)size {
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
}
+ (UIFont *)ows_mediumFontWithSize:(CGFloat)size {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(8, 2)) {
return [UIFont systemFontOfSize:size weight:UIFontWeightMedium];
} else {
return [UIFont fontWithName:@"HelveticaNeue-Medium" size:size];
}
}
+ (UIFont *)ows_boldFontWithSize:(CGFloat)size {
iOS 9 Support - Fixing size classes rendering bugs. - Supporting native iOS San Francisco font. - Quick Reply - Settings now slide to the left as suggested in original designed opposed to modal. - Simplification of restraints on many screens. - Full-API compatiblity with iOS 9 and iOS 8 legacy support. - Customized AddressBook Permission prompt when restrictions are enabled. If user installed Signal previously and already approved access to Contacts, don't bugg him again. - Fixes crash in migration for users who installed Signal <2.1.3 but hadn't signed up yet. - Xcode 7 / iOS 9 Travis Support - Bitcode Support is disabled until it is better understood how exactly optimizations are performed. In a first time, we will split out the crypto code into a separate binary to make it easier to optimize the non-sensitive code. Blog post with more details coming. - Partial ATS support. We are running our own Certificate Authority at Open Whisper Systems. Signal is doing certificate pinning to verify that certificates were signed by our own CA. Unfortunately Apple's App Transport Security requires to hand over chain verification to their framework with no control over the trust store. We have filed a radar to get ATS features with pinned certificates. In the meanwhile, ATS is disabled on our domain. We also followed Amazon's recommendations for our S3 domain we use to upload/download attachments. (#891) - Implement a unified `AFSecurityOWSPolicy` pinning strategy accross libraries (AFNetworking RedPhone/TextSecure & SocketRocket).
2015-09-01 19:22:08 +02:00
return [UIFont boldSystemFontOfSize:size];
2014-11-24 21:51:43 +01:00
}
#pragma mark Dynamic Type
+ (UIFont *)ows_dynamicTypeBodyFont {
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
}
+ (UIFont *)ows_infoMessageFont
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
}
+ (UIFont *)ows_dynamicTypeTitle2Font {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) {
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