Revision: 15074 http://sourceforge.net/p/skim-app/code/15074 Author: hofman Date: 2025-04-03 14:55:48 +0000 (Thu, 03 Apr 2025) Log Message: ----------- macro for NSPboardType to UTI
Modified Paths: -------------- trunk/SKFontWell.m Modified: trunk/SKFontWell.m =================================================================== --- trunk/SKFontWell.m 2025-04-03 09:39:48 UTC (rev 15073) +++ trunk/SKFontWell.m 2025-04-03 14:55:48 UTC (rev 15074) @@ -44,6 +44,7 @@ #define SKNSFontPanelDescriptorsPboardType @"NSFontPanelDescriptorsPboardType" #define SKNSFontPanelFamiliesPboardType @"NSFontPanelFamiliesPboardType" +#define UTIForNSPboardType(type) CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (__bridge CFStringRef)type, NULL)) #define SKNSFontCollectionFontDescriptors @"NSFontCollectionFontDescriptors" #define SKFontWellWillBecomeActiveNotification @"SKFontWellWillBecomeActiveNotification" @@ -294,7 +295,7 @@ @try { if ([type isEqualToString:SKNSFontPanelDescriptorsPboardType]) { - NSData *data = [pboard dataForType:type] ?: [pboard dataForType:CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (__bridge CFStringRef)type, NULL))]; + NSData *data = [pboard dataForType:type] ?: [pboard dataForType:UTIForNSPboardType(type)]; NSDictionary *dict = [data isKindOfClass:[NSData class]] ? [NSKeyedUnarchiver unarchiveObjectWithData:data] : nil; if ([dict isKindOfClass:[NSDictionary class]]) { NSArray *fontDescriptors = [dict objectForKey:SKNSFontCollectionFontDescriptors]; @@ -306,7 +307,7 @@ } } } else if ([type isEqualToString:SKNSFontPanelFamiliesPboardType]) { - NSArray *families = [pboard propertyListForType:type] ?: [pboard propertyListForType:CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (__bridge CFStringRef)type, NULL))]; + NSArray *families = [pboard propertyListForType:type] ?: [pboard propertyListForType:UTIForNSPboardType(type)]; NSString *family = ([families isKindOfClass:[NSArray class]] && [families count]) ? [families objectAtIndex:0] : nil; if ([family isKindOfClass:[NSString class]]) droppedFont = [[NSFontManager sharedFontManager] convertFont:[self font] toFamily:family]; @@ -431,7 +432,7 @@ NSDictionary *dict = @{SKNSFontCollectionFontDescriptors: @[[[self font] fontDescriptor]], NSFontSizeAttribute: [NSNumber numberWithDouble:[[self font] pointSize]]}; NSData *data = [NSKeyedArchiver archivedDataWithRootObject:dict]; NSPasteboardItem *item = [[NSPasteboardItem alloc] init]; - [item setData:data forType:CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (__bridge CFStringRef)SKNSFontPanelDescriptorsPboardType, NULL))]; + [item setData:data forType:UTIForNSPboardType(SKNSFontPanelDescriptorsPboardType)]; NSDraggingItem *dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:item]; [dragItem setDraggingFrame:bounds contents:dragImage]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit