Various Improvements

This commit is contained in:
Ilya Laktyushin
2022-04-23 05:28:29 +04:00
parent e3dc5cbe8a
commit 71bde57b6a
90 changed files with 1757 additions and 297 deletions

View File

@@ -892,7 +892,9 @@ public class TextNode: ASDisplayNode {
static func calculateLayout(attributedString: NSAttributedString?, minimumNumberOfLines: Int, maximumNumberOfLines: Int, truncationType: CTLineTruncationType, backgroundColor: UIColor?, constrainedSize: CGSize, alignment: NSTextAlignment, verticalAlignment: TextVerticalAlignment, lineSpacingFactor: CGFloat, cutout: TextNodeCutout?, insets: UIEdgeInsets, lineColor: UIColor?, textShadowColor: UIColor?, textStroke: (UIColor, CGFloat)?, displaySpoilers: Bool) -> TextNodeLayout {
if let attributedString = attributedString {
if attributedString.string.hasPrefix("Д") {
print()
}
let stringLength = attributedString.length
let font: CTFont
@@ -1290,6 +1292,9 @@ public class TextNode: ASDisplayNode {
var clearRects: [CGRect] = []
if let layout = parameters as? TextNodeLayout {
if (layout.attributedString?.string ?? "").hasPrefix("Д") {
print()
}
if !isRasterizing || layout.backgroundColor != nil {
context.setBlendMode(.copy)
context.setFillColor((layout.backgroundColor ?? UIColor.clear).cgColor)
@@ -1334,10 +1339,13 @@ public class TextNode: ASDisplayNode {
if alignment == .center {
lineFrame.origin.x = offset.x + floor((bounds.size.width - lineFrame.width) / 2.0)
} else if alignment == .natural, line.isRTL {
lineFrame.origin.x = offset.x + floor(bounds.size.width - lineFrame.width)
lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: bounds.size), cutout: layout.cutout)
} else if alignment == .natural {
if line.isRTL {
lineFrame.origin.x = offset.x + floor(bounds.size.width - lineFrame.width)
lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: bounds.size), cutout: layout.cutout)
} else {
lineFrame.origin.x += offset.x
}
}
context.textPosition = CGPoint(x: lineFrame.minX, y: lineFrame.minY)