Browse Source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

tangchao 10 months ago
parent
commit
cb074b8f17

+ 11 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -1939,7 +1939,7 @@ let KMColorPickerViewHeight: CGFloat = 64
             self!.alignmentTypeSelected(model.fontAlignment)
             self!.textColorPickerView.color = model.fontColor
             
-            DispatchQueue.global(qos: .default).async {
+            DispatchQueue.global(qos: .default).async { [self]
                 let fonts = NSFontManager.shared.availableFontFamilies
                 let menu = NSMenu()
                 var selectedIndex = 0
@@ -1950,14 +1950,20 @@ let KMColorPickerViewHeight: CGFloat = 64
                         let item = NSMenuItem()
                         item.attributedTitle = attributedString
                         menu.addItem(item)
-                        if model.fontName == font.fontName {
-                            selectedIndex = index
+                        
+                        if let family = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
+                           let style = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
+                            if model.fontName == family {
+                                selectedIndex = index
+                            }
                         }
                     }
                 }
                 DispatchQueue.main.async {
-                    self!.fontPopUpButton.menu = menu
-                    self!.fontPopUpButton.selectItem(at: selectedIndex)
+                    if self != nil {
+                        self!.fontPopUpButton.menu = menu
+                        self!.fontPopUpButton.selectItem(at: selectedIndex)
+                    }
                 }
             }
             let selectedStyleIndex = self!.setFontStyle(fontName: model.fontName, currentStyle: model.fontWeight)

+ 10 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/WindowController/KMAnnotationFontWindowController.swift

@@ -132,8 +132,11 @@ class KMFontModel: NSObject {
                     let string = NSAttributedString(string: fontName, attributes: attributes)
                     fontArr.append(string)
                     
-                    if self.annotationFontModel?.fontName == font.fontName {
-                        selectedIndex = index
+                    if let family = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
+                       let style = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
+                        if self.annotationFontModel?.fontName == family {
+                            selectedIndex = index
+                        }
                     }
                 }
             }
@@ -208,8 +211,11 @@ class KMFontModel: NSObject {
                     item.attributedTitle = attributedString
                     menu.addItem(item)
                     
-                    if annotationFontModel?.fontName == font.fontName {
-                        selectedIndex = index
+                    if let family = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
+                       let style = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
+                        if self.annotationFontModel?.fontName == family {
+                            selectedIndex = index
+                        }
                     }
                 }
             }