mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Rewrite the reading and writing portions of NSFontCollection so that we can output the root object as NSFontCollectionDictionary
This commit is contained in:
parent
681e5c9ed9
commit
2760d90061
2 changed files with 34 additions and 13 deletions
10
MISSING
10
MISSING
|
@ -6,7 +6,6 @@ MISSING HEADERS
|
|||
> NSAccessibilityCustomRotor.h
|
||||
> NSAccessibilityElement.h
|
||||
> NSAccessibilityProtocols.h
|
||||
> NSAlignmentFeedbackFilter.h
|
||||
> NSCollectionViewCompositionalLayout.h
|
||||
> NSCollectionViewFlowLayout.h
|
||||
> NSCollectionViewGridLayout.h
|
||||
|
@ -36,8 +35,6 @@ MISSING HEADERS
|
|||
> NSPathControl.h
|
||||
> NSPathControlItem.h
|
||||
> NSPersistentDocument.h
|
||||
> NSPressureConfiguration.h
|
||||
> NSQuickDrawView.h
|
||||
> NSRuleEditor.h
|
||||
> NSScrubber.h
|
||||
> NSScrubberItemView.h
|
||||
|
@ -61,8 +58,6 @@ MISSING HEADERS
|
|||
> NSTextInputClient.h
|
||||
> NSTextInputContext.h
|
||||
> NSTitlebarAccessoryViewController.h
|
||||
> NSTouch.h
|
||||
> NSTouchBar.h
|
||||
> NSTypesetter.h
|
||||
> NSUserActivity.h
|
||||
> NSUserInterfaceCompression.h
|
||||
|
@ -109,3 +104,8 @@ Mac Specific
|
|||
> NSWindowScripting.h
|
||||
> NSHapticFeedback.h
|
||||
> NSAppleScriptExtensions.h
|
||||
> NSAlignmentFeedbackFilter.h
|
||||
> NSTouch.h
|
||||
> NSTouchBar.h
|
||||
> NSQuickDrawView.h
|
||||
> NSPressureConfiguration.h
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSData.h>
|
||||
|
||||
#import <AppKit/NSFontCollection.h>
|
||||
#import <GNUstepGUI/GSFontInfo.h>
|
||||
|
||||
|
@ -43,6 +45,7 @@ static NSLock *_fontCollectionLock = nil;
|
|||
+ (void) _loadAvailableFontCollections;
|
||||
- (BOOL) _writeToFile;
|
||||
- (BOOL) _removeFile;
|
||||
- (NSMutableDictionary *) _fontCollectionDictionary;
|
||||
- (void) _setFontCollectionDictionary: (NSMutableDictionary *)dict;
|
||||
- (void) _setQueryAttributes: (NSArray *)queryAttributes;
|
||||
- (void) _setFullFileName: (NSString *)fn;
|
||||
|
@ -105,13 +108,13 @@ static NSLock *_fontCollectionLock = nil;
|
|||
{
|
||||
if ([[file pathExtension] isEqualToString: @"collection"])
|
||||
{
|
||||
NSString *name;
|
||||
name = [file stringByDeletingPathExtension];
|
||||
newCollection = [NSKeyedUnarchiver unarchiveObjectWithFile: [dir stringByAppendingPathComponent: file]];
|
||||
NSString *name = [file stringByDeletingPathExtension];
|
||||
newCollection = [self _readFileAtPath: [dir stringByAppendingPathComponent: file]];
|
||||
if (newCollection != nil && name != nil)
|
||||
{
|
||||
[newCollection _setFullFileName: file];
|
||||
[_availableFontCollections setObject: newCollection forKey: name];
|
||||
[_availableFontCollections setObject: newCollection
|
||||
forKey: name];
|
||||
RELEASE(newCollection);
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +125,15 @@ static NSLock *_fontCollectionLock = nil;
|
|||
}
|
||||
}
|
||||
|
||||
+ (NSFontCollection *) _readFileAtPath: (NSString *)path
|
||||
{
|
||||
NSFontCollection *fc = [[NSFontCollection alloc] init];
|
||||
NSData *d = [NSData dataWithContentsOfFile: path];
|
||||
NSKeyedUnarchiver *u = [[NSKeyedUnarchiver alloc] initForReadingWithData: d];
|
||||
[fc _setFontCollectionDictionary: [u decodeObjectForKey: @"NSFontCollectionDictionary"]];
|
||||
return fc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Writing and Removing Files
|
||||
*/
|
||||
|
@ -214,10 +226,14 @@ static NSLock *_fontCollectionLock = nil;
|
|||
NSLog (@"Failed attempt to create directory %@", path);
|
||||
}
|
||||
}
|
||||
|
||||
success = [NSKeyedArchiver archiveRootObject: self
|
||||
toFile: [self _fullFileName]];
|
||||
|
||||
|
||||
// Write out the file in the proper format...
|
||||
NSMutableData *m = [[NSMutableData alloc] initWithCapacity: 10240];
|
||||
NSKeyedArchiver *a = [[NSKeyedArchiver alloc] initForWritingWithMutableData: m];
|
||||
[a encodeObject: [self _fontCollectionDictionary]
|
||||
forKey: @"NSFontCollectionDictionary"];
|
||||
[a finishEncoding];
|
||||
success = [m writeToFile: [self _fullFileName] atomically: YES];
|
||||
if (success && path_is_standard)
|
||||
{
|
||||
[_fontCollectionLock lock];
|
||||
|
@ -304,6 +320,11 @@ static NSLock *_fontCollectionLock = nil;
|
|||
return result;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *) _fontCollectionDictionary
|
||||
{
|
||||
return _fontCollectionDictionary;
|
||||
}
|
||||
|
||||
- (void) _setFontCollectionDictionary: (NSMutableDictionary *)dict
|
||||
{
|
||||
ASSIGNCOPY(_fontCollectionDictionary, dict);
|
||||
|
|
Loading…
Reference in a new issue