Reorganised the handling of the font enumerator. New

[_includeFont:] is only called from here. Corrected
[availableMembersOfFontFamily:] and [fontNamed:hasTraits:].


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11376 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2001-11-12 16:42:54 +00:00
parent 78af7eab3a
commit bb47d9c045

View file

@ -49,7 +49,7 @@ static NSFontPanel *fontPanel = nil;
static Class fontManagerClass = Nil; static Class fontManagerClass = Nil;
static Class fontPanelClass = Nil; static Class fontPanelClass = Nil;
@interface NSFontManager (GNUstepBackend) @interface NSFontManager (GNUstepPrivate)
- (BOOL) _includeFont: (NSString*)fontName; - (BOOL) _includeFont: (NSString*)fontName;
@end @end
@ -110,8 +110,7 @@ static Class fontPanelClass = Nil;
_action = @selector(changeFont:); _action = @selector(changeFont:);
_storedTag = NSNoFontChangeAction; _storedTag = NSNoFontChangeAction;
_fontEnumerator = RETAIN([GSFontEnumerator _fontEnumerator = RETAIN([GSFontEnumerator sharedEnumerator]);
sharedEnumeratorWithFontManager: self]);
return self; return self;
} }
@ -129,7 +128,20 @@ static Class fontPanelClass = Nil;
*/ */
- (NSArray*) availableFonts - (NSArray*) availableFonts
{ {
return [_fontEnumerator availableFonts]; int i;
NSArray *fontsList = [_fontEnumerator availableFonts];
NSMutableArray *fontNames = [NSMutableArray
arrayWithCapacity: [fontsList count]];
for (i = 0; i < [fontsList count]; i++)
{
NSString *name = [fontsList objectAtIndex: i];
if ([self _includeFont: name])
[fontNames addObject: name];
}
return fontNames;
} }
- (NSArray*) availableFontFamilies - (NSArray*) availableFontFamilies
@ -168,13 +180,23 @@ static Class fontPanelClass = Nil;
return fontNames; return fontNames;
} }
/*
* This are somewhat strange methods, as they are not in the list,
* but their implementation is defined.
*/
- (NSArray*) availableMembersOfFontFamily: (NSString*)family - (NSArray*) availableMembersOfFontFamily: (NSString*)family
{ {
return [_fontEnumerator availableMembersOfFontFamily: family]; int i;
NSArray *fontsList = [_fontEnumerator availableMembersOfFontFamily: family];
NSMutableArray *fonts = [NSMutableArray
arrayWithCapacity: [fontsList count]];
for (i = 0; i < [fontsList count]; i++)
{
NSArray *fontDef = [fontsList objectAtIndex: i];
NSString *name = [fontDef objectAtIndex: 0];
if ([self _includeFont: name])
[fonts addObject: fontDef];
}
return fonts;
} }
- (NSString*) localizedNameForFamily: (NSString*)family - (NSString*) localizedNameForFamily: (NSString*)family
@ -778,7 +800,7 @@ static Class fontPanelClass = Nil;
- (BOOL) fontNamed: (NSString*)typeface - (BOOL) fontNamed: (NSString*)typeface
hasTraits: (NSFontTraitMask)fontTraitMask; hasTraits: (NSFontTraitMask)fontTraitMask;
{ {
// TODO: THis method is implemented very slow, but I dont // TODO: This method is implemented very slow, but I dont
// see any use for it, so why change it? // see any use for it, so why change it?
int i, j; int i, j;
NSArray *fontFamilies = [self availableFontFamilies]; NSArray *fontFamilies = [self availableFontFamilies];
@ -793,7 +815,7 @@ static Class fontPanelClass = Nil;
{ {
NSArray *fontDef = [fontDefs objectAtIndex: j]; NSArray *fontDef = [fontDefs objectAtIndex: j];
if ([[fontDef objectAtIndex: 3] isEqualToString: typeface]) if ([[fontDef objectAtIndex: 0] isEqualToString: typeface])
{ {
traits = [[fontDef objectAtIndex: 3] unsignedIntValue]; traits = [[fontDef objectAtIndex: 3] unsignedIntValue];
// FIXME: This is not exactly the right condition // FIXME: This is not exactly the right condition
@ -966,7 +988,7 @@ static Class fontPanelClass = Nil;
@end @end
@implementation NSFontManager (GNUstepBackend) @implementation NSFontManager (GNUstepPrivate)
/* /*
* Ask delegate if to include a font * Ask delegate if to include a font