Ver Fonte

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

niehaoyu há 10 meses atrás
pai
commit
843e6bb70b

+ 3 - 1
PDF Office/PDF Master/Class/Common/OC/OCR/KMGOCRManager.m

@@ -432,7 +432,9 @@ static inline NSFont * FontWithSize(NSString *strChar, CGSize size) {
         }
         NSError *error = nil;
         VNImageRequestHandler *handle = [[VNImageRequestHandler alloc] initWithCGImage:[self nsImageToCGImageRef:image] options:@{}];
-        [handle performRequests:@[self->_appleRequest] error:&error];
+        if (self->_appleRequest){
+            [handle performRequests:@[self->_appleRequest] error:&error];
+        }
     });
 }
 

+ 7 - 7
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFFreeTextAnnotation+PDFListView.swift

@@ -97,9 +97,8 @@ import Foundation
         }
         return CPDFFreeTextAnnotation._ft_keys
     }
-    
+    private static var img: NSImage?
     class func annotationImage(annotationModel: CPDFAnnotationModel) -> NSImage? {
-        var image: NSImage?
         let string: NSString = annotationModel.contents() as? NSString ?? "Sample"
         var attributes: [NSAttributedString.Key : Any] = [:]
         attributes[.font] = NSFont(name: annotationModel.fontName(), size: annotationModel.fontSize())
@@ -135,16 +134,17 @@ import Foundation
         attributes[.paragraphStyle] = style
         
         let size = string.size(withAttributes: attributes)
-        image = NSImage(size: size)
-        image?.lockFocus()
+        self.img = nil
+        self.img = NSImage(size: size)
+        self.img?.lockFocus()
         NSGraphicsContext.current?.imageInterpolation = .high
         
-        let imageSize = image?.size ?? .zero
+        let imageSize = self.img?.size ?? .zero
         string.draw(in: NSMakeRect(0, 0, imageSize.width, imageSize.height), withAttributes: attributes)
         NSGraphicsContext.current?.imageInterpolation = .default
         
-        image?.unlockFocus()
-        return image
+        self.img?.unlockFocus()
+        return self.img
     }
 }
 

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

@@ -2392,38 +2392,16 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         }
     } else if (CAnnotationTypeFreeText == self.annotationType ||
                CAnnotationTypeSignText == self.annotationType) {
-        //保存参数
-        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-        NSString *fontName = [KMEditPDFTextManager.manager fetchFontNameWithFontName: [defaults objectForKey:CFreeTextNoteFontNameKey]];
-        NSString *fontStyle = [KMEditPDFTextManager.manager fetchFontStyleWithFontName: [defaults objectForKey:CFreeTextNoteFontNameKey]];
-        CGFloat size = [[defaults objectForKey:CFreeTextNoteFontSizeKey] floatValue];
-        CGFloat opacity = [[defaults objectForKey:CFreeTextNoteOpacityKey] floatValue] ?:1.0;
-//        CGFloat size = [[defaults objectForKey:CFreeTextNoteFontSizeKey] floatValue];
-//        defaults.safe_setColor(annotation.color, forKey: CFreeTextNoteColorKey)
-//        defaults.safe_setColor((annotation as! CPDFFreeTextAnnotation).fontColor, forKey: CFreeTextNoteFontColorKey)
-//        defaults.set((annotation as! CPDFFreeTextAnnotation).alignment.rawValue, forKey: CFreeTextNoteAlignmentKey)
-//        defaults.set((annotation as! CPDFFreeTextAnnotation).fontName(), forKey: CFreeTextNoteFontNameKey)
-//        defaults.set((annotation as! CPDFFreeTextAnnotation).fontSize(), forKey: CFreeTextNoteFontSizeKey)
-//        defaults.set(annotation.lineWidth(), forKey: CFreeTextNoteLineWidthKey)
-//        defaults.set(annotation.borderStyle().rawValue, forKey: CFreeTextNoteLineStyleKey)
-//        defaults.set(annotation.dashPattern(), forKey: CFreeTextNoteDashPatternKey)
-        
-        
-//        KMEditPDFTextFontModel *model = [KMEditPDFTextManager.manager fetchUserDefaultDataWithTypeStringWithType:@"Commonly"];
-//        NSString *fontName = [KMEditPDFTextManager.manager fetchFontNameWithFontName:model.fontName];
-//        NSString *fontStyle = [KMEditPDFTextManager.manager fetchFontStyleWithFontName:model.fontName];
-//        CGFloat size = model.fontSize;
-        
         CPDFAnnotationModel *annotationModel = [[CPDFAnnotationModel alloc] initWithAnnotationType:self.annotationType];
-        annotationModel.fontName = [NSString stringWithFormat:@"%@-%@",fontName,fontStyle];
-        annotationModel.fontSize = size;
-        annotationModel.opacity = opacity;
         
         CGFloat defaultWidth = annotationModel.fontSize;
         CGFloat defaultHeight = annotationModel.fontSize;
         NSSize defaultSize = ([page rotation] % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) : NSMakeSize(defaultHeight, defaultWidth);
         CGRect bounds =  CPDFListViewRectFromRightAndSize(pagePoint, defaultSize);
         CGFloat fontSize = annotationModel.fontSize;
+        NSString *fontName = annotationModel.fontName;
+        CGFloat opacity = annotationModel.opacity;
+        
         bounds = CGRectMake(pagePoint.x, pagePoint.y - (fontSize+2), defaultSize.width, (fontSize+2));
         
         bounds = CPDFListViewConstrainRect(bounds, page.bounds,[CPDFListViewConfig defaultManager].annotationBorderOffset.floatValue);