title: How to scale multiline text by gesture in SwiftUI
body: <p>I need to implement multiline text scaling by gesture. I tried to use scaleEffect() but it's become blurry and pixelized (first gif). Then I tried to change font directly from gesture but faced another problem: text starts jumping, changing line breaks and etc (second gif). fixedSize() can't solve this because it's multiline text.
  I need to implement scaling like with scaleEffect() but without blurring like with scaling font directly. Here's my code:</p>
  <pre><code>struct ContentView: View {
  
      @State var activeTextScale: CGFloat = 1.0
      @State var lastScale: CGFloat = 1.0
      @State var fontSize: CGFloat = 24
  
      var body: some View {
          ZStack {
              ZStack {
                  Text(
                      &quot;Abcdefghijklmnopqrstuvwxyz Abcdefghijklmnopqrstuvwxyz Abcdefghijklmnopqrstuvwxyz&quot;
                  )
                  .foregroundColor(.yellow)
                  //                    .scaleEffect(activeTextScale)
                  .font(.system(size: fontSize * activeTextScale))
                  .background(
                      Rectangle()
                          .foregroundColor(.brown.opacity(0.6))
                      //                            .scaleEffect(activeTextScale)
                  )
                  .gesture(
                      MagnificationGesture()
                          .onChanged { value in
                              activeTextScale = value + lastScale
                          }
                          .onEnded { value in
                              lastScale = activeTextScale
                          }
                  )
              }
          }
      }
  }
  </code></pre>
  <p>Here I'm tried to scale font and view accordingly, but it gives the same result as on second gif:</p>
  <pre><code>struct ContentView: View {
  
      @State var activeTextScale: CGFloat = 1.0
      @State var lastScale: CGFloat = 1.0
      @State var fontSize: CGFloat = 24
  
      func getTextFontSize() -&gt; CGFloat {
          let size = fontSize * activeTextScale
          print(activeTextScale)
          print(size.rounded())
          return size.rounded()
      }
  
      var body: some View {
          ZStack {
              VStack {
                  Text(
                      &quot;Abcdefghijklmnopqrstuvwxyz Abcdefghijklmnopqrstuvwxyz Abcdefghijklmnopqrstuvwxyz&quot;
                  )
                  .foregroundColor(.yellow)
                  .font(.system(size: getTextFontSize()))
                  .background(
                      Rectangle()
                          .foregroundColor(.brown.opacity(0.6))
                  )
  
              }
              .scaleEffect(activeTextScale)
              .gesture(
                  MagnificationGesture()
                      .onChanged { value in
                          activeTextScale = value + lastScale
                      }
                      .onEnded { value in
                          lastScale = activeTextScale
                      }
              )
          }
      }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/8Sodr.gif" rel="nofollow noreferrer">First gif with scaleEffect()</a></p>
  <p><a href="https://i.stack.imgur.com/sjvYm.gif" rel="nofollow noreferrer">Second gif with font scaling</a></p>
  <p><a href="https://i.stack.imgur.com/nU25B.gif" rel="nofollow noreferrer">Third gif with scaling view and font accordingly</a></p>