Revision: 16583
http://sourceforge.net/p/skim-app/code/16583
Author: hofman
Date: 2026-10-01 16:07:25 +0000 (Thu, 01 Oct 2026)
Log Message:
-----------
set default font for attributed text of Text or Stamp annotation when it has no
attributes
Modified Paths:
--------------
trunk/PDFAnnotation_SKExtensions.m
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2026-10-01 15:57:20 UTC (rev 16582)
+++ trunk/PDFAnnotation_SKExtensions.m 2026-10-01 16:07:25 UTC (rev 16583)
@@ -295,8 +295,19 @@
return properties;
NSMutableDictionary *mutableProperties = [properties mutableCopy];
[mutableProperties setObject:SKNNoteString forKey:SKNPDFAnnotationTypeKey];
- NSString *contents = [properties objectForKey:SKNPDFAnnotationContentsKey];
- if (contents) {
+ NSAttributedString *attrString = [properties
objectForKey:SKNPDFAnnotationTextKey];
+ NSString *contents;
+ if (attrString) {
+ if ([attrString isKindOfClass:[NSData class]])
+ attrString = [[NSAttributedString alloc] initWithData:(NSData
*)attrString options:@{} documentAttributes:NULL error:NULL];
+ NSRange r;
+ if ([[attrString attributesAtIndex:0 effectiveRange:&r] count] == 0 &&
r.length == [attrString length]) {
+ NSFont *font = [[NSUserDefaults standardUserDefaults]
fontForNameKey:SKAnchoredNoteFontNameKey sizeKey:SKAnchoredNoteFontSizeKey];
+ attrString = [[NSAttributedString alloc]
initWithString:[attrString string]
+ attributes:[NSDictionary
dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]];
+ [mutableProperties setObject:attrString
forKey:SKNPDFAnnotationTextKey];
+ }
+ } else if ((contents = [properties
objectForKey:SKNPDFAnnotationContentsKey])) {
NSRange r = [contents rangeOfString:@" "];
NSRange r1 = [contents rangeOfString:@"\n"];
if (r1.location < r.location)
@@ -303,7 +314,7 @@
r = r1;
if (NSMaxRange(r) < [contents length]) {
NSFont *font = [[NSUserDefaults standardUserDefaults]
fontForNameKey:SKAnchoredNoteFontNameKey sizeKey:SKAnchoredNoteFontSizeKey];
- NSAttributedString *attrString = [[NSAttributedString alloc]
initWithString:[contents substringFromIndex:NSMaxRange(r)]
+ attrString = [[NSAttributedString alloc] initWithString:[contents
substringFromIndex:NSMaxRange(r)]
attributes:[NSDictionary
dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]];
[mutableProperties setObject:attrString
forKey:SKNPDFAnnotationTextKey];
[mutableProperties setObject:[contents
substringToIndex:r.location] forKey:SKNPDFAnnotationContentsKey];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit