marinofaggiana 4 years ago
parent
commit
3a5e9bb73b
1 changed files with 9 additions and 3 deletions
  1. 9 3
      iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

+ 9 - 3
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -527,11 +527,17 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
                                 t = t.scaledBy(x: image.size.width, y: -image.size.height)
                                 t = t.translatedBy(x: 0, y: -1)
                                 let rect = observation.boundingBox.applying(t)
-                                                                
+                                let text = textLine.string
+
                                 let font = UIFont.systemFont(ofSize: rect.size.height, weight: .regular)
-                                let bestFont = self.bestFittingFont(for: textLine.string, in: rect, fontDescriptor: font.fontDescriptor)
+                                let bestFont = self.bestFittingFont(for: text, in: rect, fontDescriptor: font.fontDescriptor)
+                                
+                                let paragraphStyle = NSMutableParagraphStyle()
+                                paragraphStyle.alignment = .justified
+
+                                let attributes = [NSAttributedString.Key.font: bestFont, NSAttributedString.Key.paragraphStyle: paragraphStyle, NSAttributedString.Key.foregroundColor: fontColor]
                                 
-                                textLine.string.draw(in: rect, withAttributes: [NSAttributedString.Key.font: bestFont, NSAttributedString.Key.foregroundColor: fontColor])
+                                text.draw(with: rect, options: .usesLineFragmentOrigin, attributes: attributes, context: nil)
                             }
                         }