Browse Source

【快捷键】编辑文本时,未支持使用快捷键 opt + cmd + + 放大或缩小字体

lizhe 9 months ago
parent
commit
d51bb7674c

+ 22 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -472,6 +472,11 @@ import Cocoa
         } else {
             self.applyPDFSettings(savedNormalSetup)
         }
+        
+        //文字
+        let fontManager = NSFontManager.shared
+        fontManager.target = self
+        fontManager.action = #selector(changeFont(_:))
     }
     
     //MARK: - PDFListView
@@ -2348,3 +2353,20 @@ extension KMMainViewController {
         }
     }
 }
+
+extension KMMainViewController {
+    func changeFont(_ sender: NSFontManager) {
+        KMPrint("changeFont ...")
+        if ((self.listView.activeAnnotation?.isKind(of: CPDFFreeTextAnnotation.self)) != nil) {
+            let annotation: CPDFFreeTextAnnotation = self.listView.activeAnnotation as! CPDFFreeTextAnnotation
+            var font = NSFont(name: annotation.fontName() ?? "Helvetica", size: (annotation.fontSize()) )
+            font = sender.convert(font!)
+            
+            annotation.setFontSize(font!.pointSize)
+            
+            self.listView.commitEditAnnotationFreeText(annotation)
+            self.listView.setNeedsDisplay(annotation)
+//            self.listView.setNeedsDisplayAnnotationViewFor(annotation.page)
+        }
+    }
+}