Cache used fonts in context

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11430 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2001-11-20 05:00:20 +00:00
parent bef0fa9983
commit db7b620c03
6 changed files with 45 additions and 28 deletions

View file

@ -45,9 +45,6 @@ static BOOL boldSystemCacheNeedsRecomputing = NO;
static BOOL userCacheNeedsRecomputing = NO;
static BOOL userFixedCacheNeedsRecomputing = NO;
/* Set used to keep track of fonts we are using */
static NSMutableSet *usedFonts = nil;
@interface NSFont (Private)
- (id) initWithName: (NSString*)name
matrix: (const float*)fontMatrix;
@ -397,21 +394,7 @@ setNSFont(NSString* key, NSFont* font)
+ (void) useFont: (NSString*)name
{
if (usedFonts == nil)
usedFonts = RETAIN([NSMutableSet setWithCapacity: 2]);
[usedFonts addObject: name];
}
+ (void) resetUsedFonts
{
if (usedFonts)
[usedFonts removeAllObjects];
}
+ (NSSet *) usedFonts
{
return usedFonts;
[GSCurrentContext() useFont: name];
}
//
@ -512,7 +495,7 @@ setNSFont(NSString* key, NSFont* font)
NSGraphicsContext *ctxt = GSCurrentContext();
[ctxt setFont: self];
[NSFont useFont: fontName];
[ctxt useFont: fontName];
}
//

View file

@ -216,6 +216,7 @@ NSGraphicsContext *GSCurrentContext()
initWithCapacity: 32];
drag_types = NSCreateMapTable(NSIntMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
usedFonts = nil;
/*
* The classMethodTable dictionary and the list of all contexts must both
@ -387,6 +388,28 @@ NSGraphicsContext *GSCurrentContext()
[self subclassResponsibility: _cmd];
}
- (void) useFont: (NSString*)name
{
if ([self isDrawingToScreen] == YES)
return;
if (usedFonts == nil)
usedFonts = RETAIN([NSMutableSet setWithCapacity: 2]);
[usedFonts addObject: name];
}
- (void) resetUsedFonts
{
if (usedFonts)
[usedFonts removeAllObjects];
}
- (NSSet *) usedFonts
{
return usedFonts;
}
@end
@implementation NSGraphicsContext (Private)

View file

@ -76,11 +76,6 @@ struct NSWindow_struct
@defs(NSWindow)
};
@interface NSFont (NSViewFonts)
+ (void) resetUsedFonts;
+ (NSSet *) usedFonts;
@end
@implementation NSView
/*
@ -2900,7 +2895,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[self endSetup];
}
[NSFont resetUsedFonts];
[ctxt resetUsedFonts];
/* Make sure we set the visible rect so everything is printed. */
[self _rebuildCoordinates];
_visibleRect = _bounds;
@ -2975,7 +2970,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
pages = ceil((float)pages / nup);
DPSPrintf(ctxt, "%%%%Pages: %d\n", pages);
}
fontNames = [NSFont usedFonts];
fontNames = [ctxt usedFonts];
if (fontNames && [fontNames count])
{
NSString *name;