|
@@ -4086,6 +4086,80 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
[self.activeAnnotations addObject:annotation];
|
|
|
}
|
|
|
[[NSFontManager sharedFontManager] orderFrontFontPanel:sender];
|
|
|
+ [[NSFontManager sharedFontManager] setTarget:self];
|
|
|
+ [[NSFontManager sharedFontManager] setAction:@selector(changeFontPanel:)];
|
|
|
+// [[NSFontManager sharedFontManager] orderFrontFontPanel:self];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)changeFontPanel:(id)sender {
|
|
|
+ for (CPDFAnnotation *tAnnotation in self.activeAnnotations) {
|
|
|
+ if ([tAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
|
|
|
+ NSFont *font = [NSFont fontWithName:tAnnotation.fontName size:tAnnotation.fontSize];
|
|
|
+ NSFont *newfont = [sender convertFont:font];
|
|
|
+ if (newfont) {
|
|
|
+ ((CPDFFreeTextAnnotation *)tAnnotation).font = newfont;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [self updateAnnotation];
|
|
|
+ [self adjustFreeText];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updateAnnotation {
|
|
|
+ if ([self.activeAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
|
|
|
+ CPDFFreeTextAnnotation *textNote = (CPDFFreeTextAnnotation *)self.activeAnnotation;
|
|
|
+ BOOL isEdit = [self isEditWithCurrentFreeText:textNote];
|
|
|
+ if (isEdit) {
|
|
|
+ [self commitEditAnnotationFreeText:textNote];
|
|
|
+ }
|
|
|
+ [self setNeedsDisplayAnnotation:self.activeAnnotation];
|
|
|
+ }
|
|
|
+ for (CPDFAnnotation *tAnnotation in self.activeAnnotations) {
|
|
|
+ if ([tAnnotation isKindOfClass:[CPDFStampAnnotation class]]) {
|
|
|
+ [(KMSelfSignAnnotation *)tAnnotation updateAppearanceStream];
|
|
|
+ }
|
|
|
+ if ([tAnnotation isKindOfClass:[CPDFMarkupAnnotation class]]) {
|
|
|
+ [self setNeedsDisplayForPage:tAnnotation.page];
|
|
|
+ } else {
|
|
|
+ [self setNeedsDisplayAnnotationViewForPage:tAnnotation.page];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+-(void)adjustFreeText {
|
|
|
+ if (self.activeAnnotations.count > 0) {
|
|
|
+ for (CPDFAnnotation *an in self.activeAnnotations) {
|
|
|
+ if ([an isKindOfClass:[CPDFFreeTextAnnotation class]]) {
|
|
|
+ CPDFFreeTextAnnotation *freeTextAn = (CPDFFreeTextAnnotation *)an;
|
|
|
+ NSFont *font = freeTextAn.font;
|
|
|
+ NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
|
|
|
+ attributes[NSFontAttributeName] = font;
|
|
|
+ NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
|
|
|
+ style.alignment = freeTextAn.alignment;
|
|
|
+ attributes[NSParagraphStyleAttributeName] = style;
|
|
|
+
|
|
|
+ NSString *contents = freeTextAn.contents ?: @"";
|
|
|
+ CGSize textViewSize = [contents boundingRectWithSize:CGSizeMake(freeTextAn.bounds.size.width, MAXFLOAT)
|
|
|
+ options:NSStringDrawingUsesLineFragmentOrigin
|
|
|
+ attributes:attributes
|
|
|
+ context:nil].size;
|
|
|
+
|
|
|
+ CGRect rect = freeTextAn.bounds;
|
|
|
+
|
|
|
+ if (textViewSize.height != freeTextAn.bounds.size.height) {
|
|
|
+ rect.origin.y -= (textViewSize.height - rect.size.height);
|
|
|
+ rect.size.height = textViewSize.height;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (textViewSize.width < freeTextAn.bounds.size.width) {
|
|
|
+ rect.size.width = textViewSize.width;
|
|
|
+ }
|
|
|
+
|
|
|
+ freeTextAn.bounds = rect;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)PreviousPageAction:(NSMenuItem *)item{
|