Browse Source

【Form】文字域调整字体无效修复

lizhe 10 tháng trước cách đây
mục cha
commit
cde769cb01

+ 18 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationFromViewController.swift

@@ -530,6 +530,24 @@ import Cocoa
                             }
                             }
                         }
                         }
                     }
                     }
+                } else if tAnnotation is CPDFTextWidgetAnnotation {
+                    let font = NSFont(name: (annotationModel.fontName())!, size: (annotationModel.fontSize())) ?? NSFont.systemFont(ofSize: 16)
+                    if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? Int {
+                        let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
+                        if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
+                            annotationModel.setFontName(newFont.fontName)
+                            annotationModel.setFontSize(newFont.pointSize)
+                        }
+                    }
+                    
+                    let tFont = NSFont(name: (annotationModel.fontName())!, size: (annotationModel.fontSize())) ?? NSFont.systemFont(ofSize: 16)
+                    if let family = tFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
+                       let style = tFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
+                        DispatchQueue.main.async {
+                            let selectedStyleIndex = self.setFontStyle(withFontName: family, currentStyle: style)
+                            self.fontStylePopUpButton.selectItem(at: Int(selectedStyleIndex))
+                        }
+                    }
                 }
                 }
             }
             }
         } else {
         } else {