Browse Source

【Form】属性面板中字体显示不应该跟随字体大小变化 -- 修复

lizhe 10 months ago
parent
commit
41dfc115fb

+ 5 - 5
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -3595,23 +3595,23 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         case CAnnotationTypeTextField:{
             CPDFTextWidgetAnnotation *textWidget = [[CPDFTextWidgetAnnotation alloc] initWithKMNoteBounds:bounds document:self.document];
             textWidget.stringValue = NSLocalizedString(@"", nil);
-            NSColor* backgroundColor = [sud colorForKey:@"SKAnnotationTextWidgetBackgroundColorKey"];
+            NSColor* backgroundColor = [sud colorForKey:CAnnotationTextWidgetBackgroundColorKey];
             if (backgroundColor) {
                 textWidget.backgroundColor = backgroundColor;
             } else {
                 textWidget.backgroundColor = [NSColor clearColor];
             }
             
-            NSColor* fontColor = [sud colorForKey:@"SKAnnotationTextWidgetFontColorKey"];
+            NSColor* fontColor = [sud colorForKey:CAnnotationTextWidgetFontColorKey];
             if (fontColor) {
                 textWidget.fontColor = fontColor;
             }
-            textWidget.alignment = [sud integerForKey:@"SKAnnotationTextWidgetAlignmenKey"];
-            NSFont *font = [sud fontForNameKey:SKAnnotationTextWidgetFontNameKey sizeKey:@"SKAnnotationTextWidgetFontSizeKey"];
+            textWidget.alignment = [sud integerForKey:CAnnotationTextWidgetAlignmenKey];
+            NSFont *font = [sud fontForNameKey:SKAnnotationTextWidgetFontNameKey sizeKey:SKAnnotationTextWidgetFontSizeKey];
             if (font) {
                 textWidget.font = font;
             }
-            textWidget.isMultiline = [sud boolForKey:@"SKAnnotationTextMultilineKey"];
+            textWidget.isMultiline = [sud boolForKey:CAnnotationTextWidgetMultilineKey];
             newAnnotation = textWidget;
         }
             break;

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

@@ -196,7 +196,7 @@ import Cocoa
 
                         let menu = NSMenu()
                         for (index, fontName) in fonts.enumerated() {
-                            if let font = NSFont(name: fontName, size: annotation!.fontSize()) {
+                            if let font = NSFont(name: fontName, size: 12.0/*annotation!.fontSize()*/) {
                                 let attributes: [NSAttributedString.Key: Any] = [.font: font]
                                 let attributedString = NSAttributedString(string: fontName, attributes: attributes)
                                 let item = NSMenuItem()
@@ -245,7 +245,7 @@ import Cocoa
                 let style = annotationFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String
                 let menu = NSMenu()
                 for (index, fontName) in fonts.enumerated() {
-                    if let font = NSFont(name: fontName, size: annotationModel.fontSize()) {
+                    if let font = NSFont(name: fontName, size: 12.0/*annotation!.fontSize()*/) {
                         let attributes: [NSAttributedString.Key: Any] = [.font: font]
                         let attributedString = NSAttributedString(string: fontName, attributes: attributes)
                         let item = NSMenuItem()
@@ -278,22 +278,22 @@ import Cocoa
     func updateAnnotationMode() {
         let userDefaults = UserDefaults.standard
         if formMode == .textField {
-            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationTextWidgetBackgroundColorKey)
-            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: SKAnnotationTextWidgetFontColorKey)
-            userDefaults.set(annotationModel.alignment().rawValue, forKey: SKAnnotationTextWidgetAlignmenKey)
+            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: CAnnotationTextWidgetBackgroundColorKey)
+            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: CAnnotationTextWidgetFontColorKey)
+            userDefaults.set(annotationModel.alignment().rawValue, forKey: CAnnotationTextWidgetAlignmenKey)
             userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationTextWidgetFontNameKey)
             userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationTextWidgetFontSizeKey)
             userDefaults.set(annotationModel.isMultiline(), forKey: SKAnnotationTextMultilineKey)
         } else if formMode == .comboBox {
-            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceWidgetBackgroundColorKey)
-            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceWidgetFontColorKey)
-            userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationChoiceWidgetFontNameKey)
-            userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationChoiceWidgetFontSizeKey)
+            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: CAnnotationChoiceWidgetBackgroundColorKey)
+            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: CAnnotationChoiceWidgetFontColorKey)
+            userDefaults.set(annotationModel.fontName(), forKey: CAnnotationChoiceWidgetFontNameKey)
+            userDefaults.set(annotationModel.fontSize(), forKey: CAnnotationChoiceWidgetFontSizeKey)
         } else if formMode == .listMenu {
-            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceListWidgetBackgroundColorKey)
-            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceListWidgetFontColorKey)
-            userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationChoiceListWidgetFontNameKey)
-            userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationChoiceListWidgetFontSizeKey)
+            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: CAnnotationChoiceListWidgetBackgroundColorKey)
+            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: CAnnotationChoiceListWidgetFontColorKey)
+            userDefaults.set(annotationModel.fontName(), forKey: CAnnotationChoiceListWidgetFontNameKey)
+            userDefaults.set(annotationModel.fontSize(), forKey: CAnnotationChoiceListWidgetFontSizeKey)
         }
     }