Browse Source

【文字图片编辑】默认参数填充

lizhe 1 year ago
parent
commit
2ae75e84a7

+ 23 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditPDFTextPropertyViewController.swift

@@ -266,13 +266,18 @@ class KMEditPDFTextPropertyViewController: NSViewController {
             if areas is CPDFEditTextArea  {
                 let sizeString = "\(abs(self.listView.editingSelectionFontSize()))"
                 let fontName: String = self.listView.editingSelectionFontName() ?? "Helvetica"
-
+                let alignment = self.listView.editingSelectionAlignment()
+                var color = self.listView.editingSelectionFontColor() ?? NSColor.black
+                
                 self.updateTextPresupposition(fontName: fontName, size: CGFloat(Float(sizeString)!), needChangeListView: false)
                 
-                self.currentColor = self.listView.editingSelectionFontColor() ?? NSColor.black
-                NSColorPanel.shared.color = self.currentColor
-                self.fontColorButton.image = self.swatchWithColor(color: self.currentColor, size: NSSize(width: 20, height: 20))
-                self.alignment = self.listView.editingSelectionAlignment()
+                self.currentColor = color
+                NSColorPanel.shared.color = color
+                self.fontColorButton.image = self.swatchWithColor(color: color, size: NSSize(width: 20, height: 20))
+                
+                self.alignment = alignment
+                self.selectAlignment(alignment: alignment)
+                
                 self.updatePreviewImage()
             }
         }
@@ -355,6 +360,19 @@ extension KMEditPDFTextPropertyViewController {
         self.updateAlignment(alignment: .right)
     }
     
+    func selectAlignment(alignment: NSTextAlignment) {
+        switch alignment {
+        case .left:
+            self.leftAlignmentAction()
+        case .right:
+            self.rightAlignmentAction()
+        case .center:
+            self.centerAlignmentAction()
+        default:
+            self.leftAlignmentAction()
+        }
+    }
+    
     func updateAlignment(alignment: NSTextAlignment) {
         if self.alignment != alignment {
             if self.listView.editingAreas()?.count ?? 0 > 0 {