mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various fixes
This commit is contained in:
@@ -1411,10 +1411,14 @@ open class TextNode: ASDisplayNode {
|
||||
context.setAllowsFontSubpixelQuantization(true)
|
||||
context.setShouldSubpixelQuantizeFonts(true)
|
||||
|
||||
var blendMode: CGBlendMode = .normal
|
||||
|
||||
var clearRects: [CGRect] = []
|
||||
if let layout = parameters as? TextNodeLayout {
|
||||
if !isRasterizing || layout.backgroundColor != nil {
|
||||
context.setBlendMode(.copy)
|
||||
blendMode = .copy
|
||||
|
||||
context.setFillColor((layout.backgroundColor ?? UIColor.clear).cgColor)
|
||||
context.fill(bounds)
|
||||
}
|
||||
@@ -1426,6 +1430,8 @@ open class TextNode: ASDisplayNode {
|
||||
|
||||
if let (textStrokeColor, textStrokeWidth) = layout.textStroke {
|
||||
context.setBlendMode(.normal)
|
||||
blendMode = .normal
|
||||
|
||||
context.setLineCap(.round)
|
||||
context.setLineJoin(.round)
|
||||
context.setStrokeColor(textStrokeColor.cgColor)
|
||||
@@ -1487,7 +1493,28 @@ open class TextNode: ASDisplayNode {
|
||||
if attributes["Attribute__EmbeddedItem"] != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var fixCoupleEmoji = false
|
||||
if glyphCount == 2, let font = attributes["NSFont"] as? UIFont, font.fontName.contains("ColorEmoji"), let string = layout.attributedString {
|
||||
let range = CTRunGetStringRange(run)
|
||||
let substring = string.attributedSubstring(from: NSMakeRange(range.location, range.length)).string
|
||||
|
||||
let heart = Unicode.Scalar(0x2764)!
|
||||
let man = Unicode.Scalar(0x1F468)!
|
||||
let woman = Unicode.Scalar(0x1F469)!
|
||||
|
||||
if substring.unicodeScalars.contains(heart) && (substring.unicodeScalars.contains(man) || substring.unicodeScalars.contains(woman)) {
|
||||
fixCoupleEmoji = true
|
||||
}
|
||||
}
|
||||
|
||||
if fixCoupleEmoji {
|
||||
context.setBlendMode(.normal)
|
||||
}
|
||||
CTRunDraw(run, context, CFRangeMake(0, glyphCount))
|
||||
if fixCoupleEmoji {
|
||||
context.setBlendMode(blendMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user