Bläddra i källkod

【注释】文本注释,调整了文本的颜色、大小、字体等属性,再保存成预设属性,无效果 -- 修复

lizhe 10 månader sedan
förälder
incheckning
ec020f24b7

+ 13 - 8
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMFreeTextStylesViewController/KMFreeTextStylesViewController.m

@@ -374,18 +374,23 @@ typedef NS_ENUM(NSUInteger, KMFreeTextMenuActionType) {
 
 - (IBAction)styleAddButtonAction:(NSButton *)sender {
     PDFAnnotationFreeText *annotation = (PDFAnnotationFreeText *)self.annotations.firstObject;
-    NSString *fontName = [annotation.font.fontDescriptor objectForKey:NSFontFamilyAttribute] ? : @"PingFang HK";
-    NSString *fontSize = [NSString stringWithFormat:@"%f", annotation.font.pointSize] ? : @"20";
-    NSString *fontWeight = [annotation.font.fontDescriptor objectForKey:NSFontFaceAttribute] ? : @"Regular";
-    NSColor *fontColor = annotation.fontColor ? : [NSColor colorWithRed:36/255.0 green:42/255.0 blue:51/255.0 alpha:1.0];
+    
+    NSFont *annotationModelFont = [NSFont fontWithName:_annotationModel.fontName size:12];
+    
+    NSString *fontName = annotation?[annotation.font.fontDescriptor objectForKey:NSFontFamilyAttribute] ? : @"PingFang HK" : annotationModelFont.fontName;
+    NSString *fontSize = [NSString stringWithFormat:@"%f", annotation? annotation.font.pointSize : _annotationModel.fontSize] ? : @"20";
+    NSString *fontWeight = annotation?[annotation.font.fontDescriptor objectForKey:NSFontFaceAttribute] ? : @"Regular" : [annotationModelFont.fontDescriptor objectForKey:NSFontFaceAttribute];
+    NSColor *fontColor = annotation? annotation.fontColor ? : [NSColor colorWithRed:36/255.0 green:42/255.0 blue:51/255.0 alpha:1.0] : _annotationModel.fontColor;
+    NSColor *backgroundColor = annotation? annotation.color ? : [NSColor colorWithRed:36/255.0 green:42/255.0 blue:51/255.0 alpha:1.0] : _annotationModel.color;
     NSString *alignmentType = @"NSTextAlignmentLeft";
-    if (annotation.alignment == NSTextAlignmentLeft) {
+    NSTextAlignment *alignment = annotation? annotation.alignment : _annotationModel.alignment;
+    if (alignment == NSTextAlignmentLeft) {
         alignmentType = @"NSTextAlignmentLeft";
-    } else if (annotation.alignment == NSTextAlignmentCenter) {
+    } else if (alignment == NSTextAlignmentCenter) {
         alignmentType = @"NSTextAlignmentCenter";
-    } else if (annotation.alignment == NSTextAlignmentRight) {
+    } else if (alignment == NSTextAlignmentRight) {
         alignmentType = @"NSTextAlignmentRight";
-    } else if (annotation.alignment == NSTextAlignmentJustified) {
+    } else if (alignment == NSTextAlignmentJustified) {
         alignmentType = @"NSTextAlignmentJustified";
     }
     NSString *fontAlignment = alignmentType ? : @"NSTextAlignmentLeft";