Skip to content

Commit

Permalink
Merge pull request airbnb#1337 from khalideali/textGeometry
Browse files Browse the repository at this point in the history
Take flipped geometry into account when drawing text
  • Loading branch information
buba447 authored Apr 13, 2021
2 parents b3c60ba + 1c565db commit 2fbef2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class TextCompositionLayer: CompositionLayer {
super.init(layer: textLayer, size: .zero)
contentsLayer.addSublayer(self.textLayer)
self.textLayer.masksToBounds = false
self.textLayer.isGeometryFlipped = true

if let rootNode = rootNode {
childKeypaths.append(rootNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ final class TextLayer: CALayer {
ctx.setShouldSubpixelPositionFonts(true)
ctx.setShouldSubpixelQuantizeFonts(true)

ctx.translateBy(x: 0, y: drawingRect.height)
ctx.scaleBy(x: 1.0, y: -1.0)
if self.contentsAreFlipped() {
ctx.translateBy(x: 0, y: drawingRect.height)
ctx.scaleBy(x: 1.0, y: -1.0)
}

let drawingPath = CGPath(rect: drawingRect, transform: nil)

Expand Down

0 comments on commit 2fbef2e

Please sign in to comment.