Explorar o código

【注释】文本注释调整字体样式和字重,无效果 -- 修复

lizhe hai 11 meses
pai
achega
aadb3100e4

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

@@ -2012,9 +2012,9 @@ let KMColorPickerViewHeight: CGFloat = 64
                 } else if tAnnotation is KMSelfSignAnnotationFreeText {
                     let newAnnotation = (tAnnotation as! KMSelfSignAnnotationFreeText)
                     if let font = newAnnotation.font {
-                        if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? String {
+                        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: fontSize.stringToCGFloat()) {
+                            if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
                                 newAnnotation.font = newFont
                             }
                         }
@@ -2105,11 +2105,11 @@ let KMColorPickerViewHeight: CGFloat = 64
                     if tAnnotation is CPDFFreeTextAnnotation {
                         let newAnnotation = (tAnnotation as! CPDFFreeTextAnnotation)
                         if let font = newAnnotation.font {
-                            if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? String,
+                            if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? Int,
                                let familyString = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String {
                                 
                                 let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
-                                if let newFont = NSFont(descriptor: attributeFontDescriptor, size: fontSize.stringToCGFloat()) {
+                                if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
                                     newAnnotation.font = newFont
                                 }
                             }
@@ -2117,11 +2117,11 @@ let KMColorPickerViewHeight: CGFloat = 64
                     } else if tAnnotation is KMSelfSignAnnotationFreeText {
                         let newAnnotation = (tAnnotation as! KMSelfSignAnnotationFreeText)
                         if let font = newAnnotation.font {
-                            if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? String,
+                            if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? Int,
                                let familyString = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String {
                                 
                                 let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
-                                if let newFont = NSFont(descriptor: attributeFontDescriptor, size: fontSize.stringToCGFloat()) {
+                                if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
                                     newAnnotation.font = newFont
                                 }
                                 newAnnotation.updateBounds()
@@ -2132,11 +2132,11 @@ let KMColorPickerViewHeight: CGFloat = 64
             } else {
                 if annotationType == .freeText || annotationType == .signText || annotationType == .signDate {
                     let font = NSFont(name: (annotationModel?.fontName())!, size: (annotationModel?.fontSize())!) ?? NSFont.systemFont(ofSize: 16)
-                    if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? String,
+                    if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? Int,
                        let familyString = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String {
                         
                         let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
-                        if let newFont = NSFont(descriptor: attributeFontDescriptor, size: fontSize.stringToCGFloat()) {
+                        if let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize)) {
                             annotationModel?.setFontName(newFont.fontName)
                             annotationModel?.setFontSize(newFont.pointSize)
                         }