mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 16:10:48 +00:00
Initial implementation of NSFontCollection methods.
This commit is contained in:
parent
479dca0b6d
commit
73bbad4059
2 changed files with 28 additions and 10 deletions
|
@ -51,14 +51,14 @@ APPKIT_EXPORT NSFontCollectionMatchingOptionKey const NSFontCollectionDisallowAu
|
|||
|
||||
typedef NSString* NSFontCollectionName;
|
||||
|
||||
@class NSMutableDictionary, NSMutableArray, GSFontEnumerator, NSArray, NSDictionary, NSError;
|
||||
@class NSMutableDictionary, NSMutableArray, NSArray, NSDictionary, NSError;
|
||||
|
||||
@interface NSFontCollection : NSObject <NSCopying, NSMutableCopying, NSCoding>
|
||||
{
|
||||
NSMutableArray *_fonts;
|
||||
NSMutableDictionary *_collectionDictionary;
|
||||
NSMutableArray *_queryDescriptors;
|
||||
NSMutableArray *_exclusionDescriptors;
|
||||
GSFontEnumerator *_fontEnumerator;
|
||||
}
|
||||
|
||||
// Initializers...
|
||||
|
|
|
@ -36,17 +36,17 @@
|
|||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_fontEnumerator = [[GSFontEnumerator alloc] init];
|
||||
_collectionDictionary = [[NSMutableDictionary alloc] init];
|
||||
_queryDescriptors = [[NSMutableArray alloc] init];
|
||||
_exclusionDescriptors = [[NSMutableArray alloc] init];
|
||||
_fonts = [[NSMutableArray alloc] initWithCapacity: 50];
|
||||
_collectionDictionary = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||
_queryDescriptors = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
_exclusionDescriptors = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_fontEnumerator);
|
||||
RELEASE(_fonts);
|
||||
RELEASE(_collectionDictionary);
|
||||
RELEASE(_queryDescriptors);
|
||||
RELEASE(_exclusionDescriptors);
|
||||
|
@ -55,12 +55,31 @@
|
|||
|
||||
+ (NSFontCollection *) fontCollectionWithDescriptors: (NSArray *)queryDescriptors
|
||||
{
|
||||
return nil;
|
||||
NSFontCollection *fc = [[NSFontCollection alloc] init];
|
||||
NSEnumerator *en = [queryDescriptors objectEnumerator];
|
||||
GSFontEnumerator *fen = [GSFontEnumerator sharedEnumerator];
|
||||
id d = nil;
|
||||
|
||||
while ((d = [en nextObject]) != nil)
|
||||
{
|
||||
NSArray *names = [fen availableFontNamesMatchingFontDescriptor: d];
|
||||
id name = nil;
|
||||
|
||||
en = [names objectEnumerator];
|
||||
while ((name = [en nextObject]) != nil)
|
||||
{
|
||||
NSFont *font = [NSFont fontWithName: name size: 0.0]; // get default size
|
||||
[fc->_fonts addObject: font];
|
||||
}
|
||||
}
|
||||
|
||||
return fc;
|
||||
}
|
||||
|
||||
+ (NSFontCollection *) fontCollectionWithAllAvailableDescriptors
|
||||
{
|
||||
return nil;
|
||||
return [self fontCollectionWithDescriptors:
|
||||
[[GSFontEnumerator sharedEnumerator] availableFontDescriptors]];
|
||||
}
|
||||
|
||||
+ (NSFontCollection *) fontCollectionWithLocale: (NSLocale *)locale
|
||||
|
@ -111,7 +130,6 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
|
||||
// Descriptors
|
||||
- (NSArray *) queryDescriptors // copy
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue