mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Raise deployment target to iOS 9 (#743)
https://github.com/TextureGroup/Texture/pull/743 Manually merged since I forgot to retarget that diff onto master before merge
This commit is contained in:
@@ -600,7 +600,10 @@ return style. _attr_;
|
||||
dispatch_once(&onceToken, ^{
|
||||
failSet = [NSMutableSet new];
|
||||
[failSet addObject:(id)kCTGlyphInfoAttributeName];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[failSet addObject:(id)kCTCharacterShapeAttributeName];
|
||||
#pragma clang diagnostic pop
|
||||
[failSet addObject:(id)kCTLanguageAttributeName];
|
||||
[failSet addObject:(id)kCTRunDelegateAttributeName];
|
||||
[failSet addObject:(id)kCTBaselineClassAttributeName];
|
||||
@@ -1049,7 +1052,10 @@ style. _attr_ = _attr_; \
|
||||
}
|
||||
|
||||
- (void)as_setCharacterShape:(NSNumber *)characterShape range:(NSRange)range {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self as_setAttribute:(id)kCTCharacterShapeAttributeName value:characterShape range:range];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)as_setRunDelegate:(CTRunDelegateRef)runDelegate range:(NSRange)range {
|
||||
@@ -1178,51 +1184,6 @@ style. _attr_ = _attr_; \
|
||||
[self as_removeDiscontinuousAttributesInRange:NSMakeRange(length, string.length)];
|
||||
}
|
||||
|
||||
- (void)as_setClearColorToJoinedEmoji {
|
||||
NSString *str = self.string;
|
||||
if (str.length < 8) return;
|
||||
|
||||
// Most string do not contains the joined-emoji, test the joiner first.
|
||||
BOOL containsJoiner = NO;
|
||||
{
|
||||
CFStringRef cfStr = (__bridge CFStringRef)str;
|
||||
BOOL needFree = NO;
|
||||
UniChar *chars = NULL;
|
||||
chars = (UniChar *)CFStringGetCharactersPtr(cfStr);
|
||||
if (!chars) {
|
||||
chars = (UniChar *)malloc(str.length * sizeof(UniChar));
|
||||
if (chars) {
|
||||
needFree = YES;
|
||||
CFStringGetCharacters(cfStr, CFRangeMake(0, str.length), chars);
|
||||
}
|
||||
}
|
||||
if (!chars) { // fail to get unichar..
|
||||
containsJoiner = YES;
|
||||
} else {
|
||||
for (int i = 0, max = (int)str.length; i < max; i++) {
|
||||
if (chars[i] == 0x200D) { // 'ZERO WIDTH JOINER' (U+200D)
|
||||
containsJoiner = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needFree) free(chars);
|
||||
}
|
||||
}
|
||||
if (!containsJoiner) return;
|
||||
|
||||
// NSRegularExpression is designed to be immutable and thread safe.
|
||||
static NSRegularExpression *regex;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
regex = [NSRegularExpression regularExpressionWithPattern:@"((👨👩👧👦|👨👩👦👦|👨👩👧👧|👩👩👧👦|👩👩👦👦|👩👩👧👧|👨👨👧👦|👨👨👦👦|👨👨👧👧)+|(👨👩👧|👩👩👦|👩👩👧|👨👨👦|👨👨👧))" options:kNilOptions error:nil];
|
||||
});
|
||||
|
||||
UIColor *clear = [UIColor clearColor];
|
||||
[regex enumerateMatchesInString:str options:kNilOptions range:NSMakeRange(0, str.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
|
||||
[self as_setColor:clear range:result.range];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)as_removeDiscontinuousAttributesInRange:(NSRange)range {
|
||||
NSArray *keys = [NSMutableAttributedString as_allDiscontinuousAttributeKeys];
|
||||
for (NSString *key in keys) {
|
||||
|
||||
Reference in New Issue
Block a user